Digitals.Analyzers
1.1.0
dotnet add package Digitals.Analyzers --version 1.1.0
NuGet\Install-Package Digitals.Analyzers -Version 1.1.0
<PackageReference Include="Digitals.Analyzers" Version="1.1.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Digitals.Analyzers" Version="1.1.0" />
<PackageReference Include="Digitals.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Digitals.Analyzers --version 1.1.0
#r "nuget: Digitals.Analyzers, 1.1.0"
#:package Digitals.Analyzers@1.1.0
#addin nuget:?package=Digitals.Analyzers&version=1.1.0
#tool nuget:?package=Digitals.Analyzers&version=1.1.0
Digitals.Analyzers
Digitals.Analyzers brings the Digitals C# analyzers and severity policy to every project in a repo: SonarAnalyzer.CSharp, Roslynator, the VS Threading analyzers and BannedApiAnalyzers, configured as one policy, plus our own DT0#### rules and four build checks. It covers production code; test projects add Digitals.Testing on top.
Reference it once, in Directory.Build.props, and remove any direct reference to the analyzers it bundles:
<PropertyGroup>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors>nullable</WarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Digitals.Analyzers" PrivateAssets="all" />
</ItemGroup>
Without EnforceCodeStyleInBuild the IDE rules stay in the editor, and without GenerateDocumentationFile the build never reports an unused using. On a target older than net10.0, also set <NuGetAuditMode>all</NuGetAuditMode>. The reference has no Version because it assumes central package management, with the version in Directory.Packages.props; without it, add Version with the latest from this page.
| What | Does |
|---|---|
| Severity policy | A global AnalyzerConfig at global_level 100. Every rule it turns on is a warning or a suggestion, never an error, so TreatWarningsAsErrors decides how hard it bites. |
Banned APIs (RS0030) |
The ambient clock (DateTime.Now, DateTimeOffset.UtcNow, ...): inject TimeProvider. The int millisecond overloads of Task.Delay, Thread.Sleep, new CancellationTokenSource and CancelAfter: pass a TimeSpan. In production code only, EF Core's FromSqlRaw family (use FromSql($"...")), Html.Raw, HtmlString and MarkupString (let Razor encode), and process arguments as one string (use ArgumentList). |
| Taint analysis | The SDK's CA3001-CA3012, shipped off, raised to warning: a request value that reaches SQL, a file path, a process start or another injection sink unchecked, followed across methods and classes. |
DT0#### rules |
Time types, new HttpClient(), dynamic, money held as double, nullable collections, #region, negative boolean names, a local reused for an unrelated value, file names, and six rules that keep each method at one level of abstraction. |
DIGB001 |
Fails the build on a direct reference to Newtonsoft.Json, AutoMapper, EF6, System.Data.SqlClient or EF Core lazy-loading proxies. |
DIGB002, DIGB003 |
Fail the build when Nullable isn't enable or TreatWarningsAsErrors isn't true, since without them the policy is advisory. |
DIGB004 |
Warns, and under TreatWarningsAsErrors fails, when the NuGet vulnerability audit is weakened. |
SonarLint.xml |
Sonar's thresholds, such as cyclomatic complexity 15 rather than 10. Add your own SonarLint.xml as AdditionalFiles and the packaged one steps aside. |
| SARIF | dotnet build -p:DigitalsSarifDir=artifacts/sarif writes every finding, suggestion level included, as SARIF per project. |
A repo-local .editorconfig beats the packaged policy, so dotnet_diagnostic.<ID>.severity = none there turns a rule off. Each build check has its own opt-out (DigitalsAllowBannedPackages, DigitalsAllowNullableDisabled, DigitalsAllowWarningsNotAsErrors, DigitalsAllowWeakNuGetAudit), set beside a comment saying why.
The Analyzers rules page explains every rule: why it exists, a failing and a passing example, and the message the build prints. Moving an existing repo onto the package, including how to stage the first wave of findings: the adoption guide.
The analyzers run in the compiler, so the package works for any target framework from a .NET 10 SDK up. It is C# only in practice: Sonar and Roslynator don't analyze VB or F#. The bundled analyzers keep their own licences and reach you as ordinary NuGet dependencies. Release notes are on GitHub Releases.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.BannedApiAnalyzers (>= 5.6.0)
- Microsoft.VisualStudio.Threading.Analyzers (>= 18.12.1)
- Roslynator.Analyzers (>= 5.0.1)
- Roslynator.Formatting.Analyzers (>= 5.0.1)
- SonarAnalyzer.CSharp (>= 10.35.0.4138)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.1.0 | 105 | 11/3/2026 | |
| 1.0.1 | 136 | 11/2/2026 | |
| 1.0.0 | 116 | 10/31/2026 | |
| 0.12.0 | 124 | 10/31/2026 | |
| 0.11.0 | 1,097 | 10/18/2026 | |
| 0.10.3 | 166 | 9/29/2026 | |
| 0.10.2 | 216 | 9/29/2026 | |
| 0.10.1 | 421 | 9/23/2026 | |
| 0.10.0 | 137 | 9/23/2026 | |
| 0.9.0 | 138 | 9/23/2026 | |
| 0.8.0 | 174 | 9/21/2026 | |
| 0.7.2 | 157 | 9/19/2026 | |
| 0.7.1 | 138 | 9/19/2026 | |
| 0.7.0 | 136 | 9/19/2026 | |
| 0.6.0 | 583 | 8/31/2026 | |
| 0.5.1 | 321 | 8/26/2026 | |
| 0.5.0 | 186 | 8/20/2026 |