Skip to main content
.NETStandard2.0

A curated set of code analyzers and code analyzer settings.

Published
Sep 10, 2024
2y ago
Total Downloads
168.2K
168,163

Install

dotnet add package Microsoft.Extensions.StaticAnalysis --version 9.0.0-preview.8.24460.1
ProductVersions
.NET Standard
netstandard2.0

README

Microsoft.Extensions.StaticAnalysis

A curated set of code analyzers and code analyzer settings.

Install the package

From the command-line:

dotnet add package Microsoft.Extensions.StaticAnalysis

Or directly in the C# project file:

<ItemGroup>
  <PackageReference Include="Microsoft.Extensions.StaticAnalysis" Version="[CURRENTVERSION]" >
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  </PackageReference>
</ItemGroup>

Usage Example

On install, a warning will be displayed that The StaticAnalysisCodeType property is not defined, assuming 'General'. The General set of diagnostics is enabled by default. To select a different set of diagnostics (or hide the warning) add the StaticAnalysisCodeType property to your project as follows.

  <PropertyGroup>
    <StaticAnalysisCodeType>General</StaticAnalysisCodeType>
  </PropertyGroup>

Available Sets Of Diagnostics

Different pre-defined sets of diagnostics are available depending on the type of project being built. These can be specified in the StaticAnalysisCodeType property:

  • Benchmark: Projects used for benchmarking.
  • General: Any type of project.
  • NonProdExe: Projects that produce an exe for non-production use.
  • NonProdLib: Projects that produce a library (dll) for non-production use.
  • ProdExe: Projects that produce an exe for production use.
  • ProdLib: Projects that produce a library (dll) for production use.
  • Test: Projects used for testing.

Each of these also has an optional -Tier1 and a -Tier2 variant (e.g. General-Tier1).

  • Tier1 enables only the most important diagnostics from this set.
  • Tier2 includes Tier1 diagnostics and others that aren't as critical.
  • The names without Tier suffixes include all diagnostics from tier's 1 and 2, and any others that are applicable.

Feedback & Contributing

We welcome feedback and contributions in our GitHub repo.

Changes from Previous Version

No structural changes between v9.0.0-preview.7.24412.10 and v9.0.0-preview.8.24460.1.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.