DiagnosticCatalog.StyleCop
0.1.0
See the version list below for details.
dotnet add package DiagnosticCatalog.StyleCop --version 0.1.0
NuGet\Install-Package DiagnosticCatalog.StyleCop -Version 0.1.0
<PackageReference Include="DiagnosticCatalog.StyleCop" Version="0.1.0" />
<PackageVersion Include="DiagnosticCatalog.StyleCop" Version="0.1.0" />
<PackageReference Include="DiagnosticCatalog.StyleCop" />
paket add DiagnosticCatalog.StyleCop --version 0.1.0
#r "nuget: DiagnosticCatalog.StyleCop, 0.1.0"
#:package DiagnosticCatalog.StyleCop@0.1.0
#addin nuget:?package=DiagnosticCatalog.StyleCop&version=0.1.0
#tool nuget:?package=DiagnosticCatalog.StyleCop&version=0.1.0
DiagnosticCatalog.StyleCop
The StyleCop.Analyzers rules as strongly referenced constants, so that
SuppressMessageAttribute takes compile-checked references instead of magic strings.
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="0.1.0" />
This package only supplies the constants. The checks that validate rule declarations and
their use sites ship separately in DiagnosticCatalog.Analyzers.
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";
}
Rule titles and descriptions are not redistributed — the help link takes you to them.
A note on versions
This catalogue mirrors StyleCop.Analyzers 1.1.118, the latest stable release. Many
projects run 1.2.0-beta.556 instead, which is widely used despite the prerelease tag and
carries additional rules. If that is you, regenerate against it:
dotnet run --project eng/CatalogGen -- \
--package StyleCop.Analyzers.Unstable --version 1.2.0.556 \
--namespace DiagnosticCatalog.StyleCop --container StyleCopRule \
--output src/DiagnosticCatalog.StyleCop/StyleCopRules.g.cs
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.
The assembly records exactly what it mirrors:
[assembly: CatalogSource(
source: "StyleCop.Analyzers",
sourceVersion: "1.1.118",
generatedOn: "2026-07-30")]
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 every DiagnosticAnalyzer they contain, and reads the DiagnosticDescriptor
instances they actually declare — the only source that cannot have drifted.
dotnet run --project eng/CatalogGen -- \
--package StyleCop.Analyzers --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 something actually moved — added rules, recategorised rules, rules retired upstream. 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 eng/CatalogGen -- --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.
Documentation
License
Apache-2.0. The rule identifiers, categories and help links are facts about a third-party analyzer, which is itself MIT-licensed.
| Product | Versions 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. |
-
.NETStandard 2.0
- DiagnosticCatalog (>= 0.1.0)
-
net10.0
- DiagnosticCatalog (>= 0.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.