コード例 #1
0
        private void AnalyzeMethodBody(OperationAnalysisContext context)
        {
            var method     = (IMethodSymbol)context.ContainingSymbol;
            var methodBody = (IMethodBodyOperation)context.Operation;

            MethodBodyAnalyzer.Run(context.ReportDiagnostic, context.Compilation, _asyncUtilities, method, methodBody.BlockBody ?? methodBody.ExpressionBody);
        }
コード例 #2
0
        private void AnalyzeAnonymousFunction(OperationAnalysisContext context)
        {
            var operation = (IAnonymousFunctionOperation)context.Operation;
            var method    = operation.Symbol;

            if (method.ContainingSymbol.Kind != SymbolKind.Method)
            {
                MethodBodyAnalyzer.Run(context.ReportDiagnostic, context.Compilation, _asyncUtilities, method, operation.Body);
            }
        }
コード例 #3
0
        private void AnalyzeArrowExpressionClause(SyntaxNodeAnalysisContext context)
        {
            if (!(context.ContainingSymbol is IMethodSymbol method) || method.MethodKind != MethodKind.PropertyGet)
            {
                return;
            }

            var operation = context.SemanticModel.GetOperation(context.Node, context.CancellationToken);

            if (operation is IBlockOperation block && block.Parent == null)
            {
                MethodBodyAnalyzer.Run(context.ReportDiagnostic, context.Compilation, _asyncUtilities, method, block);
            }
        }