本文整理汇总了C#中INamespaceSymbol.GetNamespaceMembers方法的典型用法代码示例。如果您正苦于以下问题:C# INamespaceSymbol.GetNamespaceMembers方法的具体用法?C# INamespaceSymbol.GetNamespaceMembers怎么用?C# INamespaceSymbol.GetNamespaceMembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INamespaceSymbol
的用法示例。
在下文中一共展示了INamespaceSymbol.GetNamespaceMembers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: GetNamespace
private static INamespaceSymbol GetNamespace(string nspace, INamespaceSymbol namespaceSymbol)
{
namespaceSymbol = namespaceSymbol.GetNamespaceMembers()
.FirstOrDefault(ns =>
{
string fullNamespace = CodeAnalysisHelper.GetFullNamespace(ns);
return nspace == fullNamespace || nspace.StartsWith(fullNamespace + Type.Delimiter);
});
if (namespaceSymbol != null && CodeAnalysisHelper.GetFullNamespace(namespaceSymbol) != nspace)
{
namespaceSymbol = CodeAnalysisHelper.GetNamespace(nspace, namespaceSymbol);
}
return namespaceSymbol;
}
示例5: 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));
}
}
示例6: GetAllTypesInModuleSymbol
private static IEnumerable<ITypeSymbol> GetAllTypesInModuleSymbol(INamespaceSymbol symbol)
{
return Enumerable.Concat(symbol.GetTypeMembers(), symbol.GetNamespaceMembers().SelectMany(GetAllTypesInModuleSymbol));
}
示例7: AddNamespacesFromCompilation
private static void AddNamespacesFromCompilation(ConcurrentBag<string> namespaceNamesInCompilation, INamespaceSymbol @namespace)
{
namespaceNamesInCompilation.Add(@namespace.ToDisplayString());
foreach (INamespaceSymbol namespaceMember in @namespace.GetNamespaceMembers())
{
AddNamespacesFromCompilation(namespaceNamesInCompilation, namespaceMember);
}
}
示例8: 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);
}
}
示例9: 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);
}
}
示例10: 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);
}
}
示例11: LookupNamespace
static INamespaceSymbol LookupNamespace (string documentationCommentId, ref int reminder, INamespaceSymbol current)
{
var exact = documentationCommentId.IndexOf ('.', reminder) < 0;
foreach (var subNamespace in current.GetNamespaceMembers ()) {
if (exact) {
if (subNamespace.Name.Length == documentationCommentId.Length - reminder &&
string.CompareOrdinal (documentationCommentId, reminder, subNamespace.Name, 0, subNamespace.Name.Length) == 0)
return subNamespace;
} else {
if (subNamespace.Name.Length < documentationCommentId.Length - reminder - 1 &&
string.CompareOrdinal (documentationCommentId, reminder, subNamespace.Name, 0, subNamespace.Name.Length) == 0 &&
documentationCommentId [reminder + subNamespace.Name.Length] == '.') {
reminder += subNamespace.Name.Length + 1;
return LookupNamespace (documentationCommentId, ref reminder, subNamespace);
}
}
}
return current;
}
示例12: ProcessNamespace
//.........这里部分代码省略.........
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,
FullName = extensionFullName,
AssemblyName = assemblyName,
PackageName = _package.Id,
PackageVersion = _package.Version,
Namespace = fullNamespaceName
};
newExtension.TargetFrameworks.AddRange(assembly.TargetFrameworks);
_extensions.Add(extensionFullName, newExtension);
}
else
{
var extensionModel = _extensions[extensionFullName];
extensionModel.MergeTargetFrameworks(assembly.TargetFrameworks);
}
}
}
}
}
catch(Exception e)
{
Debug.Write(e.ToString());
}
}
// recurse to chilren namespaces
foreach (var childNamespace in namespaceSymbol.GetNamespaceMembers())
{
if (childNamespace.NamespaceKind == NamespaceKind.Module)
{
ProcessNamespace(assembly, childNamespace);
}
}
}
示例13: 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);
}
}
示例14: MapGlobalTypes
internal static void MapGlobalTypes(NamespaceInfoMap nsInfoMap, INamespaceSymbol nsSymbol)
{
if (!nsSymbol.IsGlobalNamespace)
{
foreach (var nsInfo in nsInfoMap.Values)
{
if (nsSymbol.FullNameEquals(nsInfo.DottedName.NameParts))
{
var typeSymbolList = nsSymbol.GetMembers().OfType<INamedTypeSymbol>().Where(i => i.TypeKind == Microsoft.CodeAnalysis.TypeKind.Class).ToList();
for (var i = 0; i < typeSymbolList.Count;)
{
var typeSymbol = typeSymbolList[i];
var clsAttData = typeSymbol.GetAttributeData(SchemaClassAttributeNameParts);
if (clsAttData != null)
{
if (typeSymbol.IsGenericType)
{
CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.SchemaClassCannotBeGeneric), GetTextSpan(typeSymbol));
}
if (typeSymbol.IsStatic)
{
CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.SchemaClassCannotBeStatic), GetTextSpan(typeSymbol));
}
var clsName = GetFirstArgumentAsString(clsAttData);
if (clsName == null)
{
CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.InvalidSchemaClassAttribute), GetTextSpan(clsAttData));
}
var clsInfo = nsInfo.TryGetGlobalType<ClassTypeInfo>(clsName);
if (clsInfo == null)
{
CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.InvalidSchemaClassAttributeName, clsName), GetTextSpan(clsAttData));
}
if (clsInfo.Symbol != null)
{
CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.DuplicateSchemaClassAttributeName, clsName), GetTextSpan(clsAttData));
}
if (!clsInfo.IsAbstract)
{
if (typeSymbol.IsAbstract)
{
CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.NonAbstractSchemaClassRequired),
GetTextSpan(typeSymbol));
}
if (!typeSymbol.HasParameterlessConstructor())
{
CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.ParameterlessConstructorRequired),
GetTextSpan(typeSymbol));
}
}
clsInfo.Symbol = typeSymbol;
typeSymbolList.RemoveAt(i);
continue;
}
++i;
}
foreach (var typeSymbol in typeSymbolList)
{
if (!typeSymbol.IsGenericType)
{
var clsName = typeSymbol.Name;
var clsInfo = nsInfo.TryGetGlobalType<ClassTypeInfo>(clsName);
if (clsInfo != null)
{
if (clsInfo.Symbol == null)
{
if (typeSymbol.IsStatic)
{
CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.SchemaClassCannotBeStatic), GetTextSpan(typeSymbol));
}
if (!clsInfo.IsAbstract)
{
if (typeSymbol.IsAbstract)
{
CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.NonAbstractSchemaClassRequired),
GetTextSpan(typeSymbol));
}
if (!typeSymbol.HasParameterlessConstructor())
{
CompilerContext.ErrorAndThrow(new DiagMsgEx(DiagCodeEx.ParameterlessConstructorRequired),
GetTextSpan(typeSymbol));
}
}
clsInfo.Symbol = typeSymbol;
}
}
}
}
}
}
}
foreach (var subNsSymbol in nsSymbol.GetNamespaceMembers())
{
MapGlobalTypes(nsInfoMap, subNsSymbol);
}
}
示例15: 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);
}
}