.NET Compiler Platform ("Roslyn") Analyzers, including ported FxCop analyzers
Windows Debug | Windows Release | |
---|---|---|
master |
This repository contains Roslyn diagnostic analyzers and code fix providers for general code quality improvement for C# and Visual Basic projects that target either .NET Core, .NET Standard, or .NET Framework for desktop apps.
This is the primary analyzer package for this repo that contains all the ported FxCop code analysis rules (CAxxxx). Refer to FxCop analyzers for documentation and FAQs about migrating from legacy post-build static analysis ("Analyze" → "Run Code Analysis" command in Visual Studio), also known as "FxCop", to FxCop analyzers.
This analyzer package contains all the ported FxCop rules that are applicable for both .NetCore/.NetStandard and Desktop .NetFramework projects. You do not need to install any separate analyzer package from this repo to get target-framework specific FxCop rules.
More info about rules in this package
This analyzer package contains the following subpackages or NuGet dependencies that are automatically installed when you install the Microsoft.CodeAnalysis.FxCopAnalyzers package:
This package contains common code quality improvement rules that are not specific to usage of any particular API. For example, CA1801 (ReviewUnusedParameters) flags parameters that are unused and is part of this package.
More info about rules in this package
This package contains rules for correct usage of APIs that are present in .NetCore/.NetStandard framework libraries. For example, CA1309 (UseOrdinalStringComparison) flags usages of string compare APIs that don't specify a StringComparison
argument.
NOTE: This analyzer package is applicable for both .NetCore/.NetStandard and Desktop .NetFramework projects. If the API whose usage is being checked exists only in .NetCore/.NetStandard libraries, then the analyzer will bail out silently for Desktop .NetFramework projects. Otherwise, if the API exists in both .NetCore/.NetStandard and Desktop .NetFramework libraries, the analyzer will run correctly for both .NetCore/.NetStandard and Desktop .NetFramework projects.
More info about rules in this package
This package contains rules for correct usage of APIs that are present only in Desktop .NetFramework libraries.
NOTE: The analyzers in this package will silently bail out if installed on a .NetCore/.NetStandard project that do not have the underlying API whose usage is being checked. If future versions of .NetCore/.NetStandard libraries include these APIs, the analyzers will automatically light up on .NetCore/.NetStandard projects that target these libraries.
More info about rules in this package
This package contains rules for correct usage of APIs from the Microsoft.CodeAnalysis NuGet package, i.e. .NET Compiler Platform ("Roslyn") APIs. These are primarily aimed towards helping authors of diagnostic analyzers and code fix providers to invoke the Microsoft.CodeAnalysis APIs in a recommended manner.
More info about rules in this package
This package contains rules that are very specific to the .NET Compiler Platform ("Roslyn") project, i.e. https://github.com/dotnet/roslyn repo. This analyzer package is not intended for general consumption outside the Roslyn repo.
More info about rules in this package
This package contains customizable rules for identifying references to banned APIs.
More info about rules in this package
This package contains rules to help library authors monitoring change to their public APIs.
More info about rules in this package
Created by summer 2015 interns Zoë Petard, Jessica Petty, and Daniel King
The MetaCompilation Analyzer is an analyzer that functions as a tutorial to teach users how to write an analyzer. It uses diagnostics and code fixes to guide the user through the various steps required to create a simple analyzer. It is designed for novice analyzer developers who have some previous programming experience.
For instructions on using this tutorial, see Instructions.
More info about rules in this package
- Clone the repository
- Restore and build:
build.cmd
- Execute tests:
test.cmd
Prior to submitting a pull request, ensure the build and all tests pass using using steps 2 and 3 above.
See VERSIONING.md for the versioning scheme for all analyzer packages built out of this repo.
Recommended Visual Studio Version: Visual Studio 2017 15.5 Preview5, RTW or later
Recommended Analyzer Package Version: Version 2.6.3, for example https://www.nuget.org/packages/Microsoft.CodeAnalysis.FxCopAnalyzers/2.6.3
Due to the fact that large number of our analyzers were based on the not-yet-shipped IOperation APIs in Roslyn, they were in beta stage and tied to a specific compiler/Visual Studio version. IOperation API shipped in Visual Studio 2017 15.5 Preview5, and we have released fully supported version 2.6.0 analyzer packages that should work on all future compiler/Visual Studio versions. Please use the following guidelines when choosing the version of analyzer packages to use on a specific version of Visual Studio/compiler toolset:
- Visual Studio 2015 RTW: Analyzer package Version 1.0.1, for example https://www.nuget.org/packages/Microsoft.CodeAnalysis.FxCopAnalyzers/1.0.1
- Visual Studio 2015 Update 1: Analyzer package Version 1.1.0, for example https://www.nuget.org/packages/Microsoft.CodeAnalysis.FxCopAnalyzers/1.1.0
- Visual Studio 2015 Update 2 and 3: Analyzer package Version 1.2.0-beta2, for example https://www.nuget.org/packages/Microsoft.CodeAnalysis.FxCopAnalyzers/1.2.0-beta2
- Visual Studio 2017 RTW (15.0), 15.1 and 15.2: Analyzer package Version 2.0.0-beta2, for example https://www.nuget.org/packages/Microsoft.CodeAnalysis.FxCopAnalyzers/2.0.0-beta2
- Visual Studio 2017 15.3: Analyzer package Version 2.3.0-beta1, for example https://www.nuget.org/packages/Microsoft.CodeAnalysis.FxCopAnalyzers/2.3.0-beta1
- Visual Studio 2017 15.5 Preview5, RTW or later: Analyzer package Version 2.6.3, for example https://www.nuget.org/packages/Microsoft.CodeAnalysis.FxCopAnalyzers/2.6.3
On Visual Studio 2017 15.5 and later releases, you can also install a custom Microsoft Code Analysis VSIX containing these analyzers as a Visual Studio extension for all your managed projects. See details here: https://marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.MicrosoftCodeAnalysis2017