Apply curb formatting to entire codebase - #3905
Open
Mpdreamz wants to merge 2 commits into
Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
theletterf
approved these changes
Aug 20, 2026
4 tasks
Without end_of_line = lf, git autocrlf on Windows converts LF→CRLF on checkout, causing curb to flag files as unformatted in Release mode. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Approved — no actionable issues found.
What is this? | From workflow: PR Review
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
Mpdreamz
added a commit
to nullean/curb
that referenced
this pull request
Aug 20, 2026
…oreCase (#53) ## Summary - `elastic/docs-builder#3905` found that Curb and `dotnet format` disagree on using-directive sort order for a namespace with an underscore-prefixed segment (`Elastic.ApiExplorer._Partials.Layout`), and had to fix the ordering by hand in one test file after running `dotnet curb format .`. - Root cause: `UsingOrganiser.Compare` case-folded names via `StringComparison.OrdinalIgnoreCase`, which folds to **upper** case internally. That leaves `_` (0x5F) above every letter, so `_Partials` sorts after `Infrastructure`. `dotnet format`'s own sort folds to **lower** case, where `_` (0x5F) sits below `i` (0x69), so it sorts `_Partials` before `Infrastructure` — the opposite order. - Verified directly: `string.Compare("_Partials", "Infrastructure", StringComparison.OrdinalIgnoreCase)` returns positive (wrong direction); lower-casing both first and comparing ordinally returns negative (matches `dotnet format`). - Fix: fold with `.ToLowerInvariant()` + `string.CompareOrdinal` instead of `StringComparison.OrdinalIgnoreCase`. The existing case-sensitive ordinal tie-break is unchanged, and the fix preserves the original motivating case (`Microsoft.CodeAnalysis.CSharp.CodeStyle` sorting after `Microsoft.CodeAnalysis.CodeStyle` — verified by hand with the same test harness). ## Test plan - [x] Added `An_underscore_prefixed_segment_sorts_before_a_capitalised_one` to `UsingOrderTests.cs`, reproducing the exact docs-builder namespace shape. - [x] Full test suite (`dotnet run --project tests/Nullean.Curb.Tests -c Release`): 1134 succeeded, 0 failed, 5 pre-existing skips. - [x] `./build.sh conformance --corpus <elastic/docs-builder checkout>`: 1201/1201 files (100.00%) — confirms the fix, applied to the actual repository that surfaced this, needs no further manual correction. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015byCT9ghPLnCK3QZf5wNPD Co-authored-by: mpdreamz <mpdreamz@cosmolino.home> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #3904 — merge that first.
What is curb?
curb is a new C# formatting tool built by nullean. It reads your existing
.editorconfig— both standard .NET keys (dotnet_*, IDE0055) and ReSharper keys (resharper_*) — and formats your code without loading the MSBuild workspace. No project restore, no Roslyn workspace hydration, just the formatter.Speed comparison on this repo (1 201 files):
dotnet curb format .dotnet curb check .dotnet format whitespacedotnet format(full)The pre-commit hook warmup cost is effectively zero in practice — by the time you commit,
dotnet buildhas already run curb in Debug mode and cached the result. The check pass on commit is burning through the cache, not re-reading the world.How it works
Instead of a tool you run, think of it as a formatter that already ran. When you
dotnet buildin Debug mode, curb reformats any file that's out of style before the compiler ever sees it. By the time compilation happens, style is already applied. The only thing left for you to think about is logic.In Release/CI mode it flips to read-only: instead of rewriting, it errors with
CURB0001if any file would change. That's the signal CI uses. The lint job just runsdotnet curb check .— no workspace load, no project restore.curb cleanupis worth knowing about: after a build that failed on standard diagnostics (unused usings, redundant modifiers, etc.) curb can apply those fixes in ~15ms by reading the SARIF output the last build already wrote, without loading the workspace at all. Add--forwardto pass the remainder todotnet format style.This PR
Three commits on top of #3904:
dotnet curb format .— 886 of 1 201 files reformatted with the new.editorconfigsettings from Migrate formatting toolchain from dotnet format to curb #3904 (line length 160→140, chained method/binary expression wrapping, binary operators lead lines)dotnet formatdiffer on sort order for_-prefixed namespacesend_of_line = lffor*.cs— without this, Windows git autocrlf converts LF→CRLF on checkout and curb's Release-mode check flags every filePure mechanical reformat, no logic changes. Best reviewed with whitespace hidden (
?w=1in the URL).Test plan
./build.sh lintpasses with 0 violations on all platforms./build.sh unit-testgreen