DiagnosticCatalog.StyleCop 1.0.0

dotnet add package DiagnosticCatalog.StyleCop --version 1.0.0
                    
NuGet\Install-Package DiagnosticCatalog.StyleCop -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DiagnosticCatalog.StyleCop" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DiagnosticCatalog.StyleCop" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DiagnosticCatalog.StyleCop" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DiagnosticCatalog.StyleCop --version 1.0.0
                    
#r "nuget: DiagnosticCatalog.StyleCop, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DiagnosticCatalog.StyleCop@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DiagnosticCatalog.StyleCop&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DiagnosticCatalog.StyleCop&version=1.0.0
                    
Install as a Cake Tool

DiagnosticCatalog.StyleCop

🌍 Languages:
πŸ‡¬πŸ‡§ English (this file) | πŸ‡«πŸ‡· FranΓ§ais

The StyleCop.Analyzers rules as strongly referenced constants, so that SuppressMessageAttribute takes compile-checked references instead of magic strings.

πŸͺž Mirrors StyleCop.Analyzers.Unstable 1.2.0.556

197 rules, 8 categories, every identifier and category read from that release's own analyzers. Regenerated 2026-07-31.

Unofficial. Not affiliated with or endorsed by the StyleCop.Analyzers project.

Why

StyleCop makes the point better than most analyzers: its categories are namespace-shaped strings nobody would ever guess.

[SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1000", Justification = "...")]

Get the id wrong and the suppression silently does nothing β€” the warning simply stays. Get the category wrong and nothing happens at all, ever: the .NET platform never reads that argument, so nothing will ever tell you. Would you have written "StyleCop.CSharp.SpacingRules" from memory? Or "Spacing", or "Style"?

using DiagnosticCatalog.StyleCop;

[SuppressMessage(
    StyleCopRule.SA1000.Category,
    StyleCopRule.SA1000.Id,
    Justification = "Generated code follows a different spacing convention.")]

Installation

<PackageReference Include="DiagnosticCatalog.StyleCop" Version="1.0.0" />

That is the only reference you need. This package depends on DiagnosticCatalog, which carries the DCAT analyzers and code fixes beside its attributes, so referencing this catalogue is what switches on the checks that validate rule declarations and their use sites. A literal suppression a catalogue reference would replace is an error by default, and a code fix rewrites it for you.

What is in the package

193 rules across 8 categories, all of them of the StyleCop.CSharp.*Rules shape: DocumentationRules, LayoutRules, MaintainabilityRules, NamingRules, OrderingRules, ReadabilityRules, SpacingRules, SpecialRules.

Every rule carries its help link, because StyleCop populates HelpLinkUri on all 193 descriptors:

[DiagnosticRule]
public static class SA1000
{
    public const string Id = nameof(SA1000);
    public const string Category = StyleCopCategory.StyleCopCSharpSpacingRules;
    public const string HelpLinkUri = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1000.md";
}

Each rule carries its upstream title as a documentation comment. Rule descriptions are not redistributed β€” the help link takes you to them.

A note on versions

This catalogue mirrors StyleCop.Analyzers.Unstable 1.2.0.556 β€” the 1.2.0-beta line, which is what projects actually install.

That is a deliberate choice, and it is worth stating plainly. StyleCop.Analyzers' latest stable release is 1.1.118, published in April 2019; the project has lived on 1.2.0-beta ever since. Mirroring the stable meant mirroring a release almost nobody runs, and it was not merely incomplete β€” SA1413 is declared under StyleCop.CSharp.ReadabilityRules in the stable and under StyleCop.CSharp.MaintainabilityRules in the beta. A consumer on the beta writing StyleCopRule.SA1413.Category from a stable-based catalogue would get the wrong string, and nothing in their build would ever say so. Being current beats being nominally stable when a category is wrong either way (ADR-0016).

Note the package id: StyleCop.Analyzers 1.2.0-beta is a metapackage carrying no analyzer assembly of its own β€” the rules live in StyleCop.Analyzers.Unstable, whose own versions carry no prerelease tag.

If you are on the stable 1.1.118, use DiagnosticCatalog.StyleCop 0.2.0, the last version to mirror it. Its 193 rules are a subset of the 197 here, none was removed, and only SA1413 changed category.

The assembly records exactly what it mirrors:

[assembly: CatalogSource(
    source:        "StyleCop.Analyzers.Unstable",
    sourceVersion: "1.2.0.556",
    generatedOn:   "2026-07-31")]

Categories declared once

A catalogue repeats very few distinct categories across very many rules. Each one is declared once in StyleCopCategory and the rules refer to it, so there is a single source per value:

[DiagnosticCategory]
public static class StyleCopCategory
{
    public const string StyleCopCSharpSpacingRules = "StyleCop.CSharp.SpacingRules";
}

[DiagnosticRule]
public static class SA1000
{
    public const string Id = nameof(SA1000);
    public const string Category = StyleCopCategory.StyleCopCSharpSpacingRules;
}

A const initialised from another const is still a compile-time constant, so StyleCopRule.SA1000.Category remains valid as an attribute argument and still folds to "StyleCop.CSharp.SpacingRules" in metadata. The indirection costs nothing.

StyleCopCategory is also usable on its own β€” IntelliSense on it lists exactly the 8 categories this analyzer actually uses.

How it is produced

Not transcribed from documentation. The generator loads the analyzer assemblies, constructs the analyzers they mark with [DiagnosticAnalyzer], and reads the DiagnosticDescriptor instances they actually declare β€” the only source that cannot have drifted.

dotnet run --project src/DiagnosticCatalog.Cli -- generate \
    --package StyleCop.Analyzers.Unstable --package-version latest \
    --namespace DiagnosticCatalog.StyleCop --container StyleCopRule \
    --output src/DiagnosticCatalog.StyleCop/StyleCopRules.g.cs

How it stays current

A nightly workflow regenerates every catalogue from its upstream package and opens a pull request when anything the catalogue publishes has moved. It never publishes: a category or an id that changed upstream changes a published contract, and since the platform never reads a suppression's category, a wrong value merged unreviewed would produce no symptom anywhere. A human reads the diff.

Nights where upstream has not moved produce nothing at all: the generator compares its own previous output and leaves the file untouched, generatedOn included.

A rule retired upstream is never deleted. It is kept and marked [Obsolete] naming the version that dropped it, so a project still referencing it gets a CS0618 warning telling it to remove the suppression β€” rather than a hard error from a member that vanished. Consumers inline constant values at their own compile time, so deleting one breaks their recompilation.

To regenerate every catalogue at once:

dotnet run --project src/DiagnosticCatalog.Cli -- generate --manifest eng/catalogs.json

How it reaches nuget.org

This catalogue rides the stylecop release train and versions independently of the foundation, so it can follow StyleCop.Analyzers' releases without dragging anything else along.

Publishing is not part of the nightly. A maintainer pushes a stylecop-vX.Y.Z tag, and the release workflow packs the package, embeds an SPDX SBOM, and publishes through NuGet Trusted Publishing with signed build provenance β€” no long-lived API key exists anywhere to leak. The packaging half of that pipeline is rehearsed on every pull request, so a release never exercises it for the first time on a tag.

Limits

[SuppressMessage] cannot suppress compiler warnings β€” CS0219 and friends need #pragma warning disable, which takes bare identifiers and so can never reference a constant. This package covers the SAxxxx analyzer rules only.

See also

Every catalogue this repository publishes is listed in one place β€” pick the one that matches an analyzer you run:

The ready-made catalogues

Want a catalogue of your own? Your analyzer's rules, or an internal ruleset, are declared exactly the way these are: a static class of constants marked [DiagnosticRule], referenced by consumers instead of retyped. That marker ships in DiagnosticCatalog, the foundation this catalogue is built on, and its README is the guide.

Documentation

For using a catalogue, in the order the work happens:

The documentation map picks a page by what you are trying to do; every guide exists in English and French. The specification is the normative version of all of it.

License

Apache-2.0. The rule identifiers, categories and help links are facts about a third-party analyzer, which is itself MIT-licensed.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.0 5 8/7/2026
0.3.0 402 7/31/2026
0.2.0 91 7/31/2026
0.1.0 100 7/31/2026