Skip to content

Set up CSharpier with a pre-push hook and CI check - #1707

Open
kblok wants to merge 6 commits into
mainfrom
chore/csharpier
Open

kblok wants to merge 6 commits into
mainfrom
chore/csharpier

Conversation

@kblok

@kblok kblok commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Sets up CSharpier for the repo, with a pre-push hook and a CI check.

What was added

  • dotnet-tools.json (repo root, where the .NET 11 SDK's dotnet new tool-manifest puts it): local tools csharpier 1.4.0 and husky (Husky.Net) 0.9.1.
  • .csharpierrc.json: printWidth: 120. The code already runs past 100 columns: about 5% of lines are over 137 characters, and the existing comments wrap near 120. No .csharpierignore, because there is no generated or vendored C#. CSharpier skips bin/, obj/ and gitignored files by default.
  • .husky/: a pre-push hook that runs the pre-push task group from task-runner.json. That group runs dotnet csharpier check ., so a push with unformatted files fails.
  • CI (ci.yml): a new csharpier job runs dotnet tool restore and dotnet csharpier check . on pull requests and on pushes to main.
  • CI Format step: now runs dotnet format style and dotnet format analyzers instead of the full dotnet format. The whitespace pass of dotnet format conflicts with CSharpier's layout: it reported WHITESPACE errors on the formatted code. CSharpier now owns whitespace. Style and analyzer checks are unchanged.
  • CONTRIBUTING.md: a short section on formatting, the hook, and the blame-ignore file.
  • CLAUDE.md: a new first bullet under "Before you push". CSharpier owns formatting: run dotnet csharpier format . before every commit or push. The pre-push hook blocks unformatted pushes. Use only dotnet format style and dotnet format analyzers, never dotnet format whitespace or a plain dotnet format.

How the pre-push hook gets installed

src/E2E/E2E.csproj has a Husky MSBuild target, the one Husky.Net recommends. It runs before Restore;CollectPackageReferences and calls dotnet tool restore, then dotnet husky install, which sets core.hooksPath to .husky. Every project references E2E, so any restore or build installs the hook. The target is skipped when:

  • CI is true (GitHub Actions sets it),
  • there is no .git at the repo root (source archives, for example),
  • HUSKY=0 is set (the opt-out).

To install the hook by hand, run dotnet tool restore, then dotnet husky install.

Commits and .git-blame-ignore-revs

  • e6850c0: tooling, hook, CI, and docs.
  • eaacd7b Format codebase with CSharpier: only the output of dotnet csharpier format . (1,586 .cs, 5 .xaml, 2 .xml, 2 .csproj).
  • 962a9fb adds .git-blame-ignore-revs with eaacd7b. GitHub uses it automatically. Locally, run git config blame.ignoreRevsFile .git-blame-ignore-revs.
  • 879d477 adds the CSharpier rules to CLAUDE.md.
  • 9a0f2eb updates the GreetingTests.cs excerpt in skills/e2e-dotnet/references/mobile.md to match the formatted sample. TheMobileReferenceTests checks that the excerpt appears in the sample line by line. CSharpier reflowed the ActAsync call there, so the test failed on the first CI run.

Please merge with a merge commit or a rebase merge, not a squash. A squash merge changes the format commit's SHA, and the entry in .git-blame-ignore-revs would then point at nothing.

Analyzer rules

None disabled. After formatting, dotnet build E2E.slnx -c Release (with TreatWarningsAsErrors and EnforceCodeStyleInBuild) passed with 0 warnings and 0 errors. dotnet format style and dotnet format analyzers with --verify-no-changes also passed. The only conflict is the dotnet format whitespace pass, which is handled above.

Verification notes

The sandbox this PR came from had no access to NuGet or the .NET SDK downloads. So the tool install, the formatting, and the build ran on GitHub Actions, on throwaway branches tmp/csharpier-bootstrap and tmp/csharpier-formatted. The workflow only ever ran on those branches. Its formatted commit was then cherry-picked here unchanged. On that runner:

  • dotnet csharpier check . passed (1,841 files).
  • The Release build of E2E.slnx passed.
  • A restore with CI unset ran the Husky target, which created .husky/_/husky.sh and set core.hooksPath=.husky.

Tests: the full CI suite runs on this PR. Its first run caught the excerpt mismatch that 9a0f2eb fixes.

Not run:

  • The real-model tests. Per CLAUDE.md they are skipped for config-only changes.
  • /code-review. It was not available in that session.

To clean up:

  • The proxy refused to delete the two tmp/ branches. Please delete them.
  • The Windows-only apps/WinAppBenchmark (where the .xaml changes are) is checked by the windows-build-test job on this PR.

https://claude.ai/code/session_01Ls2e1y2tkZNP6dfy8F5GTF


Generated by Claude Code

Adds CSharpier 1.4.0 and Husky.Net 0.9.1 as local tools, a pre-push hook
that runs `dotnet csharpier check .`, an MSBuild target that installs the
hook on restore (skipped in CI), and a csharpier job in CI. `dotnet format`
in CI now checks only style and analyzers, since CSharpier owns whitespace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls2e1y2tkZNP6dfy8F5GTF
Runs `dotnet csharpier format .` (CSharpier 1.4.0, printWidth 120) on the
whole repository. No other changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls2e1y2tkZNP6dfy8F5GTF
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Warning

Review details and warnings were omitted to fit the comment limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls2e1y2tkZNP6dfy8F5GTF
TheMobileReferenceTests checks that the GreetingTests.cs excerpt in
skills/e2e-dotnet/references/mobile.md appears line by line in the sample.
CSharpier reflowed the ActAsync call in the sample, so the excerpt now
quotes the formatted code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls2e1y2tkZNP6dfy8F5GTF
@kblok

kblok commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts on this branch.

# Conflicts:
#	src/E2E/Agent/Act.cs
#	src/E2E/Agent/Agent.cs
#	src/E2E/Cache/Context.cs
#	src/E2E/Core/Launch.cs
#	src/E2E/Run/E2ESession.cs
#	tests/E2E.Tests/Core/CoreTests.cs

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts on this branch.

Resolved in merge commit f469fbc. CSharpier and the focused core and mobile-reference tests pass. The real-model suite was attempted and failures retried, but remains blocked by missing Copilot login, unreachable sample sites, platform requirements, and a TUnit test-runner incompatibility.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants