2

In recent years I used ruleset files for code analysis, configured via a project's Properties -> Code Analysis tab. I've recently started creating some .Net 5 projects where this option is no longer available, so I've decided to try using an .editorconfig file instead, but I'm finding the whole code analysis experience to be very frustrating.

I've added an .editorconfig file to the solution's root folder, and also added it to the solution itself, where it appears in the "Solution Items" folder. I can double-click the file, which opens a grid-based GUI "editor", but I often find that nothing happens when I make changes then click Save - the file doesn't change. It seems a bit hit and miss though, suggesting a bug in VS.

I've also added the StyleCop.Analyzers NuGet package to my projects, which adds a load of extra "SAxxxx" and "SXxxxx" rules in the editor's "Analyzers" tab. The same rules also appear under each project, in \Dependencies\Analyzers\StyleCop.Analyzers. However here I can't change the severity of the rules. Should I be able to? When I try, it sometimes displays an error message saying that it can't find a ruleset to update, while at other times nothing happens and the severity remains unchanged.

Also, when I was using rulesets, the ruleset editor listed a number of IDExxxxx rules, but I can't see these anywhere in my new .Net 5 solution - they aren't in the editorconfig editor, and not under the projects' \Analyzers list. Where have these gone?

I'm finding the whole code analysis experience to be incredibly frustrating and confusing. Is it just me, or is there something that I'm not understanding in relation to the ues of editorconfig and code analysis?

Andrew Stephens
  • 9,413
  • 6
  • 76
  • 152
  • I think in the past using Visual Studio, you had to close all files and reopen them for the editorconfig settings to be applied. I am not sure if that is still the case. Jetbrains Rider works well with editorconfig. – Andez Oct 21 '21 at 15:11
  • Code analysis Tab in vs 2019 is available(v16.11.5), and support both Ruleset and .editconfig in net5. – M.Hassan Oct 22 '21 at 05:02

0 Answers0