Colin
(Colin)
March 28, 2023, 8:01am
3
Hey there.
Stepping away from the coverage issue for a moment, it sounds like you might be facing this issue we reported to Microsoft a few weeks ago.
opened 08:42AM - 07 Mar 23 UTC
Area-Analyzers
untriaged
**Version**: MSBuild version 17.5.0+6f08c67f3 - Roslyn 4.5
In [sonar-dotnet](… https://github.com/SonarSource/sonar-dotnet/tree/master) we have a set of analyzers enabled by default and a set of analyzers that need to be explicitly enabled by a `ruleset` file. Enabling by `ruleset` had been working as expected until the latest release of MSBuild 17.5.
When our analyzers are used with MSBuild17.5 (Roslyn 4.5), all the rules not enabled by default are not executed, although they are enabled by a `.ruleset` file (which should have higher priority than the default values).
During debugging - assuming we have enabled a suppressed analyzer with `DiagnosticId= "S126"` through a ruleset file:
1. When inspecting the `Compilation.Options.SpecificDiagnosticOptions`, the analyzer seemed enabled with value `{[S126, Warn]}`; however, it was not executed.
2. When the value of `IsEnabledByDefault` is manually set to true [when creating the DiagnosticDescriptor object](https://github.com/SonarSource/sonar-dotnet/blob/dffe8ff1aaeffb92431d5fa5e811c07b00da4808/analyzers/src/SonarAnalyzer.Common/DiagnosticAnalyzer/DiagnosticDescriptorFactory.cs#L45), then S126 was normally executed.
3. When the analyzer S126 is enabled through `.editorconfig,` it works as expected.
4. When we downgrade Roslyn to 4.4 - the ruleset enabling works as expected.
The analyzers enabled by default are still properly disabled by the ruleset file.
In summary - Roslyn does not take into account analyzers enabled through a ruleset file.
I'll gladly provide any log or other info to help with the investigation.
For now, we would recommend downgrading to 17.4 until there is some resolution from Microsoft (the beta of 17.6.0 doesn’t demonstrate the issue, so fingers crossed )
@hakanaltindis Can you check if downgrading also fixes the coverage errors? That would help us understand more if it’s an issue with upgrading to 17.5.
3 Likes