本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.GetMembersUnordered方法的典型用法代码示例。如果您正苦于以下问题:C# NamedTypeSymbol.GetMembersUnordered方法的具体用法?C# NamedTypeSymbol.GetMembersUnordered怎么用?C# NamedTypeSymbol.GetMembersUnordered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol
的用法示例。
在下文中一共展示了NamedTypeSymbol.GetMembersUnordered方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StructDependsClosure
private static void StructDependsClosure(NamedTypeSymbol type, HashSet<Symbol> partialClosure, NamedTypeSymbol on)
{
Debug.Assert((object)type != null);
if ((object)type.OriginalDefinition == on)
{
// found a possibly expanding cycle, for example
// struct X<T> { public T t; }
// struct W<T> { X<W<W<T>>> x; }
// while not explicitly forbidden by the spec, it should be.
partialClosure.Add(on);
return;
}
if (partialClosure.Add(type))
{
foreach (var member in type.GetMembersUnordered())
{
var field = member as FieldSymbol;
if ((object)field == null || field.Type.TypeKind != TypeKind.Struct || field.IsStatic)
{
continue;
}
StructDependsClosure((NamedTypeSymbol)field.Type, partialClosure, on);
}
}
}
示例2: DependsOnDefinitelyManagedType
private static bool DependsOnDefinitelyManagedType(NamedTypeSymbol type, HashSet<Symbol> partialClosure)
{
Debug.Assert(!ReferenceEquals(type, null));
// NOTE: unlike in StructDependsClosure, we don't have to check for expanding cycles,
// because as soon as we see something with non-zero arity we kick out (generic => managed).
if (partialClosure.Add(type))
{
foreach (var member in type.GetMembersUnordered())
{
// Only instance fields (including field-like events) affect the outcome.
if (member.IsStatic)
{
continue;
}
FieldSymbol field = null;
switch (member.Kind)
{
case SymbolKind.Field:
field = (FieldSymbol)member;
Debug.Assert(ReferenceEquals(field.AssociatedSymbol as EventSymbol, null),
"Didn't expect to find a field-like event backing field in the member list.");
break;
case SymbolKind.Event:
field = ((EventSymbol)member).AssociatedField;
break;
}
if ((object)field == null)
{
continue;
}
// pointers are unmanaged
// NOTE: If we do not check HasPointerType, we will unconditionally
// bind Type and that may cause infinite recursion.
// HasPointerType can use syntax directly and break recursion.
if (field.HasPointerType)
{
continue;
}
TypeSymbol fieldType = field.Type;
NamedTypeSymbol fieldNamedType = fieldType as NamedTypeSymbol;
if ((object)fieldNamedType == null)
{
if (fieldType.IsManagedType)
{
return true;
}
}
else
{
// NOTE: don't use IsManagedType on a NamedTypeSymbol - that could lead
// to infinite recursion.
switch (IsManagedTypeHelper(fieldNamedType))
{
case ThreeState.True:
return true;
case ThreeState.False:
continue;
case ThreeState.Unknown:
if (DependsOnDefinitelyManagedType(fieldNamedType, partialClosure))
{
return true;
}
continue;
}
}
}
}
return false;
}
示例3: VisitNamedType
public override void VisitNamedType(NamedTypeSymbol symbol)
{
_cancellationToken.ThrowIfCancellationRequested();
if (DoNotVisit(symbol)) return;
System.Diagnostics.Debug.Assert(!symbol.IsImplicitClass);
Compliance compliance = GetDeclaredOrInheritedCompliance(symbol);
if (VisitTypeOrMember(symbol, compliance))
{
if (IsTrue(compliance))
{
CheckBaseTypeCompliance(symbol);
CheckTypeParameterCompliance(symbol.TypeParameters, symbol);
if (symbol.TypeKind == TypeKind.Delegate)
{
CheckParameterCompliance(symbol.DelegateInvokeMethod.Parameters, symbol);
}
else if (_compilation.IsAttributeType(symbol) && !HasAcceptableAttributeConstructor(symbol))
{
this.AddDiagnostic(ErrorCode.WRN_CLS_BadAttributeType, symbol.Locations[0], symbol);
}
}
}
// You may assume we could skip the members if this type is inaccessible,
// but dev11 reports that they are inaccessible as well.
if (_compilation.Options.ConcurrentBuild)
{
var options = _cancellationToken.CanBeCanceled
? new ParallelOptions() { CancellationToken = _cancellationToken }
: CSharpCompilation.DefaultParallelOptions; //i.e. new ParallelOptions()
Parallel.ForEach(symbol.GetMembersUnordered(), options, UICultureUtilities.WithCurrentUICulture<Symbol>(Visit));
}
else
{
foreach (var m in symbol.GetMembersUnordered())
{
Visit(m);
}
}
}