Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between Microsoft.CodeAnalysis.FxCopAnalyzers and Microsoft.CodeAnalysis?

I want to install code analysis in one of my C# projects, and it seems that the way people add code analysis to .NET Core projects is by using the NuGet package Microsoft.CodeAnalysis.FxCopAnalyzers.

However, I also found other NuGet packages from the Microsoft.CodeAnalysis namespace, namely Microsoft.CodeAnalysis, Microsoft.CodeAnalysis.CSharp, Microsoft.CodeAnalysis.Features, etc.

What is the purpose of these other packages in comparison to the FxCopAnalyers package? The package descriptions are not very clear, so I don't know what their use cases are.

EDIT 2021: From current documentation: Prior to Visual Studio 2019 16.8 and .NET 5.0, code 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. They are also available as Microsoft.CodeAnalysis.NetAnalyzers NuGet package. Please consider migrating from FxCop analyzers to .NET analyzers.

like image 496
Andrej Lucansky Avatar asked Apr 15 '19 06:04

Andrej Lucansky


People also ask

What replaced FxCop?

NET 5.0, FxCop is replaced with Microsoft Code Analysis (Roslyn) Analyzers.

What is FxCop tool used for?

FxCop provides a tool to help developers to follow their company's coding standards. FxCop does code analysis to check whether the new code is compliant with the coding standards and naming conventions followed by the company. FxCop will ensure that the specified rules are used in the source code.


1 Answers

Microsoft.CodeAnalysis.FxCopAnalyzers is just a set of analyzers which analyze your code as some other analyzers, IDEs, etc. This package analyzes your code for performance, design issues, and so on, and so forth.

However, Microsoft.CodeAnalysis.CSharp, Microsoft.CodeAnalysis.VisualBasic, Microsoft.CodeAnalysis.Workspaces and other similar packages allow you to programmatically analyze input code, write custom static code analyzers and rulesets, investigate semantic and syntactical code models, and use some helpful logic to extend Visual Studio features, and so on, and so forth.

like image 182
George Alexandria Avatar answered Oct 05 '22 12:10

George Alexandria