Use StyleCop.Analyzers, Microsoft.CodeAnalysis.* or both?

329 views Asked by At

What is the difference between them from the point of view of the rules? Are the rule sets close enough to just use one of them? Then which one to choose?

1

There are 1 answers

0
James Rustad On

Use both.

StyleCop.Analyzers concentrates on the style used in the source code. It will ensure that you follow a specific coding style that will be understood by anyone who looks at your code (assuming they are familiar with the style enforced by StyleCop). https://github.com/DotNetAnalyzers/StyleCopAnalyzers/tree/master/documentation

Microsoft.CodeAnalysis concentrates on finding problematic code constructs. It can find problems that are not obvious. https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview

Compare the CA* warnings with the SA* warnings and the difference between the tools should be apparent.