Dloizides.Analyzers
0.7.4
See the version list below for details.
dotnet add package Dloizides.Analyzers --version 0.7.4
NuGet\Install-Package Dloizides.Analyzers -Version 0.7.4
<PackageReference Include="Dloizides.Analyzers" Version="0.7.4"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Dloizides.Analyzers" Version="0.7.4" />
<PackageReference Include="Dloizides.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Dloizides.Analyzers --version 0.7.4
#r "nuget: Dloizides.Analyzers, 0.7.4"
#:package Dloizides.Analyzers@0.7.4
#addin nuget:?package=Dloizides.Analyzers&version=0.7.4
#tool nuget:?package=Dloizides.Analyzers&version=0.7.4
Dloizides.Analyzers
Roslyn analyzers for the house comment standard (no comments in code, and only short doc comments
on public members) and the test-name standard (Method_Scenario_Expected) and feature folders over technical-type folders. Business and logic intent lives in names and in unit / integration test names.
| Id | Reports |
|---|---|
DLZ0001 |
A // or /* */ comment that is not a tool directive (#pragma, ReSharper, <auto-generated>) |
DLZ0002 |
A doc comment (/// or /** */) on a member not visible outside the assembly: private, internal, private protected, a member of a non-public type, a local function, or a statement |
DLZ0003 |
A doc comment over 3 content lines, a summary over one line, a line over 120 characters, a call chain (→, -> or a line starting Flow:), or using an element other than <summary>, <param>, <returns>, <inheritdoc/> and inline <see>, <c>, <paramref>, <typeparamref> |
DLZ0004 |
A [Fact], [Theory], [Test] or [TestMethod] method (or an attribute derived from one) not named Method_Scenario_Expected: exactly 3 PascalCase parts, the Scenario starting With, When, Without or Given (Create_WithValidRequest_Returns201) |
DLZ0005 |
A type declared in a namespace with a Services, Helpers, Utils, Utilities or Common segment: organize by feature/use case (ARCH-VSA-1 "Vertical Slice Architecture inside Clean Architecture"). Runs only when HouseArchitectureStyle is CleanVerticalSlice; skipped in assemblies ending .Shared, .SharedKernel or Tests; one diagnostic per top-level type |
Pattern rules
Default severity error, category Dloizides.Patterns (PATTERN-1 "Use the house pattern wherever its trigger appears"). Rules 6, 7 and 9 skip assemblies ending Tests.
| Id | Reports |
|---|---|
DLZ0006 |
new HttpClient(...) outside a lambda passed to AddHttpClient, ConfigureHttpClient, ConfigurePrimaryHttpMessageHandler or AddTypedClient (PAT-HTTP-1) |
DLZ0007 |
IConfiguration (or a type implementing it) as a constructor or primary-constructor parameter, or a field of a type whose constructors do not take it; static classes, Startup and Program are skipped (PAT-CONFIG-1) |
DLZ0008 |
An if or ?: whose condition is only role checks (IsInRole, Contains/Any on a *Roles value) and whose branch calls Forbid/ForbidAsync/ForbiddenAsync/SendForbiddenAsync or creates a ForbidResult; a condition that also checks ownership is not reported (PAT-AUTHZ-1) |
DLZ0009 |
GetOrAdd/TryAdd/AddOrUpdate/TryUpdate or an indexer write on a static ConcurrentDictionary outside its field initializer or static constructor (PAT-CACHE-1) |
DLZ0010 |
A [SuppressMessage] / [UnconditionalSuppressMessage] for DLZ0006-DLZ0009 with a missing, empty or blank Justification |
DLZ0011 |
A project whose MSBuild property HouseArchitectureStyle is missing, empty or not Clean / CleanVerticalSlice (case-sensitive); one diagnostic per compilation (PAT-STYLE-1) |
Lone <summary> / </summary> lines and <inheritdoc/> do not count toward the 3-line cap.
Generated code (<auto-generated>, *.g.cs, *.Designer.cs, generated_code = true) and files under
a Migrations folder are skipped. Works with and without GenerateDocumentationFile.
Adopt
<PackageReference Include="Dloizides.Analyzers" Version="0.6.0" PrivateAssets="all" />
Put it in the repo's Directory.Build.props with the service's declared architecture style (D-PAT-10
"Architecture style is a per-service choice"): Clean = Clean Architecture layers only,
CleanVerticalSlice = Clean layers plus feature folders (turns on DLZ0005). The package's
buildTransitive props make the property visible to the analyzers.
<PropertyGroup>
<HouseArchitectureStyle>CleanVerticalSlice</HouseArchitectureStyle>
</PropertyGroup>
Diagnostics default to warning; once the repo's
comment cleanup has landed, make them errors in .editorconfig
(a project that legitimately keeps a technical-type namespace sets dotnet_diagnostic.DLZ0005.severity = none):
[*.cs]
dotnet_diagnostic.DLZ0001.severity = error
dotnet_diagnostic.DLZ0002.severity = error
dotnet_diagnostic.DLZ0003.severity = error
dotnet_diagnostic.DLZ0004.severity = error
dotnet_diagnostic.DLZ0005.severity = error
Build and test
dotnet test tests/Dloizides.Analyzers.Tests
Publish with ./publish.ps1 -Bump patch -ApiKey $env:NUGET_API_KEY from a clean, committed tree.
Rule packs and DLZ0012-DLZ0013 (D-PAT-12 "Whole rule packs as warnings, one shared approach")
Referencing this package also brings Meziantou.Analyzer, Microsoft.VisualStudio.Threading.Analyzers and SonarAnalyzer.CSharp. buildTransitive/Dloizides.Analyzers.packs.globalconfig sets every default-enabled Info or Error rule of the packs to warning and turns MA0004 (ConfigureAwait: ASP.NET Core has no SynchronizationContext) and MA0048 (file name = type name: a vertical-slice file holds Request + Endpoint + Validator) off (global_level = 50: above the packs own configs, below a repo .globalconfig at 100; a repo .editorconfig always wins). buildTransitive/Dloizides.Analyzers.targets adds that file to EditorConfigFiles in a target before CoreCompile (a static GlobalAnalyzerConfigFiles item never reached the compiler) and appends every pack rule ID plus DLZ0001-DLZ0005, DLZ0012 and DLZ0013 to WarningsNotAsErrors, so a TreatWarningsAsErrors repo still builds; the warnings are counted by the ratchet, not held to zero. PackRuleFilesTests fails when a pack bump changes the rule list and names the regenerated file to copy in.
| ID | Rule |
|---|---|
| DLZ0012 | A class named *Dto, *Command or *Event that derives from object is a record (PAT-REVIEW-7) |
| DLZ0013 | A concrete *Service/*Repository/*Handler/*Provider/*Manager/*Client of the same solution is not constructed with new outside Program.cs/Startup.cs, a method taking IServiceCollection/IServiceProvider/a host builder, a lambda passed to Add*/TryAdd*/Configure*, or the type's own factory (PAT-REVIEW-4) |
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Meziantou.Analyzer (>= 3.0.313)
- Microsoft.VisualStudio.Threading.Analyzers (>= 18.12.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 |
|---|---|---|
| 0.23.1 | 79 | 11/26/2026 |
| 0.23.0 | 74 | 11/26/2026 |
| 0.22.0 | 86 | 11/25/2026 |
| 0.21.0 | 83 | 11/25/2026 |
| 0.20.0 | 82 | 11/25/2026 |
| 0.19.0 | 78 | 11/25/2026 |
| 0.18.0 | 81 | 11/25/2026 |
| 0.14.0 | 91 | 11/23/2026 |
| 0.13.0 | 99 | 11/23/2026 |
| 0.12.0 | 114 | 11/21/2026 |
| 0.11.0 | 108 | 11/19/2026 |
| 0.10.1 | 270 | 11/19/2026 |
| 0.10.0 | 99 | 11/19/2026 |
| 0.9.0 | 132 | 10/27/2026 |
| 0.8.2 | 112 | 10/26/2026 |
| 0.8.1 | 102 | 10/26/2026 |
| 0.8.0 | 107 | 10/26/2026 |
| 0.7.4 | 373 | 10/19/2026 |
| 0.7.3 | 95 | 10/19/2026 |
| 0.7.2 | 98 | 10/19/2026 |