本文整理匯總了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;
}