예제 #1
0
        protected AnalyzerCanContinueMethodResult GetContinuationResult(SyntaxNodeAnalysisContext context)
        {
            var result = AnalyzerCanContinueMethodResult.Default();

            if (!(context.Node is InvocationExpressionSyntax invocationExpressionSyntax))
            {
                return(result);
            }

            if (!(context.SemanticModel.GetSymbolInfo(invocationExpressionSyntax).Symbol is IMethodSymbol methodSymbol))
            {
                return(result);
            }

            if (!methodSymbol.IsDeclareInMetadata())
            {
                return(result);
            }

            if (IsMethodKindValid(methodSymbol.MethodKind))
            {
                return(result);
            }

            if (!(methodSymbol?.ReturnType is INamedTypeSymbol returnTypeSymbol))
            {
                return(result);
            }

            return(new AnalyzerCanContinueMethodResult(methodSymbol, returnTypeSymbol, true));
        }
        protected AnalyzerCanContinueMethodResult GetContinuationResult(SymbolAnalysisContext context)
        {
            var result = AnalyzerCanContinueMethodResult.Default();

            IMethodSymbol methodSymbol = (IMethodSymbol)context.Symbol;

            if (methodSymbol == null)
            {
                return(result);
            }

            if (!methodSymbol.IsDeclareInMetadata())
            {
                return(result);
            }

            if (!IsMethodKindValid(methodSymbol.MethodKind))
            {
                return(result);
            }

            if (!(methodSymbol?.ReturnType is INamedTypeSymbol returnTypeSymbol))
            {
                return(result);
            }

            return(new AnalyzerCanContinueMethodResult(methodSymbol, returnTypeSymbol, true));
        }