本文整理汇总了C#中INamespaceSymbol.GetTypeMembers方法的典型用法代码示例。如果您正苦于以下问题:C# INamespaceSymbol.GetTypeMembers方法的具体用法?C# INamespaceSymbol.GetTypeMembers怎么用?C# INamespaceSymbol.GetTypeMembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INamespaceSymbol
的用法示例。
在下文中一共展示了INamespaceSymbol.GetTypeMembers方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CollectTypes
private static void CollectTypes(INamespaceSymbol ns, List<ITypeSymbol> types)
{
types.AddRange(ns.GetTypeMembers().Cast<ITypeSymbol>());
foreach (var nestedNs in ns.GetNamespaceMembers())
{
CollectTypes(nestedNs, types);
}
}
示例2: Visit
private void Visit(INamespaceSymbol nameSpace)
{
foreach (var type in nameSpace.GetTypeMembers())
{
Visit(type);
}
foreach (var innerNameSpace in nameSpace.GetNamespaceMembers())
{
Visit(innerNameSpace);
}
}
示例3: ParseProjectNamespacesRecursively
internal void ParseProjectNamespacesRecursively(INamespaceSymbol namespaceSymbol)
{
HandleOnItemParseStart(namespaceSymbol.Name);
if (!ParserOptions.SharpDoxConfig.ExcludedIdentifiers.Contains(namespaceSymbol.GetIdentifier()))
{
var sdNamespace = GetParsedNamespace(namespaceSymbol);
ParserOptions.SDRepository.AddNamespace(sdNamespace);
_typeParser.ParseProjectTypes(namespaceSymbol.GetTypeMembers().ToList());
}
foreach (var childNamespaceSymbol in namespaceSymbol.GetNamespaceMembers())
{
ParseProjectNamespacesRecursively(childNamespaceSymbol);
}
}
示例4: VisitNamespace
public override void VisitNamespace(INamespaceSymbol symbol)
{
if (_finished || _symbolPredicate == null || _symbolPredicate(symbol))
{
AddDocument(symbol, true, new MetadataItems
{
{ CodeAnalysisKeys.SpecificKind, (k, m) => symbol.Kind.ToString() },
{ CodeAnalysisKeys.MemberNamespaces, DocumentsFor(symbol.GetNamespaceMembers()) },
{ CodeAnalysisKeys.MemberTypes, DocumentsFor(symbol.GetTypeMembers()) }
});
}
// Descend if not finished, regardless if this namespace was included
if (!_finished)
{
Parallel.ForEach(symbol.GetMembers(), s => s.Accept(this));
}
}
示例5: GetAllTypesInModuleSymbol
private static IEnumerable<ITypeSymbol> GetAllTypesInModuleSymbol(INamespaceSymbol symbol)
{
return Enumerable.Concat(symbol.GetTypeMembers(), symbol.GetNamespaceMembers().SelectMany(GetAllTypesInModuleSymbol));
}
示例6: GetExportedTypes
private static void GetExportedTypes(INamespaceSymbol namespaceSymbol, List<ITypeInfo> exportedTypes)
{
foreach (var type in namespaceSymbol.GetTypeMembers())
{
if (type.TypeKind == TypeKind.Class &&
type.DeclaredAccessibility == Accessibility.Public)
{
exportedTypes.Add(new CodeAnalysisSymbolBasedTypeInfo(type));
}
}
foreach (var subNamespace in namespaceSymbol.GetNamespaceMembers())
{
GetExportedTypes(subNamespace, exportedTypes);
}
}
示例7: FillNamespaces
public static void FillNamespaces (ITreeBuilder builder, Project project, INamespaceSymbol ns)
{
var members = ns.GetTypeMembers ();
//IParserContext ctx = IdeApp.Workspace.ParserDatabase.GetProjectParserContext (project);
if (members.Any ()) {
if (builder.Options ["ShowProjects"])
builder.AddChild (new ProjectNamespaceData (project, ns));
else {
if (!builder.HasChild (ns.Name, typeof (NamespaceData)))
builder.AddChild (new ProjectNamespaceData (null, ns));
}
}
foreach (var nSpace in ns.GetNamespaceMembers ()) {
FillNamespaces (builder, project, nSpace);
}
}
示例8: VisitNamespace
public override void VisitNamespace(INamespaceSymbol symbol)
{
base.VisitNamespace(symbol);
foreach (var item in symbol.GetTypeMembers())
{
item.Accept(this);
}
foreach (var item in symbol.GetNamespaceMembers())
{
item.Accept(this);
}
}
示例9: ProcessNamespace
/// <summary>
/// Reqursively goes through all namespaces in the assembly and discovers unique types, extensions and namespaces.
/// </summary>
private void ProcessNamespace(AssemblyMetadata assembly, INamespaceSymbol namespaceSymbol)
{
var assemblyName = Path.GetFileName(assembly.FullPath);
if (string.IsNullOrEmpty(assemblyName) || namespaceSymbol == null)
{
return;
}
var fullNamespaceName = (namespaceSymbol.ContainingNamespace == null || string.IsNullOrEmpty(namespaceSymbol.ContainingNamespace.Name))
? namespaceSymbol.Name
: namespaceSymbol.ContainingNamespace + "." + namespaceSymbol.Name;
foreach (var typeName in namespaceSymbol.GetTypeMembers())
{
try
{
// keep only public types
if (typeName.DeclaredAccessibility != Accessibility.Public)
{
continue;
}
var typeFullName = string.IsNullOrEmpty(fullNamespaceName)
? typeName.Name
: typeName.ContainingNamespace + "." + typeName.Name;
// if we meet this type first time - remember it
if (!_types.ContainsKey(typeFullName))
{
var newType = new TypeModel
{
Name = typeName.Name,
FullName = typeFullName,
AssemblyName = assemblyName,
PackageName = _package.Id,
PackageVersion = _package.Version
};
newType.TargetFrameworks.AddRange(assembly.TargetFrameworks);
_types.Add(typeFullName, newType);
// if namespace contains at least one type and we meet this namespace first time - remember it
if (!string.IsNullOrEmpty(fullNamespaceName) && !_namespaces.ContainsKey(fullNamespaceName))
{
var newNamespace = new NamespaceModel
{
Name = fullNamespaceName,
AssemblyName = assemblyName,
PackageName = _package.Id,
PackageVersion = _package.Version
};
newNamespace.TargetFrameworks.AddRange(assembly.TargetFrameworks);
_namespaces.Add(fullNamespaceName, newNamespace);
}
else
{
var namespaceModel = _namespaces[fullNamespaceName];
namespaceModel.MergeTargetFrameworks(assembly.TargetFrameworks);
}
}
else
{
var typeModel = _types[typeFullName];
typeModel.MergeTargetFrameworks(assembly.TargetFrameworks);
if (!string.IsNullOrEmpty(fullNamespaceName))
{
var namespaceModel = _namespaces[fullNamespaceName];
namespaceModel.MergeTargetFrameworks(assembly.TargetFrameworks);
}
}
// if type is static, then it might contain extension methdos
if (typeName.IsStatic)
{
foreach (var member in typeName.GetMembers())
{
// proceed only if static type's member is a method and it is public
var method = member as IMethodSymbol;
if (method == null || method.DeclaredAccessibility != Accessibility.Public)
{
continue;
}
if (method.IsExtensionMethod)
{
var thisParameter = method.Parameters[0];
var extensionMethodTypeName = thisParameter.Type.ContainingNamespace + "." + thisParameter.Type.Name;
var extensionFullName = extensionMethodTypeName + "." + method.Name;
// if we meet this extension first time - remember it
if (!_extensions.ContainsKey(extensionFullName))
{
var newExtension = new ExtensionModel
{
Name = method.Name,
//.........这里部分代码省略.........
示例10: EnumSymbols
private static void EnumSymbols(INamespaceSymbol namespaceSymbol, Action<ISymbol> action)
{
foreach (var subNamespace in namespaceSymbol.GetNamespaceMembers())
{
EnumSymbols(subNamespace, action);
}
foreach (var topLevelType in namespaceSymbol.GetTypeMembers())
{
action(topLevelType);
}
}
示例11: ScanNamespace
private static void ScanNamespace(IList<Diagnostic> diagnostics, INamespaceSymbol namespaceSymbol)
{
foreach (var member in namespaceSymbol.GetNamespaceMembers())
{
ScanNamespace(diagnostics, member);
}
foreach (var member in namespaceSymbol.GetTypeMembers())
{
ScanType(diagnostics, member);
}
}