Beispiel #1
0
        public static void Analyze(SyntaxNodeAnalysisContext context, MethodDeclarationSyntax methodDeclaration)
        {
            IMethodSymbol methodSymbol = context.SemanticModel.GetDeclaredSymbol(methodDeclaration, context.CancellationToken);

            if (methodSymbol?.IsAsync == true &&
                !methodSymbol.Name.EndsWith(AsyncSuffix, StringComparison.Ordinal) &&
                methodDeclaration.ContainsAwait())
            {
                context.ReportDiagnostic(
                    DiagnosticDescriptors.AsynchronousMethodNameShouldEndWithAsync,
                    methodDeclaration.Identifier.GetLocation());
            }
        }