6using System.Collections.Immutable;
10 [DiagnosticAnalyzer(LanguageNames.CSharp)]
14 private static readonly DiagnosticDescriptor incorrectParameterRule =
15 new DiagnosticDescriptor(
16 Constants.AnalyzerIdentifiers.RefOrOutParameterInOperation,
17 FindRefAndOutParametersInOperationsAnalyzerConstants.Title,
18 FindRefAndOutParametersInOperationsAnalyzerConstants.Message,
19 Constants.Categories.Usage, DiagnosticSeverity.Error,
true,
20 helpLinkUri: HelpUrlBuilder.Build(
24 ImmutableArray.Create(incorrectParameterRule);
28 context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
29 context.EnableConcurrentExecution();
30 context.RegisterSyntaxNodeAction(AnalyzeMethodDeclaration, SyntaxKind.MethodDeclaration);
33 private static void AnalyzeMethodDeclaration(SyntaxNodeAnalysisContext context)
35 var methodNode = (MethodDeclarationSyntax)context.Node;
37 if (!methodNode.ContainsDiagnostics)
39 var methodSymbol = context.SemanticModel.GetDeclaredSymbol(methodNode);
40 var typeSymbol = methodSymbol.ContainingType;
42 if (typeSymbol.IsBusinessBase() && methodSymbol.IsDataPortalOperation())
44 foreach(var parameterSymbol
in methodSymbol.Parameters)
46 if(parameterSymbol.RefKind == RefKind.Out ||
47 parameterSymbol.RefKind == RefKind.Ref)
49 context.ReportDiagnostic(Diagnostic.Create(
50 incorrectParameterRule, parameterSymbol.Locations[0]));
override ImmutableArray< DiagnosticDescriptor > SupportedDiagnostics
override void Initialize(AnalysisContext context)