S3776 not shown in Visual Studio 2022 Preview (17.5) but in VS 2022 (17.4)

If I analyze one VS solution with VS 2022 (17.4.1) and 2022 Preview (17.5) I get less code warnings in the Preview version. The exact same solution, opened from the exact same place on my disk.

In VS 2022 Preview I am not seeing the warning S3776.

I cannot find any suppression information, neither in the solution directory nor in my %appdata% directory.

The Solution is connected to our SonarCloud organisation and I see the projects ruleset file linked to all C# projects in the solution explorer of VS.

Any idea what could cause the missing issues?

Hmm, I opened the ruleset file, unchecked S3776, checked S3776 again and rerun the Solution Analyzer - now S3776 is showing in VS 2022 Preview. I didn’t even save the ruleset and VS 2022 and 2022 Preview use the same ruleset file provided from SonarCloud. Very strange. Maybe I should do that for all checkboxes…

@SvenC what do you mean by “rerun the Solution Analyzer”?

For SonarC#/Visual Basic rules, the only role SonarLint plays is in generating a ruleset from the Quality Profile on the server.

The actual execution of the rules is handled entirely by Visual Studio, which has a few options that can vary between VS instances. See the MS docs for more information.

Based on observation, there seem to be a few quirks in how the Roslyn rules are executed by Visual Studio: it appears that some rules are only executed when Run background code analysis for: is set to Entire solution (an high-level explanation is that some rules require a compilation-level analysis, which only happens when Entire solution is selected. Unfortunately, as an end-user you can’t tell which rules this affects).

Hi Duncan, I used the Analyze menu of Visual Studio, from there “Run code analysis” and “On Solution”. That triggers SonarLint with the ruleset from our SonarCloud org.

I agree that this looks like quirky behavior in VS - just in the preview version of 2022, not the release version of 2022.

Like said in the reply to myself above: just unchecking and checking the rule S3776 made it reappear in the next analyzer run.

I used the VS UI which opens, when you double click a ruleset file. You get a list of all rules with checkboxes to activate/deactivate the available rules. S3776 was activated and working when analyzed by VS 2022 release, not working with VS 2022 preview. Uncheck/check and VS 2022 preview is working as well.

Hope that clarified what I did.

I think there is nothing to do on the Sonar side.

1 Like