StyleSharp.Analyzers 3.16.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package StyleSharp.Analyzers --version 3.16.2
                    
NuGet\Install-Package StyleSharp.Analyzers -Version 3.16.2
                    
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="StyleSharp.Analyzers" Version="3.16.2">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StyleSharp.Analyzers" Version="3.16.2" />
                    
Directory.Packages.props
<PackageReference Include="StyleSharp.Analyzers">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 StyleSharp.Analyzers --version 3.16.2
                    
#r "nuget: StyleSharp.Analyzers, 3.16.2"
                    
#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 StyleSharp.Analyzers@3.16.2
                    
#: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=StyleSharp.Analyzers&version=3.16.2
                    
Install as a Cake Addin
#tool nuget:?package=StyleSharp.Analyzers&version=3.16.2
                    
Install as a Cake Tool

CI Build Coverage Reliability Rating Duplicated Lines (%) Vulnerabilities Security Rating NuGet Downloads NuGet Downloads GitHub stars License: MIT

<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

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####)

  • Spacing for token and whitespace conventions
  • Readability for query layout, unique-line lists, tuple/null/style conventions, expression simplification, redundant-code removal, and similar readability rules
  • Ordering for using ordering, modifier ordering, accessor ordering, and member ordering
  • Layout for brace placement, blank-line rules, and block consistency
  • Naming for .NET naming conventions, async-method suffixes, and override parameter names
  • Maintainability for access modifiers, precedence, auto-properties, nameof, trailing commas, redundant modifiers, exception handling, type design, and related rules
  • Documentation for XML docs, file headers, and documentation quality rules
  • Extensions for C# 14 extension-block conventions
  • Records for record and record-struct conventions
  • Concurrency for lock-target safety rules
  • Modernization for runtime throw-helper adoption and pattern-matching forms
  • CollectionExpressions for collection-expression usage
  • ModernSyntax for new language features such as the C# 14 field keyword

PerformanceSharp (PSH####)

  • Allocations (PSH10xx) for closure/delegate allocations, throwaway empty arrays, and empty finalizers
  • Collections (PSH11xx) for LINQ on hot paths, redundant iterator layers, O(1) count/indexer alternatives, and repeated dictionary/set lookups
  • Strings (PSH12xx) for case-conversion comparison allocations, char overloads, and StringBuilder patterns
  • Concurrency (PSH13xx) for System.Threading.Lock adoption and async/concurrency perf patterns
  • ApiSelection (PSH14xx) for cheaper framework APIs such as one-shot HashData

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####.md or docs/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.
There are no supported framework assets in this package.

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
Loading failed