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


C# IMethodSymbol.ToString方法代码示例

本文整理汇总了C#中IMethodSymbol.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodSymbol.ToString方法的具体用法?C# IMethodSymbol.ToString怎么用?C# IMethodSymbol.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMethodSymbol的用法示例。


在下文中一共展示了IMethodSymbol.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsAsyncLibraryConstruct

        public void IsAsyncLibraryConstruct(IMethodSymbol symbol)
        {
            if (symbol.ContainingNamespace.ToString().Equals("System.Threading.Tasks") ||
                symbol.ContainingNamespace.ToString().Equals("System.Threading") ||
                (symbol.ContainingNamespace.ToString().Equals("System.Linq") && (symbol.ContainingType.ToString().Contains("ParallelQuery") || symbol.ContainingType.ToString().Contains("ParallelEnumerable"))) ||
                symbol.ContainingNamespace.ToString().Equals("System.Collections.Concurrent"))
            {

                if (ConsultingAnalysisResult.libraryUsage.ContainsKey(symbol.ToString()))
                    ConsultingAnalysisResult.libraryUsage[symbol.ToString()]++;
                else
                    ConsultingAnalysisResult.libraryUsage[symbol.ToString()] = 1;
            }
        }
开发者ID:modulexcite,项目名称:concurrent-code-analyses,代码行数:14,代码来源:AsyncLibraryDetectionWalker.cs

示例2: IsSelectingADifferentMethod

 private static bool IsSelectingADifferentMethod(IEnumerable<SyntaxNode> childNodes, SimpleNameSyntax methodName, SyntaxTree tree, IMethodSymbol methodSymbol, ExpressionSyntax invocationExpression, Compilation compilation)
 {
     var parameterExpressions = GetParameterExpressions(childNodes);
     var firstArgument = parameterExpressions.FirstOrDefault();
     var argumentList = CreateArgumentListSyntaxFrom(parameterExpressions.Skip(1));
     var newInvocationStatement = CreateInvocationExpression(firstArgument, methodName, argumentList)
         .WithAdditionalAnnotations(introduceExtensionMethodAnnotation);
     var extensionMethodNamespaceUsingDirective = SyntaxFactory.UsingDirective(methodSymbol.ContainingNamespace.ToNameSyntax());
     var speculativeRootWithExtensionMethod = tree.GetCompilationUnitRoot()
         .ReplaceNode(invocationExpression, newInvocationStatement)
         .AddUsings(extensionMethodNamespaceUsingDirective);
     var speculativeTree = speculativeRootWithExtensionMethod.SyntaxTree;
     var speculativeTreeOptions = (CSharpParseOptions)speculativeTree.Options;
     var speculativeTreeWithCorrectLanguageVersion = speculativeTree.WithRootAndOptions(speculativeRootWithExtensionMethod, speculativeTreeOptions.WithLanguageVersion(((CSharpParseOptions)tree.Options).LanguageVersion));
     var speculativeModel = compilation.ReplaceSyntaxTree(tree, speculativeTreeWithCorrectLanguageVersion)
         .GetSemanticModel(speculativeTreeWithCorrectLanguageVersion);
     var speculativeInvocationStatement = speculativeTreeWithCorrectLanguageVersion.GetCompilationUnitRoot().GetAnnotatedNodes(introduceExtensionMethodAnnotation).Single() as InvocationExpressionSyntax;
     var speculativeExtensionMethodSymbol = speculativeModel.GetSymbolInfo(speculativeInvocationStatement.Expression).Symbol as IMethodSymbol;
     var speculativeNonExtensionFormOfTheMethodSymbol = speculativeExtensionMethodSymbol?.GetConstructedReducedFrom();
     return speculativeNonExtensionFormOfTheMethodSymbol == null || speculativeNonExtensionFormOfTheMethodSymbol.ToString() != methodSymbol.ToString();//can't compare equality, as speculative symbol might be different
 }
开发者ID:julianosaless,项目名称:code-cracker,代码行数:21,代码来源:CallExtensionMethodAsExtensionAnalyzer.cs

示例3: IsAsyncLibraryConstruct

        public void IsAsyncLibraryConstruct(IMethodSymbol symbol)
        {
            if (symbol.ContainingNamespace.ToString().Equals("System.Threading.Tasks") ||
                symbol.ContainingNamespace.ToString().Equals("System.Threading") ||
                (symbol.ContainingNamespace.ToString().Equals("System.Linq") && (symbol.ContainingType.ToString().Contains("ParallelQuery") || symbol.ContainingType.ToString().Contains("ParallelEnumerable"))) ||
                symbol.ContainingNamespace.ToString().Equals("System.Collections.Concurrent"))
            {
                var libraryUsage = Result.LibraryUsage;

                int temp;
                string key = symbol.ToString();
                
                libraryUsage.TryGetValue(key, out temp);
                libraryUsage[key] = ++temp;
            }
        }
开发者ID:modulexcite,项目名称:CSharpAnalyzer,代码行数:16,代码来源:ConcurrencyUsageWalker.cs

示例4: Task

 public Task(IMethodSymbol symbol, bool step)
 {
     CheckSignature(symbol);
     signature = symbol.ToString();
     this.step = step;
 }
开发者ID:jthelin,项目名称:Nake,代码行数:6,代码来源:Task.cs

示例5: CheckSignature

        static void CheckSignature(IMethodSymbol symbol)
        {
            bool hasDuplicateParameters = symbol.Parameters
                .GroupBy(p => p.Name, StringComparer.OrdinalIgnoreCase)
                .Any(p => p.Count() > 1);

            if (!symbol.ReturnsVoid ||
                symbol.IsGenericMethod ||
                symbol.Parameters.Any(p => p.RefKind != RefKind.None || !TypeConverter.IsSupported(p.Type)) ||
                hasDuplicateParameters)
                throw new TaskSignatureViolationException(symbol.ToString());
        }
开发者ID:jthelin,项目名称:Nake,代码行数:12,代码来源:Task.cs

示例6: DetectBlockingOperations

        private void DetectBlockingOperations(InvocationExpressionSyntax methodCall, IMethodSymbol methodCallSymbol)
        {

            var methodDeclaration = methodCall.FirstAncestorOrSelf<MethodDeclarationSyntax>();
            var replacement = ((IMethodSymbol)methodCallSymbol.OriginalDefinition).DetectSynchronousUsages(SemanticModel);

            if (methodDeclaration != null)
            {
                if (replacement != "None")
                {
                    Logs.TempLog6.Info(@"{0}{1}{2}{3}**********************************************",
                                        Document.FilePath,
                                        System.Environment.NewLine + System.Environment.NewLine + "BLOCKING METHODCALL: " + methodCallSymbol.ToString(),
                                        System.Environment.NewLine + System.Environment.NewLine + "REPLACE IT WITH: " + replacement,
                                        methodDeclaration.ToLog());
                }
            }
        }
开发者ID:modulexcite,项目名称:concurrent-code-analyses,代码行数:18,代码来源:AsyncAwaitDetectionWalker.cs

示例7: Add

            public void Add(IMethodSymbol ms)
            {
                if (IsLibrary)
                    return;
                FlatArrayBuilder fab = new FlatArrayBuilder();
                fab.Add(FlatValue.Int32(ms.IsStatic ? (int)ClassMemberType.StaticMethod : (int)ClassMemberType.Method));
                fab.Add(FlatValue.String(ms.GetFullyQualifiedName()));

                Function f;
                if (!Chunk.Functions.TryGetValue(ms, out f))
                {
                    throw new LS2ILMethodException("Method not found " + ms.ToString());
                }

                fab.Add(FlatValue.Int32(f.NumFunction));

                // input declarations
                fab.Add(GenerateInputDeclarations(ms).GetFlatValue());

                Members.Add(fab.GetFlatValue());
            }
开发者ID:LaxLacks,项目名称:ls2csc,代码行数:21,代码来源:TypeExtraInfo.cs


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