本文整理汇总了C#中INamespaceSymbol.GetMembers方法的典型用法代码示例。如果您正苦于以下问题:C# INamespaceSymbol.GetMembers方法的具体用法?C# INamespaceSymbol.GetMembers怎么用?C# INamespaceSymbol.GetMembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INamespaceSymbol
的用法示例。
在下文中一共展示了INamespaceSymbol.GetMembers方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitNamespace
public override void VisitNamespace(INamespaceSymbol symbol)
{
foreach (var member in symbol.GetMembers())
{
member.Accept(this);
}
}
示例2: VisitNamespace
public override void VisitNamespace(INamespaceSymbol symbol)
{
symbols.Add(symbol);
foreach (var childSymbol in symbol.GetMembers())
{
childSymbol.Accept(this);
}
}
示例3: VisitNamespace
public override void VisitNamespace(INamespaceSymbol symbol)
{
if (IsUnimportantSymbol(symbol))
return;
PrettyPrint(symbol);
tabCount++;
foreach(var childSymbol in symbol.GetMembers())
{
childSymbol.Accept(this);
}
tabCount--;
}
示例4: AddNamespace
private void AddNamespace(INamespaceSymbol namespaceSymbol)
{
if (!_names.IsEmpty) return;
var classList = namespaceSymbol.GetMembers();
var methodsList = classList.ToList().SelectMany(x => x.GetMembers());
var methods = new List<ISymbol>(methodsList);
try
{
_names = new ConcurrentBag<ISymbol>(methods);
}
catch
{
}
}
示例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: GetRuleDependencyAttributeTypeSymbols
private ImmutableArray<INamedTypeSymbol> GetRuleDependencyAttributeTypeSymbols(INamespaceSymbol globalNamespace)
{
var builder = ImmutableArray.CreateBuilder<INamedTypeSymbol>();
foreach (var antlr4Namespace in globalNamespace.GetMembers("Antlr4").OfType<INamespaceSymbol>())
{
foreach (var runtimeNamespace in antlr4Namespace.GetMembers("Runtime").OfType<INamespaceSymbol>())
{
builder.AddRange(runtimeNamespace.GetTypeMembers("RuleDependencyAttribute"));
}
}
return builder.ToImmutable();
}
示例7: BindsWithoutErrors
private bool BindsWithoutErrors(INamespaceSymbol ns, string rightName, bool isAttributeName)
{
// If there was no name on the right, then this binds without any problems.
if (rightName == null)
{
return true;
}
// Otherwise, see if the namespace we will bind this contains a member with the same
// name as the name on the right.
var types = ns.GetMembers(rightName);
if (types.Any())
{
return true;
}
if (!isAttributeName)
{
return false;
}
return BindsWithoutErrors(ns, rightName + "Attribute", isAttributeName: false);
}
示例8: VisitNamespace
public override void VisitNamespace(INamespaceSymbol symbol)
{
foreach (var member in symbol.GetMembers()) { Visit(member); }
base.VisitNamespace(symbol);
}
示例9: TranslateMetadata
private NestedUnitNamespace TranslateMetadata(INamespaceSymbol namespaceSymbol) {
Contract.Requires(namespaceSymbol != null);
Contract.Ensures(Contract.Result<UnitNamespace>() != null);
IUnitNamespaceReference nsr;
if (this.namespaceSymbolCache.TryGetValue(namespaceSymbol, out nsr)) {
var alreadyTranslatedNamespace = nsr as IUnitNamespace;
if (alreadyTranslatedNamespace != null) return alreadyTranslatedNamespace as NestedUnitNamespace;
}
var ns = CreateNamespaceDefinition(namespaceSymbol);
var mems = new List<INamespaceMember>();
foreach (var m in namespaceSymbol.GetMembers()) {
var nestedNamespaceSymbol = m as INamespaceSymbol;
if (nestedNamespaceSymbol != null) {
var cciNtd = TranslateMetadata(nestedNamespaceSymbol);
mems.Add(cciNtd);
}
var typeSymbol = m as INamedTypeSymbol;
if (typeSymbol != null) {
var cciType = (INamespaceTypeDefinition)TranslateMetadata(typeSymbol);
mems.Add(cciType);
continue;
}
}
ns.Members = mems;
return ns;
}
示例10: 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);
}
}