本文整理汇总了C#中AbstractSyntaxContext.GetOuterTypes方法的典型用法代码示例。如果您正苦于以下问题:C# AbstractSyntaxContext.GetOuterTypes方法的具体用法?C# AbstractSyntaxContext.GetOuterTypes怎么用?C# AbstractSyntaxContext.GetOuterTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractSyntaxContext
的用法示例。
在下文中一共展示了AbstractSyntaxContext.GetOuterTypes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldIncludeSymbol
private bool ShouldIncludeSymbol(ISymbol symbol, AbstractSyntaxContext context, CancellationToken cancellationToken)
{
var isMember = false;
switch (symbol.Kind)
{
case SymbolKind.NamedType:
var namedType = (INamedTypeSymbol)symbol;
if (namedType.SpecialType == SpecialType.System_Void)
{
return false;
}
break;
case SymbolKind.Method:
var methodSymbol = (IMethodSymbol)symbol;
if (methodSymbol.MethodKind == MethodKind.EventAdd ||
methodSymbol.MethodKind == MethodKind.EventRemove ||
methodSymbol.MethodKind == MethodKind.EventRaise ||
methodSymbol.MethodKind == MethodKind.PropertyGet ||
methodSymbol.MethodKind == MethodKind.PropertySet)
{
return false;
}
isMember = true;
break;
case SymbolKind.Event:
case SymbolKind.Field:
case SymbolKind.Property:
isMember = true;
break;
case SymbolKind.TypeParameter:
return ((ITypeParameterSymbol)symbol).TypeParameterKind != TypeParameterKind.Cref;
}
if (context.IsAttributeNameContext)
{
var enclosingSymbol = context.SemanticModel.GetEnclosingNamedType(context.LeftToken.SpanStart, cancellationToken);
return symbol.IsOrContainsAccessibleAttribute(enclosingSymbol, context.SemanticModel.Compilation.Assembly);
}
if (context.IsEnumTypeMemberAccessContext)
{
return symbol.Kind == SymbolKind.Field;
}
// In an expression or statement context, we don't want to display instance members declared in outer containing types.
if ((context.IsStatementContext || context.IsAnyExpressionContext) &&
!symbol.IsStatic &&
isMember &&
context.GetOuterTypes(cancellationToken).Contains(symbol.ContainingType))
{
return false;
}
var namespaceSymbol = symbol as INamespaceSymbol;
if (namespaceSymbol != null)
{
return namespaceSymbol.ContainsAccessibleTypesOrNamespaces(context.SemanticModel.Compilation.Assembly);
}
return true;
}