Move to Allman, and let CSharpier hold it - #62
Merged
Merged
Conversation
The braces move from K&R to Allman, which is what the .NET ecosystem and every Microsoft template use, and is the one thing CSharpier does not offer a choice about. Taking its whole layout rather than a brace-only rewrite is what makes the style checkable instead of a review topic. The version is pinned in the tool manifest so a clone and CI agree on what formatted means. Project files are excluded. CSharpier reindents MSBuild XML to two spaces but leaves the interior of multi-line comments at its old indentation, and this repo's csproj comments are long enough that every one of them would come out hanging. No behaviour change: the solution builds and all 2258 tests pass before and after. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The formatter only holds if something runs it. The pre-commit hook is the fast answer and the CI step is the guarantee, since a hook lives in a clone and --no-verify skips it. .editorconfig repeats the same layout for the IDE. Without it Rider and Visual Studio format to their own defaults as you type, and the next commit undoes it. .git-blame-ignore-revs keeps the reformat from claiming the last change to every line. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
CSharpier does not reach these: a sample in a ``` fence is prose, and one in a <code>
block is a comment. They were the last K&R left outside the generator tests.
Brace placement only, rather than running the samples through CSharpier. It agrees on
every brace, and disagrees on much else a doc sample decides deliberately: it collapses
the fluent chain in the README onto one line, squashes comments that are aligned to be
read down the column, and expands a one-line `interface IEmailSender { void Send(); }`
into four. Checked by extracting all 227 fences and diffing against CSharpier's own
output, which now differs on no brace.
The generator tests keep theirs. Those samples are C# in a string, fed to Roslyn to
compile; several tests assert on the line and column a diagnostic lands at.
Co-Authored-By: Claude Opus 5 (1M context) <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.
K&R goes, Allman arrives, and a formatter decides it from here rather than review. Allman is what the .NET templates emit and what every C# codebase around this one uses, and it is the one thing CSharpier offers no choice about, so taking its whole layout is what makes the style checkable.
Three commits, meant to be read in order:
79a2881reformats all 313 C# files. Machine-generated, no behaviour change.9cc0bbaadds the enforcement: the pinned tool, a pre-commit hook, a CI step,.editorconfig,CONTRIBUTING.md.51a3ecbmoves the code samples in the docs, which CSharpier cannot reach.Reviewing this is mostly reviewing the second commit. The first is large and uninteresting;
.git-blame-ignore-revslists it sogit blamekeeps pointing at whoever actually wrote each line, and GitHub reads that file without being asked.One step per clone
Git does not install hooks on clone, so this cannot be automated. The hook is the fast answer and
--no-verifyskips it, which is whybuild-package.yamlrunsdotnet csharpier check .on every pull request. That step is what actually holds the formatting.Three things deliberately left alone
Project files. CSharpier 1.x formats MSBuild XML too, but it reindents to two spaces while leaving the interior of multi-line comments where it was. Every commented csproj here came out with hanging comment bodies, so
.csharpierignoreexcludes*.csproj,*.propsand*.targets.The generator test fixtures, 491 lines across 30 files. That is C# inside string literals, handed to Roslyn to compile, and several tests assert on the line and column a diagnostic lands at. Reformatting it would move the thing under test.
Everything about a doc sample except its braces. The third commit moves braces only rather than running the samples through CSharpier. CSharpier agrees on every brace and disagrees on plenty a sample decides on purpose: it collapses the fluent chain in the README onto one line, squashes comments aligned to be read down a column, and expands a one-line
interface IEmailSender { void Send(string to); }into four. Verified by extracting all 227 fences and diffing against CSharpier's own output, which now differs on no brace.Checked
Solution builds, 2258 tests pass on net8.0 and net10.0,
dotnet csharpier check .is clean, and the VitePress site builds. The hook was tested on both paths, including a path with a space in it.🤖 Generated with Claude Code