CSharpStyleChecker 3.1.0
dotnet add package CSharpStyleChecker --version 3.1.0
NuGet\Install-Package CSharpStyleChecker -Version 3.1.0
<PackageReference Include="CSharpStyleChecker" Version="3.1.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="CSharpStyleChecker" Version="3.1.0" />
<PackageReference Include="CSharpStyleChecker"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add CSharpStyleChecker --version 3.1.0
#r "nuget: CSharpStyleChecker, 3.1.0"
#:package CSharpStyleChecker@3.1.0
#addin nuget:?package=CSharpStyleChecker&version=3.1.0
#tool nuget:?package=CSharpStyleChecker&version=3.1.0
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;whereclauses) 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:),#ifdisabled text,#linefiles, empty()lists, broken syntax, and unshrinkable lines are left untouched soCSC001reports 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.
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.