protected override void InitializeWorker(ControllerAnalyzerContext analyzerContext)
        {
            analyzerContext.Context.RegisterSyntaxNodeAction(context =>
            {
                var methodSyntax = (MethodDeclarationSyntax)context.Node;
                var method       = context.SemanticModel.GetDeclaredSymbol(methodSyntax, context.CancellationToken);

                if (!analyzerContext.IsControllerAction(method))
                {
                    return;
                }

                if (!method.IsAsync || !method.ReturnsVoid)
                {
                    return;
                }

                var returnType = analyzerContext.SystemThreadingTask.ToMinimalDisplayString(
                    context.SemanticModel,
                    methodSyntax.ReturnType.SpanStart);

                var properties = ImmutableDictionary.Create <string, string>(StringComparer.Ordinal)
                                 .Add(ReturnTypeKey, returnType);

                var location = methodSyntax.ReturnType.GetLocation();
                context.ReportDiagnostic(Diagnostic.Create(
                                             SupportedDiagnostic,
                                             location,
                                             properties: properties));
            }, SyntaxKind.MethodDeclaration);
        }
        public sealed override void Initialize(AnalysisContext context)
        {
            context.RegisterCompilationStartAction(compilationContext =>
            {
                var analyzerContext = new ControllerAnalyzerContext(compilationContext);

                // Only do work if ControllerAttribute is defined.
                if (analyzerContext.ControllerAttribute == null)
                {
                    return;
                }

                InitializeWorker(analyzerContext);
            });
        }
 protected abstract void InitializeWorker(ControllerAnalyzerContext analyzerContext);