本文整理汇总了C#中INamedTypeSymbol.GetTypeArgumentCustomModifiers方法的典型用法代码示例。如果您正苦于以下问题:C# INamedTypeSymbol.GetTypeArgumentCustomModifiers方法的具体用法?C# INamedTypeSymbol.GetTypeArgumentCustomModifiers怎么用?C# INamedTypeSymbol.GetTypeArgumentCustomModifiers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INamedTypeSymbol
的用法示例。
在下文中一共展示了INamedTypeSymbol.GetTypeArgumentCustomModifiers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTypeArguments
//returns true if there are constraints
private void AddTypeArguments(ImmutableArray<ITypeSymbol> typeArguments, INamedTypeSymbol modifiersSourceOpt = null)
{
if (typeArguments.Length > 0 && format.GenericsOptions.IncludesOption(SymbolDisplayGenericsOptions.IncludeTypeParameters))
{
AddPunctuation(SyntaxKind.LessThanToken);
var first = true;
for (int i = 0; i < typeArguments.Length; i++)
{
var typeArg = typeArguments[i];
if (!first)
{
AddPunctuation(SyntaxKind.CommaToken);
AddSpace();
}
first = false;
if (typeArg.Kind == SymbolKind.TypeParameter)
{
var typeParam = (ITypeParameterSymbol)typeArg;
AddTypeParameterVarianceIfRequired(typeParam);
typeParam.Accept(this.NotFirstVisitor);
}
else
{
typeArg.Accept(this.NotFirstVisitor);
}
if (modifiersSourceOpt != null)
{
AddCustomModifiersIfRequired(modifiersSourceOpt.GetTypeArgumentCustomModifiers(i), leadingSpace: true, trailingSpace: false);
}
}
AddPunctuation(SyntaxKind.GreaterThanToken);
}
}
示例2: VisitNamedType
public override void VisitNamedType(INamedTypeSymbol symbol)
{
if (this.IsMinimizing && TryAddAlias(symbol, builder))
{
return;
}
if (format.MiscellaneousOptions.IncludesOption(SymbolDisplayMiscellaneousOptions.UseSpecialTypes))
{
if (AddSpecialTypeKeyword(symbol))
{
//if we're using special type keywords and this is a special type, then no other work is required
return;
}
}
if (!format.MiscellaneousOptions.IncludesOption(SymbolDisplayMiscellaneousOptions.ExpandNullable))
{
//if we're expanding nullable, we just visit nullable types normally
if (IsNullableType(symbol) && !symbol.IsDefinition)
{
// Can't have a type called "int*?".
var typeArg = symbol.TypeArguments[0];
if (typeArg.TypeKind != TypeKind.Pointer)
{
symbol.TypeArguments[0].Accept(this.NotFirstVisitor);
AddCustomModifiersIfRequired(symbol.GetTypeArgumentCustomModifiers(0), leadingSpace: true, trailingSpace: false);
AddPunctuation(SyntaxKind.QuestionToken);
//visiting the underlying type did all of the work for us
return;
}
}
}
if (this.IsMinimizing || symbol.IsTupleType)
{
MinimallyQualify(symbol);
return;
}
AddTypeKind(symbol);
if (CanShowDelegateSignature(symbol))
{
if (format.DelegateStyle == SymbolDisplayDelegateStyle.NameAndSignature)
{
var invokeMethod = symbol.DelegateInvokeMethod;
if (invokeMethod.ReturnsByRef)
{
AddRefIfRequired();
}
if (invokeMethod.ReturnsVoid)
{
AddKeyword(SyntaxKind.VoidKeyword);
}
else
{
symbol.DelegateInvokeMethod.ReturnType.Accept(this.NotFirstVisitor);
}
AddSpace();
}
}
//only visit the namespace if the style requires it and there isn't an enclosing type
var containingSymbol = symbol.ContainingSymbol;
if (ShouldVisitNamespace(containingSymbol))
{
var namespaceSymbol = (INamespaceSymbol)containingSymbol;
var shouldSkip = namespaceSymbol.IsGlobalNamespace && symbol.TypeKind == TypeKind.Error;
if (!shouldSkip)
{
namespaceSymbol.Accept(this.NotFirstVisitor);
AddPunctuation(namespaceSymbol.IsGlobalNamespace ? SyntaxKind.ColonColonToken : SyntaxKind.DotToken);
}
}
//visit the enclosing type if the style requires it
if (format.TypeQualificationStyle == SymbolDisplayTypeQualificationStyle.NameAndContainingTypes ||
format.TypeQualificationStyle == SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces)
{
if (IncludeNamedType(symbol.ContainingType))
{
symbol.ContainingType.Accept(this.NotFirstVisitor);
AddPunctuation(SyntaxKind.DotToken);
}
}
AddNameAndTypeArgumentsOrParameters(symbol);
}