AngryHacker
AngryHacker

Reputation: 61616

What is the difference between various Microsoft.CodeQuality.* analyzers?

I am a bit confused about the various code analyzers for .NET Core.

If you create a default .NET Core web project, you get the Microsoft.CodeAnalysis.Analyzers.

In addition, on NuGet, there is Microsoft.CodeQuality.Analyzers (note the slight difference in the name). After installing it, I see that it contains a lot more rules.

And finally, there is also Microsoft.CodeAnalysis.FxCopAnalyzers, which appears to contain Microsoft.CodeQuality.Analyzers.

So what exactly is the relationship between Microsoft.CodeAnalysis.Analyzers, Microsoft.CodeQuality.Analyzers and Microsoft.CodeAnalysis.FxCopAnalyzers? What should my project have?

P.S. After creating a new project, I search NuGet for Microsoft.CodeAnalysis.Analyzers package (which already exists in my project). It finds it and states my project has v1.1 and that it needs to upgrade it to v2.9.4. However, according to NuGet, v1.1 was released in 2015. This makes no sense as I am using VS2019 and there have been plenty of releases of this analyzer between 2015 and 2019.

However, when I upgrade the package to 2.9.4 - the analyzer has the same 3 rules that v1.1 had. So what exactly am I upgrading?

Upvotes: 5

Views: 1954

Answers (1)

Julian
Julian

Reputation: 36740

This is described here: https://github.com/dotnet/roslyn-analyzers/blob/master/README.md

In summary:

  • Microsoft.CodeQuality.Analyzers is the package to use for running analyzers.

    This package contains common code quality improvement rules that are not specific to usage of any particular API

  • Microsoft.CodeAnalysis.Analyzers is for code analysis creators. So for creating an analyzer.
  • Microsoft.CodeAnalysis.FxCopAnalyzers: This is the primary analyzer package for this repo that contains all the ported FxCop code analysis rules (CAxxxx).

Upvotes: 4

Related Questions