|
1 | | -README |
| 1 | +# Microsoft.Extensions.StaticAnalysis |
| 2 | + |
| 3 | +A curated set of code analyzers and code analyzer settings. |
| 4 | + |
| 5 | +## Install the package |
| 6 | + |
| 7 | +From the command-line: |
| 8 | + |
| 9 | +```dotnetcli |
| 10 | +dotnet add package Microsoft.Extensions.StaticAnalysis |
| 11 | +``` |
| 12 | + |
| 13 | +Or directly in the C# project file: |
| 14 | + |
| 15 | +```xml |
| 16 | +<ItemGroup> |
| 17 | + <PackageReference Include="Microsoft.Extensions.StaticAnalysis" Version="[CURRENTVERSION]" > |
| 18 | + <PrivateAssets>all</PrivateAssets> |
| 19 | + <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
| 20 | + </PackageReference> |
| 21 | +</ItemGroup> |
| 22 | +``` |
| 23 | + |
| 24 | +## Usage Example |
| 25 | + |
| 26 | +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. |
| 27 | + |
| 28 | +```XML |
| 29 | + <PropertyGroup> |
| 30 | + <StaticAnalysisCodeType>General</StaticAnalysisCodeType> |
| 31 | + </PropertyGroup> |
| 32 | +``` |
| 33 | + |
| 34 | +## Available Sets Of Diagnostics |
| 35 | + |
| 36 | +Different pre-defined sets of diagnostics are available depending on the type of project being built. These can be specified in the StaticAnalysisCodeType property: |
| 37 | +- Benchmark: Projects used for benchmarking. |
| 38 | +- General: Any type of project. |
| 39 | +- NonProdExe: Projects that produce an exe for non-production use. |
| 40 | +- NonProdLib: Projects that produce a library (dll) for non-production use. |
| 41 | +- ProdExe: Projects that produce an exe for production use. |
| 42 | +- ProdLib: Projects that produce a library (dll) for production use. |
| 43 | +- Test: Projects used for testing. |
| 44 | + |
| 45 | +Each of these also has an optional `-Tier1` and a `-Tier2` variant (e.g. `General-Tier1`). |
| 46 | +- `Tier1` enables only the most important diagnostics from this set. |
| 47 | +- `Tier2` includes Tier1 diagnostics and others that aren't as critical. |
| 48 | +- The names without `Tier` suffixes include all diagnostics from tier's 1 and 2, and any others that are applicable. |
| 49 | + |
| 50 | +## Feedback & Contributing |
| 51 | + |
| 52 | +We welcome feedback and contributions in [our GitHub repo](https://github.com/dotnet/extensions). |
0 commit comments