本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.GetInstanceFieldsAndEvents方法的典型用法代码示例。如果您正苦于以下问题:C# NamedTypeSymbol.GetInstanceFieldsAndEvents方法的具体用法?C# NamedTypeSymbol.GetInstanceFieldsAndEvents怎么用?C# NamedTypeSymbol.GetInstanceFieldsAndEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol
的用法示例。
在下文中一共展示了NamedTypeSymbol.GetInstanceFieldsAndEvents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DependsOnDefinitelyManagedType
private static bool DependsOnDefinitelyManagedType(NamedTypeSymbol type, HashSet<Symbol> partialClosure)
{
Debug.Assert((object)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.GetInstanceFieldsAndEvents())
{
// Only instance fields (including field-like events) affect the outcome.
FieldSymbol field;
switch (member.Kind)
{
case SymbolKind.Field:
field = (FieldSymbol)member;
Debug.Assert((object)(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;
default:
throw ExceptionUtilities.UnexpectedValue(member.Kind);
}
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;
}