CSharpStyleChecker 3.1.0

dotnet add package CSharpStyleChecker --version 3.1.0
                    
NuGet\Install-Package CSharpStyleChecker -Version 3.1.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="CSharpStyleChecker" Version="3.1.0">
  <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="CSharpStyleChecker" Version="3.1.0" />
                    
Directory.Packages.props
<PackageReference Include="CSharpStyleChecker">
  <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 CSharpStyleChecker --version 3.1.0
                    
#r "nuget: CSharpStyleChecker, 3.1.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 CSharpStyleChecker@3.1.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=CSharpStyleChecker&version=3.1.0
                    
Install as a Cake Addin
#tool nuget:?package=CSharpStyleChecker&version=3.1.0
                    
Install as a Cake Tool

CSharpStyleChecker

Roslyn analyzer and CSC001 line-length formatter that enforce the C# style of CopilotAIWorkflow as compiler errors (CSC001–CSC009). Add it as a development dependency:

<PackageReference Include="CSharpStyleChecker" Version="3.*" />

Rebuild. Violations surface as compiler errors. The analyzers and the CSC001 code-fix provider load from analyzers/dotnet/cs and bundle CSharpStyleChecker.CodeFixes.dll and ExitPoints.dll; no second package and no PrivateAssets are needed. The checker applies to the referencing project only; it does not flow to downstream projects.

Automatic line-length formatting (3.1.0+)

3.1.0 includes a built-in Roslyn CodeFixProvider and multi-pass FixAllProvider for CSC001. Apply it from the CLI or IDE code actions with no second formatter package:

dotnet restore App.csproj
dotnet format analyzers App.csproj --no-restore --diagnostics CSC001
dotnet build App.csproj -c Release --no-restore
  • Wraps overlong C# code constructs (argument, parameter, attribute, tuple, and initializer lists; member/null-conditional chains; binary and ?? operators; ?: and Allman switch expressions; assignments; =>; base lists; where clauses) and standalone // / /// prose comments to the configured visible width.
  • Every edit passes fail-closed AST, token, XML-documentation (DocumentationMode.Diagnose), directive, and comment-word equivalence validation before replacing text.
  • Masked string literals, interpolation holes, /* … */ block comments, trailing // comments on short code lines, structured XML blocks (<code>, tables, lists, Sync:), #if disabled text, #line files, empty () lists, broken syntax, and unshrinkable lines are left untouched so CSC001 reports only what requires manual reflow.

2.0.1 supports top-level statements under CSC003, including .NET 10 file-based apps.

With 3.0.1, CSC009 accepts long messages split across lines inside a single InvariantStringHelper call. Prefix each segment with $ so the compiler formats them with one invariant handler.

string message = Invariant(
    $"Order {orderId}. "
    + $"Total {total:F2}.");

CSC001 allows 120 visible characters by default. To override the width (for example to keep the 2.x limit), set it in .editorconfig:

[*.cs]
build_property.csc_max_line_length = 130

Rule reference: README — CSharpStyleChecker. Changes: CHANGELOG.

Requirements

SDK-style netstandard2.0+ or .NET Core App project; .NET SDK 9.0.300+ or Visual Studio 2022 17.14+ (Roslyn 4.14).

Migration

Deprecated Use instead
PackageReference CSharpStyleValidator CSharpStyleChecker
Analyzer IDs CSV001–CSV008 CSC001–CSC008

License

MIT. See LICENSE.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CSharpStyleChecker:

Package Downloads
ZeroAlloc

Zero-allocation string formatting and binary serialization library with Roslyn source generators. Features: compile-time optimized ZA.String() and ZA.Bytes() APIs, endian-aware wrappers (U16BE, I32LE, etc.), VarInt encoding, length-prefixed string encodings, and generated binary parsers. Perfect for network protocols, CAN/FlexRay, embedded systems, and high-performance logging. Requires .NET 10+.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.1.0 80 11/28/2026
3.0.1 96 11/25/2026
3.0.0 93 11/24/2026
2.0.1 95 11/22/2026
2.0.0 116 11/10/2026
1.2.0 115 11/5/2026
1.1.0 136 10/9/2026
1.0.1 955 7/13/2026
1.0.0 690 7/8/2026