Enable or install first-party .NET analyzers - Visual Studio (Windows) (original) (raw)

.NET compiler platform (Roslyn) analyzers inspect your C# or Visual Basic code for code quality and code style issues. The first-party .NET analyzers are target-platform agnostic. That is, your project doesn't need to target a specific .NET platform. The analyzers work for projects that target net5.0, later versions, as well as earlier .NET versions, such as netcoreapp, netstandard, and net472.

You can enable or install the first-party .NET analyzers in one of the following ways:

Note

It is recommended that you enable the analyzers from the .NET SDK instead of installing the Microsoft.CodeAnalysis.NetAnalyzers NuGet package, when possible. Enabling the analyzers from the .NET SDK ensures that you automatically get the analyzer bug fixes and new analyzers as soon as you update the SDK. In the NuGet model, you need to update the NuGet package each time you want the latest bug fixes. The NuGet package is updated more frequently.

Migrate to .NET analyzers

If you are using legacy FxCop analyzers or FxCop analyzers and want to use the .NET analyzers, follow instructions in the following articles: