Rule registration: "SonarTreeReportingContextBase.ReportIssue" assumes ShouldAnalyzeTree was called before #8876
Labels
Area: C#
C# rules related issues.
Area: VB.NET
VB.NET rules related issues.
Type: Improvement
Making existing code better.
There are two implementations of "ReportIssue":
SonarTreeReportingContextBase
sonar-dotnet/analyzers/src/SonarAnalyzer.Common/AnalysisContext/SonarReportingContextBase.cs
Lines 93 to 94 in 55c6cbe
SonarCompilationReportingContextBase
sonar-dotnet/analyzers/src/SonarAnalyzer.Common/AnalysisContext/SonarReportingContextBase.cs
Lines 104 to 110 in 55c6cbe
These classes are derived from SonarTreeReportingContextBase
If the reporting happens through one of these contexts,
ShouldAnalyzeTree
is not checked. The reasoning is, that the check was done via "Execute" like in SonarAnalysisContext:sonar-dotnet/analyzers/src/SonarAnalyzer.Common/AnalysisContext/SonarAnalysisContext.cs
Lines 117 to 119 in 55c6cbe
sonar-dotnet/analyzers/src/SonarAnalyzer.Common/AnalysisContext/SonarAnalysisContext.cs
Lines 143 to 157 in 55c6cbe
But in the other "Start" contexts this check is missing:
sonar-dotnet/analyzers/src/SonarAnalyzer.Common/AnalysisContext/SonarCodeBlockStartAnalysisContext.cs
Lines 34 to 35 in 55c6cbe
sonar-dotnet/analyzers/src/SonarAnalyzer.Common/AnalysisContext/SonarCompilationStartAnalysisContext.cs
Lines 33 to 40 in 55c6cbe
.. and the new SymbolStartAnalysisContext of #8799
sonar-dotnet/analyzers/src/SonarAnalyzer.Common/AnalysisContext/SonarSymbolStartAnalysisContext.cs
Lines 34 to 53 in 9b7cab0
as a result, we raise in generated code in these registrations.
See also:
The text was updated successfully, but these errors were encountered: