StyleSharp.Analyzers
3.16.7
dotnet add package StyleSharp.Analyzers --version 3.16.7
NuGet\Install-Package StyleSharp.Analyzers -Version 3.16.7
<PackageReference Include="StyleSharp.Analyzers" Version="3.16.7"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="StyleSharp.Analyzers" Version="3.16.7" />
<PackageReference Include="StyleSharp.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add StyleSharp.Analyzers --version 3.16.7
#r "nuget: StyleSharp.Analyzers, 3.16.7"
#:package StyleSharp.Analyzers@3.16.7
#addin nuget:?package=StyleSharp.Analyzers&version=3.16.7
#tool nuget:?package=StyleSharp.Analyzers&version=3.16.7
<br> <a href="https://github.com/glennawatson/RoslynCommonAnalyzers"> <img width="160" height="160" src="https://raw.githubusercontent.com/glennawatson/RoslynCommonAnalyzers/main/icons/icon.png" alt="StyleSharp.Analyzers"> </a> <br>
RoslynCommonAnalyzers
Two fast Roslyn analyzer and code-fix packages for .NET codebases, built from one repository:
StyleSharp.Analyzers(SST####) — style and consistency: spacing, readability, ordering, layout, naming, maintainability, documentation, extension blocks, records, lock-target safety, modernization, collection expressions, and modern C# syntax.PerformanceSharp.Analyzers(PSH####) — runtime performance of your code: avoidable allocations, collection and LINQ enumeration costs, string handling, concurrency and async patterns, and cheaper API selection.
Both packages are analyzer-only, target netstandard2.0, ship as a DevelopmentDependency, and pack analyzer/code-fix assemblies for multiple Roslyn slots under one NuGet package each. The analyzers themselves are engineered for build-time speed: allocation-free no-diagnostic paths, syntax-first candidate filtering, and per-rule benchmarks.
Installation
dotnet add package StyleSharp.Analyzers
dotnet add package PerformanceSharp.Analyzers
Each package adds no runtime assemblies to your output and is not transitive to consumers of your library. They are independent — install either or both.
Documentation
- Full rule catalog (both packages):
docs/README.md - Configuration:
docs/CONFIGURATION.md - Performance guidance:
docs/PERFORMANCE.md - Ready-to-use presets:
recommended.editorconfig(StyleSharp) andrecommended-performancesharp.editorconfig(PerformanceSharp)
The rule catalog is intentionally split out of this README so the GitHub landing page stays readable while the detailed rule index can grow with the project.
Rule Categories
StyleSharp (SST####)
Spacingfor token and whitespace conventionsReadabilityfor query layout, unique-line lists, tuple/null/style conventions, expression simplification, redundant-code removal, and similar readability rulesOrderingfor using ordering, modifier ordering, accessor ordering, and member orderingLayoutfor brace placement, blank-line rules, and block consistencyNamingfor .NET naming conventions, async-method suffixes, and override parameter namesMaintainabilityfor access modifiers, precedence, auto-properties, nameof, trailing commas, redundant modifiers, exception handling, type design, and related rulesDocumentationfor XML docs, file headers, and documentation quality rulesExtensionsfor C# 14 extension-block conventionsRecordsfor record and record-struct conventionsConcurrencyfor lock-target safety rulesModernizationfor runtime throw-helper adoption and pattern-matching formsCollectionExpressionsfor collection-expression usageModernSyntaxfor new language features such as the C# 14fieldkeyword
PerformanceSharp (PSH####)
Allocations(PSH10xx) for closure/delegate allocations, throwaway empty arrays, and empty finalizersCollections(PSH11xx) for LINQ on hot paths, redundant iterator layers, O(1) count/indexer alternatives, and repeated dictionary/set lookupsStrings(PSH12xx) for case-conversion comparison allocations, char overloads, andStringBuilderpatternsConcurrency(PSH13xx) forSystem.Threading.Lockadoption and async/concurrency perf patternsApiSelection(PSH14xx) for cheaper framework APIs such as one-shotHashData
Rules whose primary motivation is runtime performance live in PerformanceSharp; rules about style and consistency live in StyleSharp. Unless a rule is marked opt-in, it is enabled by default at Warning severity.
Configuration
Both packages are configured entirely through .editorconfig. Severity uses the standard dotnet_diagnostic.<RuleId>.severity keys, and rule options use the compiler-provided analyzer config system with a per-package prefix (stylesharp. / performancesharp.).
[*.cs]
dotnet_diagnostic.SST1309.severity = warning
stylesharp.tuple_element_naming = pascal_case
dotnet_diagnostic.PSH1100.severity = warning
performancesharp.avoid_linq_on_hot_path = true
See docs/CONFIGURATION.md for the full option list and the recommended configuration approach.
Repository Layout
| Project | Purpose |
|---|---|
src/StyleSharp.Analyzers / src/PerformanceSharp.Analyzers |
analyzer implementations |
src/StyleSharp.Analyzers.CodeFixes / src/PerformanceSharp.Analyzers.CodeFixes |
code-fix implementations |
src/StyleSharp.Analyzers.Package / src/PerformanceSharp.Analyzers.Package |
NuGet packaging |
src/tests/* |
TUnit + Microsoft.CodeAnalysis.Testing test suites |
src/benchmarks/* |
BenchmarkDotNet perf harnesses |
Building And Testing
Run these commands from src/:
dotnet build RoslynCommonAnalyzers.slnx -c Release
dotnet test --project tests/StyleSharp.Analyzers.Tests/StyleSharp.Analyzers.Tests.csproj -c Release
dotnet test --project tests/PerformanceSharp.Analyzers.Tests/PerformanceSharp.Analyzers.Tests.csproj -c Release
To pack every Roslyn slot into the published NuGet packages:
dotnet pack StyleSharp.Analyzers.Package/StyleSharp.Analyzers.Packages.csproj -c Release
dotnet pack PerformanceSharp.Analyzers.Package/PerformanceSharp.Analyzers.Packages.csproj -c Release
Contributing
Issues and pull requests are welcome.
When adding a rule, update all of the following (in whichever package the rule belongs to):
- analyzer implementation
- code-fix implementation if the rule is fixable
- tests
docs/rules/SST####.mdordocs/rules/PSH####.md- that package's
AnalyzerReleases.Unshipped.md - the matching preset (
recommended.editorconfig/recommended-performancesharp.editorconfig) if the rule should appear there
Performance is a first-class requirement. Read docs/PERFORMANCE.md before changing analyzer hot paths, and benchmark changes rather than guessing.
License
MIT — see LICENSE.
Acknowledgements
The analyzers and code fixes here are written from scratch. No source code was copied from the projects below. License references are included in LICENSE where applicable.
- StyleCop.Analyzers, licensed under the MIT License, inspired the original shape of the project. Thanks to Sam Harwell and the StyleCop.Analyzers contributors.
- Roslynator, licensed under the Apache License 2.0, inspired some diagnostic design choices. Thanks to Josef Pihrt and the Roslynator contributors.
- The .NET SDK analyzer guidance and dotnet/roslyn, licensed under the MIT License, inspired parts of the style-rule coverage. Thanks to the .NET and Roslyn teams.
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
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 |
|---|---|---|
| 3.16.7 | 50 | 7/6/2026 |
| 3.16.6 | 44 | 7/6/2026 |
| 3.16.5 | 47 | 7/6/2026 |
| 3.16.4 | 38 | 7/6/2026 |
| 3.16.3 | 53 | 7/6/2026 |
| 3.16.2 | 78 | 7/5/2026 |
| 3.16.1 | 42 | 7/5/2026 |
| 3.16.0 | 90 | 7/5/2026 |
| 3.15.2 | 44 | 7/5/2026 |
| 3.15.1 | 45 | 7/5/2026 |
| 3.15.0 | 49 | 7/5/2026 |
| 3.14.0 | 119 | 7/4/2026 |
| 3.13.4 | 1,288 | 6/23/2026 |
| 3.13.3 | 146 | 6/23/2026 |
| 3.13.2 | 132 | 6/23/2026 |
| 3.13.1 | 117 | 6/23/2026 |
| 3.13.0 | 144 | 6/22/2026 |
| 3.12.14 | 347 | 6/22/2026 |
| 3.12.13 | 116 | 6/22/2026 |
| 3.12.12 | 114 | 6/22/2026 |