Migrate from legacy analysis (FxCop) to source analysis (.NET analyzers)
Applies to: Visual Studio Visual Studio for Mac
Source analysis by .NET Compiler Platform ("Roslyn") analyzers replaces legacy analysis for managed code. For newer project templates such as .NET Core and .NET Standard projects, legacy analysis is not available.
Many of the legacy analysis (FxCop) rules have already been rewritten for .NET analyzers, a set of Roslyn code analyzers. Roslyn analyzers run source-code based analysis during compiler execution. Analyzer results are reported along with compiler results.
For more information on the differences between legacy analysis and source analysis, see the following:
To migrate to source analysis:
Enable or install the .NET analyzers. Like legacy analysis rule violations, source code analysis violations appear in the Error List window in Visual Studio. In addition, source code analysis violations also show up in the code editor as squiggles under the offending code. The color of the squiggle depends on the severity setting of the rule. To see the status of rules ported to the new .NET analyzers, see Ported and unported rules.
Prior to Visual Studio 2019 16.8 and .NET 5.0, these analyzers shipped as
Microsoft.CodeAnalysis.FxCopAnalyzersNuGet package. Starting in Visual Studio 2019 16.8 and .NET 5.0, these analyzers are included with the .NET SDK. They are also available as
Microsoft.CodeAnalysis.NetAnalyzersNuGet package. For more information, see Migrate from FxCop analyzers to .NET analyzers.
To resolve CA0507, make sure that legacy code analysis is disabled for the project. In the project file, set the
RunCodeAnalysisproperty to false:
Or, open Project Properties > Code Analysis and disable the Run on build setting.
To learn more about how to configure the .NET analyzers:
To configure .NET analyzers, see Configure .NET analyzers.
To find out about configuring analyzers using predefined rules with EditorConfig or a rule set file, see Enable a category of rules.
Submit and view feedback for