本文整理汇总了C#中IMethodSymbol.ToDisplayString方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodSymbol.ToDisplayString方法的具体用法?C# IMethodSymbol.ToDisplayString怎么用?C# IMethodSymbol.ToDisplayString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethodSymbol
的用法示例。
在下文中一共展示了IMethodSymbol.ToDisplayString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReportDiagnostic
private static void ReportDiagnostic(
OperationAnalysisContext oaContext,
IInvocationExpression invocationExpression,
IMethodSymbol targetMethod,
IMethodSymbol correctOverload)
{
oaContext.ReportDiagnostic(
invocationExpression.Syntax.CreateDiagnostic(
Rule,
targetMethod.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat),
oaContext.ContainingSymbol.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat),
correctOverload.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat)));
}
示例2: BuildMethodDeclaration
protected override void BuildMethodDeclaration(IMethodSymbol methodSymbol, _VSOBJDESCOPTIONS options)
{
BuildMemberModifiers(methodSymbol);
if (methodSymbol.MethodKind != MethodKind.Constructor &&
methodSymbol.MethodKind != MethodKind.Destructor &&
methodSymbol.MethodKind != MethodKind.StaticConstructor &&
methodSymbol.MethodKind != MethodKind.Conversion)
{
AddTypeLink(methodSymbol.ReturnType, LinkFlags.None);
AddText(" ");
}
if (methodSymbol.MethodKind == MethodKind.Conversion)
{
switch (methodSymbol.Name)
{
case WellKnownMemberNames.ImplicitConversionName:
AddName("implicit operator ");
break;
case WellKnownMemberNames.ExplicitConversionName:
AddName("explicit operator ");
break;
}
AddTypeLink(methodSymbol.ReturnType, LinkFlags.None);
}
else
{
var methodNameFormat = new SymbolDisplayFormat(
genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters | SymbolDisplayGenericsOptions.IncludeVariance);
AddName(methodSymbol.ToDisplayString(methodNameFormat));
}
AddText("(");
if (methodSymbol.IsExtensionMethod)
{
AddText("this ");
}
BuildParameterList(methodSymbol.Parameters);
AddText(")");
if (methodSymbol.IsGenericMethod)
{
BuildGenericConstraints(methodSymbol);
}
}
示例3: BuildSignature
private SignatureHelpItem BuildSignature(IMethodSymbol symbol)
{
var signature = new SignatureHelpItem();
signature.Documentation = symbol.GetDocumentationCommentXml();
if (symbol.MethodKind == MethodKind.Constructor)
{
signature.Name = symbol.ContainingType.Name;
signature.Label = symbol.ContainingType.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
}
else
{
signature.Name = symbol.Name;
signature.Label = symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
}
signature.Parameters = GetParameters(symbol).Select(parameter =>
{
return new SignatureHelpParameter()
{
Name = parameter.Name,
Label = parameter.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat),
Documentation = parameter.GetDocumentationCommentXml()
};
});
return signature;
}
示例4: GetMethodKey
/// <summary>
/// Gets the key the <paramref name="methodSymbol" /> is stored under in the <seealso cref="_implementationMethods" />
/// dictionary.
/// </summary>
/// <param name="methodSymbol">The method the key should be returned for.</param>
private static string GetMethodKey(IMethodSymbol methodSymbol)
{
return String.Format("{0} {1}", methodSymbol.ContainingType.ToDisplayString(), methodSymbol.ToDisplayString());
}
示例5: GetMethodName
private static string GetMethodName(IMethodSymbol methodSymbol)
{
var format = (methodSymbol.MethodKind == MethodKind.UserDefinedOperator) ?
_testDataOperatorKeyFormat :
_testDataKeyFormat;
return methodSymbol.ToDisplayString(format);
}
示例6: GetTooltipForMethod
private string GetTooltipForMethod(IMethodSymbol methodSymbol)
=> methodSymbol.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat
.AddGenericsOptions(SymbolDisplayGenericsOptions.IncludeTypeParameters)
.AddParameterOptions(SymbolDisplayParameterOptions.IncludeName)
.AddMemberOptions(SymbolDisplayMemberOptions.IncludeType));