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.
NET 5.0, FxCop is replaced with Microsoft Code Analysis (Roslyn) Analyzers.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With