当前位置: 首页>>代码示例>>C#>>正文


C# IMethodSymbol.ToDisplayString方法代码示例

本文整理汇总了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)));
 }
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:13,代码来源:SpecifyStringComparison.cs

示例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);
            }
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:51,代码来源:DescriptionBuilder.cs

示例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;
        }
开发者ID:tugberkugurlu,项目名称:omnisharp-roslyn,代码行数:26,代码来源:OmnisharpController.SignatureHelp.cs

示例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());
		}
开发者ID:cubeme,项目名称:safety-sharp,代码行数:9,代码来源:MethodBodyNormalizer.cs

示例5: GetMethodName

 private static string GetMethodName(IMethodSymbol methodSymbol)
 {
     var format = (methodSymbol.MethodKind == MethodKind.UserDefinedOperator) ?
         _testDataOperatorKeyFormat :
         _testDataKeyFormat;
     return methodSymbol.ToDisplayString(format);
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:CompilationTestData.cs

示例6: GetTooltipForMethod

 private string GetTooltipForMethod(IMethodSymbol methodSymbol)
     => methodSymbol.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat
         .AddGenericsOptions(SymbolDisplayGenericsOptions.IncludeTypeParameters)
         .AddParameterOptions(SymbolDisplayParameterOptions.IncludeName)
         .AddMemberOptions(SymbolDisplayMemberOptions.IncludeType));
开发者ID:lukas-lansky,项目名称:CSharpFormatting,代码行数:5,代码来源:ReportingCSharpSyntaxWalker.cs


注:本文中的IMethodSymbol.ToDisplayString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。