Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Source analysis by .NET Compiler Platform ("Roslyn") analyzers replaces legacy analysis for managed code. Many of the legacy analysis (FxCop) rules have already been rewritten as source analyzers.
Prior to Visual Studio 2019 16.8 and .NET 5.0, these analyzers shipped as Microsoft.CodeAnalysis.FxCopAnalyzers
NuGet package.
Starting in Visual Studio 2019 16.8 and .NET 5.0, these analyzers are included with the .NET SDK. If you don't want to move to the .NET 5+ SDK or if you prefer a NuGet package-based model, the analyzers are also available in the Microsoft.CodeAnalysis.NetAnalyzers
NuGet package. You might prefer a package-based model for on-demand version updates.
Note
The first-party .NET analyzers are target-platform agnostic. That is, your project does not need to target a specific .NET platform. The analyzers work for projects that target net5.0
as well as earlier .NET versions, such as netcoreapp
, netstandard
, and net472
.
Starting with version 3.3.2
, Microsoft.CodeAnalysis.FxCopAnalyzers
NuGet package has been deprecated. Please follow the below steps to migrate your project or solution from Microsoft.CodeAnalysis.FxCopAnalyzers
to the .NET analyzers:
Uninstall Microsoft.CodeAnalysis.FxCopAnalyzers
NuGet package
Enable or install .NET analyzers. Note that you do not need to change your project's target platform.
Enable additional rules: Microsoft.CodeAnalysis.NetAnalyzers
is much more conservative compared to Microsoft.CodeAnalysis.FxCopAnalyzers
. Unlike FxCopAnalyzers package, it only has a few correctness rules which are enabled by default as build warnings. You can enable additional rules by customizing the AnalysisMode MSBuild property. For example, setting the property to AllEnabledByDefault
will enable all the applicable CA rules as build warnings by default.
<PropertyGroup>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
</PropertyGroup>
Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayTraining
Documentation
Enable or install first-party .NET analyzers - Visual Studio (Windows)
Enable first-party .NET analyzers by using the .NET SDK in Visual Studio or install a first-party analyzer as a NuGet package.
Migrate from FxCop to source analysis (.NET) - Visual Studio (Windows)
Analyze code for the first time or migrate your process from binary analysis (FxCop code analysis) to .NET analyzers for source analysis.
Code quality rule configuration options - .NET
Learn how to specify additional configuration options for code quality rules.