6using System.Collections.Immutable;
11 [DiagnosticAnalyzer(LanguageNames.CSharp)]
15 private static readonly DiagnosticDescriptor childHasRunLocalRule =
16 new DiagnosticDescriptor(
17 Constants.AnalyzerIdentifiers.DoesChildOperationHaveRunLocal, DoesChildOperationHaveRunLocalAnalyzerConstants.Title,
18 DoesChildOperationHaveRunLocalAnalyzerConstants.Message, Constants.Categories.Usage,
19 DiagnosticSeverity.Warning,
true,
20 helpLinkUri: HelpUrlBuilder.Build(
23 public override ImmutableArray<DiagnosticDescriptor>
SupportedDiagnostics => ImmutableArray.Create(childHasRunLocalRule);
27 context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
28 context.EnableConcurrentExecution();
29 context.RegisterSyntaxNodeAction(AnalyzeMethodDeclaration, SyntaxKind.MethodDeclaration);
32 private static void AnalyzeMethodDeclaration(SyntaxNodeAnalysisContext context)
34 var methodNode = (MethodDeclarationSyntax)context.Node;
36 var methodSymbol = context.SemanticModel.GetDeclaredSymbol(methodNode);
37 var typeSymbol = methodSymbol.ContainingType;
39 if (typeSymbol.IsStereotype() && methodSymbol.IsChildDataPortalOperation() &&
40 methodSymbol.GetAttributes().Any(_ => _.AttributeClass.IsRunLocalAttribute()))
42 context.ReportDiagnostic(Diagnostic.Create(
43 childHasRunLocalRule, methodSymbol.Locations[0]));
override ImmutableArray< DiagnosticDescriptor > SupportedDiagnostics
override void Initialize(AnalysisContext context)