syntax + code-style · C# · .NET 10

C# style enforcement
on every build.

A C# formatter built into dotnet build. It reads the .editorconfig you already have, agrees with dotnet format and your IDE, and fixes the mechanical work before the compiler reads a line. Formatting just happens.

nuget ↗
nuget ↗
dotnet build
$ dotnet build
 
curb formatted 47 files · verified 47
  braces, wrapping, spacing, usings — fixed
 
csc  Order.cs(31,9): info IDE0007:
      Use 'var' instead of explicit type
 
Build succeeded
 
# the mechanical work is gone before
# the compiler reads a line. what is
# left needed a compilation to decide.
$


One package.
Then never think about it.

Curb runs before CoreCompile, so the compiler reads source that is already formatted. The mechanical offences are not reported — they are gone.

01
Use the .editorconfig you already have

No second config file. Add max_line_length when you want reflow; leave it out and Curb will never wrap a line for you.

02
Add the build package

Build-only — no library, nothing in your output. Drop it in Directory.Build.props to cover a whole solution.

03
Run dotnet build

Files are rewritten in Debug and checked in Release. A developer wants the fix; CI wants to be told. An untouched project pays nothing: no process start, no directory walk.

.editorconfig
[*.cs]
indent_style = tab
max_line_length = 120          # opt into reflow
csharp_new_line_before_open_brace = all
csharp_prefer_braces = true
csharp_style_namespace_declarations = file_scoped
Directory.Build.props
<PackageReference Include="curb"
                  Version="*" PrivateAssets="all" />

Rewriting code unattended is only reasonable if it cannot go wrong. Every file is verified in memory before anything is written — the tokens emitted must match the tokens parsed — and a file that fails is reported and left exactly as it was. Syntax Curb has not learned yet is emitted verbatim, so it is incomplete long before it is ever destructive. How it is checked →


Fast enough that
skipping it makes no sense.

Newtonsoft.Json — 945 files, no .editorconfig. Wall-clock time, best of three runs.

0.26 s
Curb
3.47 s
dotnet format whitespace
4.85 s
CSharpier (cold — no prior cache)

Curb ships as a native-AOT binary — about 10 ms to start, no warm-up cost. MSBuild skips it entirely when the project is untouched: no process start, no directory walk. Full benchmark table →


Two passes.
One build.

Style rules split by what they need to know. The split is not an implementation detail — it is why Curb can run before the compiler and still leave nothing for dotnet format to do afterwards.

pass 1 · before compile

Layout

Decided from the parse tree alone. No restore, no compilation, no project system — runs before CoreCompile, rewrites the file, and the compiler reads formatted source.

  • Indentation, spacing, brace placement, blank lines
  • Reflow to max_line_length
  • Braces, expression bodies, file-scoped namespaces
  • Modifier order, using directives, file headers
97 options →
pass 2 · after compile

Code-style fixes

Runs on the diagnostics the compiler already reported. Applies fixes the build already knows how to make — no extra analysis step, no separate command to remember.

  • Redundant parentheses (IDE0047 / IDE0048)
  • Unnecessary casts and type annotations
  • Object and collection initialiser style
  • Anything with a Roslyn code fix and a severity in .editorconfig
curb cleanup →

Style enforcement that costs no context.

Style rules written as prose in an AGENTS.md get followed inconsistently, and every correction is a round trip: the agent writes, the build complains, the agent edits, the build runs again. Every one of those edits is mechanical — there was one right answer, and it was already in your .editorconfig.

Put the rules where they belong and let the build apply them. The agent never sees the mechanical offences, never spends a token on them, and never has to be told about them. What reaches it is the part that needed judgement.

AGENTS.md — the whole style section
## Style

Formatting and syntax-level code style are
applied automatically by the build — see
.editorconfig.

Do not hand-format code, and do not "fix"
formatting you see in a diff.
dotnet build will do it.

One package reference.

The .editorconfig you already have. Nothing new to learn.
Nothing to remember to run. Just dotnet build.