Repository navigation
Set up CSharpier formatting with pre-push hook and CI check - #3781
Merged
Merged
Conversation
- Pin csharpier 1.4.0 and husky 0.9.1 as local dotnet tools. - Add a Husky.Net pre-push hook that runs `dotnet csharpier check .`, installed by an MSBuild target in PuppeteerSharp.csproj (skipped when CI=true, HUSKY=0, or there is no .git). - Add a csharpier check job to the build workflow and limit the existing dotnet format step to the style and analyzers passes. - Document the formatting rules in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls2e1y2tkZNP6dfy8F5GTF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls2e1y2tkZNP6dfy8F5GTF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls2e1y2tkZNP6dfy8F5GTF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls2e1y2tkZNP6dfy8F5GTF
|
Important Review skippedToo many files! This PR contains 597 files, which is 297 over the limit of 300. To get a review, reduce the PR to 300 files or fewer by splitting it into smaller PRs or changing its base branch. Usage-priced reviews support at most 300 files.
|
- Turn off the StyleCop layout rules that CSharpier's output breaks (SA1003, SA1009, SA1111, SA1118, SA1500, SA1501, SA1502, SA1504, SA1513, SA1515, SA1516) and document them in CLAUDE.md. - Limit the PreBuild `dotnet format` target in CommonProps.props to the style and analyzers passes; its whitespace pass rewrote CSharpier's layout during builds and left merge conflict markers in multi-target builds. - Remove the double blank line in Browser.cs (SA1507, csharpier check). - Move the CA2000 pragma out of the CdpElementHandle constructor parameter list (SA1116). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls2e1y2tkZNP6dfy8F5GTF
This was referenced Nov 19, 2026
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.
Summary
Sets up CSharpier as the formatter for the repo, with a pre-push hook and a CI check.
What was added
.config/dotnet-tools.json):csharpier1.4.0 andhusky(Husky.Net) 0.9.1. Rundotnet tool restoreto get them..csharpierignore: skipswwwroottest fixtures,docfx_project/,docs-site/, and build output. No.csharpierrc.json, because the repo has no line-width setting, so CSharpier's default (100) applies..husky/pre-push+.husky/task-runner.json): runsdotnet csharpier check .and blocks the push if anything is unformatted.csharpier checkjob in.github/workflows/dotnet.yml(dotnet tool restore+dotnet csharpier check .). The existingdotnet formatstep now runs onlydotnet format styleanddotnet format analyzers(still with--exclude-diagnostics CA1865). Its whitespace pass is dropped because it fights CSharpier.dotnet csharpier format .before every commit/push, and never rundotnet format whitespaceor a plaindotnet format.How the pre-push hook gets installed
A
HuskyMSBuild target inlib/PuppeteerSharp/PuppeteerSharp.csprojrunsdotnet tool restore && dotnet husky installfrom the repo root on restore/build. So building the solution once installs the hook (core.hooksPath=.husky). The target is skipped whenCI=true, whenHUSKY=0, or when there is no.git(for example, a source tarball).Build-time
dotnet formatlib/Common/CommonProps.propshas aPreBuildtarget that ran a plaindotnet formaton every build. Its whitespace pass rewrote CSharpier's layout, and in the multi-target build it left merge conflict markers in the sources (this broke the Demo Project build). The target now runs onlydotnet format styleanddotnet format analyzers, like CI.Analyzer rules turned off because of CSharpier
CSharpier's output breaks these StyleCop layout rules, so
lib/.editorconfigsets them tonone, with a comment. They are also listed in CLAUDE.md:Two errors were fixed at the source instead:
Browser.cs.#pragmaout of theCdpElementHandleconstructor's parameter list.Formatting commit and blame
264479f"Format codebase with CSharpier" contains only the output ofdotnet csharpier format .(568.cs, 13.csproj, 2.props, 4.configfiles). A temporary workflow generated it in GitHub Actions; that workflow is removed in the next commit..git-blame-ignore-revslists that SHA. GitHub applies it automatically. Locally, rungit config blame.ignoreRevsFile .git-blame-ignore-revs.005ba51"Docs changes" comes from the repo'son-push-do-docsworkflow (mdsnippets refreshed the README and docs snippets from the reformatted samples).Please merge with a merge commit or a rebase merge, not a squash. A squash would change the SHA of the formatting commit, and
.git-blame-ignore-revswould no longer match.https://claude.ai/code/session_01Ls2e1y2tkZNP6dfy8F5GTF
Generated by Claude Code