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


C# MethodDeclarationSyntax.HasEventArgsParameter方法代码示例

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


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

示例1: VisitMethodDeclaration

        public override void VisitMethodDeclaration(MethodDeclarationSyntax node)
        {
            if (node.HasEventArgsParameter())
                Result.generalAsyncResults.NumEventHandlerMethods++;

            base.VisitMethodDeclaration(node);
        }
开发者ID:modulexcite,项目名称:CSharpAnalyzer,代码行数:7,代码来源:GeneralAsyncDetectionWalker.cs

示例2: VisitMethodDeclaration

        public override void VisitMethodDeclaration(MethodDeclarationSyntax node)
        {
            if (node.HasEventArgsParameter())
            {
                var arg= node.ParameterList.Parameters.Where(param => param.Type.ToString().EndsWith("EventArgs")).First();

                var type = SemanticModel.GetTypeInfo(arg.Type).Type;
                
                if (type.ToString().StartsWith("System.Windows"))
                {
                    int result = ProcessMethodCallsInMethod(node,0);
                    Logs.TempLog2.Info("{0}\r\n{1}\r\n--------------", result, node);

                }
            }

            base.VisitMethodDeclaration(node);
        }
开发者ID:modulexcite,项目名称:CSharpAnalyzer,代码行数:18,代码来源:DispatcherDetectionWalker.cs

示例3: IsFireForget

		private static bool IsFireForget(MethodDeclarationSyntax node)
		{
			return node.ReturnType.ToString().Equals("void") && !node.HasEventArgsParameter();
		}
开发者ID:modulexcite,项目名称:CSharpAnalyzer,代码行数:4,代码来源:AsyncAwaitAntiPatternsWalker.cs

示例4: VisitMethodDeclaration

        public override void VisitMethodDeclaration(MethodDeclarationSyntax node)
        {

            //if (node.HasAsyncModifier() && !node.ToString().Contains("await"))
            //{
            //    Logs.TempLog5.Info("NotHavingAwait {0}\r\n{1}\r\n------------------------------", Document.FilePath, node);
            //}
            if (node.HasAsyncModifier() && node.ToString().Contains("await"))
            {
                if (Result.CurrentAnalyzedProjectType == Enums.ProjectType.WP7)
                    Result.asyncAwaitResults.NumAsyncAwaitMethods_WP7++;
                else
                    Result.asyncAwaitResults.NumAsyncAwaitMethods_WP8++;

                if (node.ReturnType.ToString().Equals("void"))
                {
                    if (node.HasEventArgsParameter())
                        Result.asyncAwaitResults.NumAsyncVoidEventHandlerMethods++;
                    else
                        Result.asyncAwaitResults.NumAsyncVoidNonEventHandlerMethods++;
                }
                else
                    Result.asyncAwaitResults.NumAsyncTaskMethods++;




                if (IsFireForget(node))
                    Result.WriteDetectedMisuseAsyncUsageToTable(1, Document, node);

                if (IsUnnecessaryAsyncAwait(node))
                    Result.WriteDetectedMisuseAsyncUsageToTable(2, Document, node);

                if(IsThereLongRunning(node))
                    Result.WriteDetectedMisuseAsyncUsageToTable(3, Document, node);

                if (IsUnnecessarilyCaptureContext(node, 0))
                    Result.WriteDetectedMisuseAsyncUsageToTable(4,Document,node);

                    //Logs.TempLog.Info("ConfigureAwaitUse {0}\r\n{1}\r\n------------------------------",Document.FilePath,node);

                //var endTime = DateTime.UtcNow;
                //Logs.TempLog5.Info(endTime.Subtract(startTime).Milliseconds);




                //if (node.Body.ToString().Contains("ConfigureAwait"))
                //{

                //    Result.asyncAwaitResults.NumAsyncMethodsHavingConfigureAwait++;
                //    Logs.TempLog5.Info("ConfigureAwait {0}\r\n{1}\r\n------------------------------", Document.FilePath, node);
                //}



                //foreach (var loop in node.DescendantNodes().Where(a => a is ForEachStatementSyntax || a is ForStatementSyntax || a is WhileStatementSyntax))
                //{
                //    foreach (var tap in loop.DescendantNodes().OfType<InvocationExpressionSyntax>())
                //    {
                //        MethodSymbol sym = (MethodSymbol)SemanticModel.GetSymbolInfo(tap).Symbol;
                //        if (sym != null && sym.IsTAPMethod())
                //            Logs.TempLog2.Info("ExpensiveAwaits {0} {1}\r\n{2}\r\n-----------------------", sym, Document.FilePath, node);
                //    }
                //}

                //var symbol = SemanticModel.GetDeclaredSymbol(node);
                //bool isThereAnyCaller = false;
                //if (symbol != null)
                //{
                //    foreach (var refs in SymbolFinder.FindReferencesAsync(symbol, Document.Project.Solution).Result)
                //    {
                //        foreach (var locs in refs.Locations)
                //        {
                //            isThereAnyCaller = true;
                //            var caller = locs.Document.GetTextAsync().Result.Lines.ElementAt(locs.Location.GetLineSpan(false).StartLinePosition.Line).ToString();
                //            if (caller.Contains(".Result") || caller.Contains(".Wait"))
                //                Logs.TempLog5.Info("BlockingCaller {0}\r\n{1}\r\n{2}\r\n-----------------------", Document.FilePath, node, caller);

                //        }
                //    }
                //}
            }

            //if (node.HasEventArgsParameter())
            //{
            //    var arg = node.ParameterList.Parameters.Where(param => param.Type.ToString().EndsWith("EventArgs")).First();

            //    var type = SemanticModel.GetTypeInfo(arg.Type).Type;

            //    if (type.ToString().StartsWith("System.Windows"))
            //    {
            //        ProcessMethodCallsInMethod(node, 0, node.Identifier.ToString() + node.ParameterList.ToString());
            //    }
            //}
            base.VisitMethodDeclaration(node);
        }
开发者ID:modulexcite,项目名称:CSharpAnalyzer,代码行数:97,代码来源:AsyncAwaitDetectionWalker.cs


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