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.