Roslyn rule excluded by “nowarn” still appearing in Sonar

I am using SonarQube and I have a C# project integrated via Azure DevOps and a git repo. In this particular project, I have a Roslyn analyzer configured. One of the rules, CS1591, I have configured via the dotnet build /nowarn command switch so the rule (XML comments) will be ignored. If you review the output of the build step from dotnet build, the rule is not processed and does not appear as a warning. However, within SonarQube, there are issues created for each instance (and a comment applied to the PR), despite the fact that the build suppressed the warning and it did not appear in the output of the build. Is there a way that I can get this rule suppressed within SonarQube?

Hey there.

I found this GitHub issue while researching the problem.

Do you have some .ruleset configuration turning this rule on? What version of Visual Studio / DotNet are you using?

That’s very odd, as there’s no other way for SonarQube to know about the issue other than the build output.

We had an .editorconfig file entry to lower it from warning to suggestion. Even when I removed and re-analysed it, it still reports these issues in SonarQube. I also tried to delete the branch in SonarQube and re-process it, but the XML issues still appear. The build output from MSBuild doesn’t show any output related to this warning at all.

Bumping. Is there anything I can try, or any logs that I can supply that would help us understand this situation?


Did you try modifying your .editorconfig to set the severity to none?

If you want to keep the issue as info for local development, you can write a small script that will search/replace the value in the config file during your CI build with none.

1 Like

I wanted to close the loop on this. I wasn’t able to do anything within Sonar, but I was able to pass a parameter to MSBuild --property:GenerateDocumentationFile=false that prevented this particular issue from occurring.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.