Skip to content

feat(#115): Run dotnet format to fix existing code to match .editorconfig#128

Merged
LeeCampbell merged 9 commits intoHdrHistogram:mainfrom
leecampbell-codeagent:agent/115-run-dotnet-format-to-fix-existing-code-t
Mar 1, 2026
Merged

feat(#115): Run dotnet format to fix existing code to match .editorconfig#128
LeeCampbell merged 9 commits intoHdrHistogram:mainfrom
leecampbell-codeagent:agent/115-run-dotnet-format-to-fix-existing-code-t

Conversation

@leecampbell-codeagent
Copy link
Copy Markdown
Collaborator

Issue #115: Run dotnet format to fix existing code to match .editorconfig

Summary

The .editorconfig file was introduced in issue #114 (commit 14b962b).
Existing source code predates these conventions and does not yet conform to them.
This issue is a one-time bulk reformatting pass using dotnet format whitespace to bring all files into alignment.
The change must be isolated in its own commit so that git blame --ignore-rev can skip it.

What Needs to Change and Why

Running dotnet format --verify-no-changes HdrHistogram.sln on the current branch reports 346 formatting violations across 101 files:

  • 213 ENDOFLINE violations — files using CRLF line endings instead of LF (end_of_line = lf in .editorconfig)
  • 78 FINALNEWLINE violations — files that do not end with a newline character (insert_final_newline = true in .editorconfig)
  • 47 CHARSET violations — files with character-encoding issues (e.g. byte-order marks)
  • 8 WHITESPACE violations — indentation issues in HdrHistogram/Utilities/Bitwise.cs (lines 43–55)

The changes are purely cosmetic (whitespace, line endings, and newlines).
No logic, API surface, or behaviour is altered.

Affected Files

The repository contains 123 .cs files across four projects, of which 101 have at least one violation:

  • HdrHistogram/ — 56 .cs source files (main library)
  • HdrHistogram.UnitTests/ — 34 .cs test files
  • HdrHistogram.Examples/ — 6 .cs example files
  • HdrHistogram.Benchmarking/ — 27 .cs benchmark files

The authoritative list of affected files comes from dotnet format --verify-no-changes HdrHistogram.sln output.

The file with the most substantive changes is:

  • HdrHistogram/Utilities/Bitwise.cs — 8 whitespace/indentation fixes

All other files require only line-ending normalisation and/or a trailing newline added at end-of-file.

Acceptance Criteria

  • dotnet format --verify-no-changes HdrHistogram.sln exits with code 0 after the fix is applied
  • dotnet build HdrHistogram.sln succeeds with no errors or warnings introduced by this change
  • All unit tests pass (dotnet test HdrHistogram.sln)
  • No functional code changes — diffs contain only whitespace, line-ending, and newline additions
  • A .git-blame-ignore-revs file is created at the repo root containing the SHA of the formatting commit
  • The commit message is chore: apply dotnet format to match .editorconfig

Test Strategy

No new tests are required — this is a pure formatting change.
Existing tests must continue to pass without modification.

Verification steps:

  1. Run dotnet format --verify-no-changes HdrHistogram.sln — must exit 0
  2. Run dotnet build HdrHistogram.sln — must succeed
  3. Run dotnet test HdrHistogram.sln — all tests must pass
  4. Inspect the diff with git diff before committing — confirm only whitespace/newline changes

Implementation Steps

  1. Run dotnet format whitespace HdrHistogram.sln to apply all whitespace fixes automatically
  2. Verify with dotnet format --verify-no-changes HdrHistogram.sln
  3. Run dotnet build HdrHistogram.sln to confirm build is clean
  4. Run dotnet test HdrHistogram.sln to confirm tests pass
  5. Commit with message: chore: apply dotnet format to match .editorconfig
  6. Record the commit SHA and create .git-blame-ignore-revs with that SHA
  7. Commit .git-blame-ignore-revs in the same PR
  8. Open a PR against main

Risks and Open Questions

  • Risk: The dotnet format command without a sub-command invokes all three fixers: whitespace, style, and analyzers.
    The .editorconfig contains Roslyn naming-convention rules at suggestion severity; by default dotnet format style only applies rules at warning severity or above, so naming rules would not be auto-applied.
    Mitigation: use dotnet format whitespace HdrHistogram.sln explicitly to limit the scope to whitespace-only fixes and remove all ambiguity.
  • Risk: CRLF/LF normalisation could affect files on Windows dev machines.
    Mitigation: .editorconfig enforces end_of_line = lf; this is the intended target, and ENDOFLINE violations confirm CRLF files exist in the repo.
  • Note: The Bitwise.cs indentation changes (8 WHITESPACE violations) are the only non-trivial fixes; they should be spot-checked manually to confirm no logic change.
  • Note: No custom analyser NuGet packages are present in any .csproj file, so the risk of non-whitespace changes from analyser rules is negligible.
Task breakdown

Task List: Issue #115 — Run dotnet format to fix existing code

Context

A one-time bulk reformatting pass using dotnet format whitespace to bring all 123 .cs
files into alignment with the .editorconfig introduced in issue #114.
346 violations exist across 101 files: 213 ENDOFLINE, 78 FINALNEWLINE, 47 CHARSET, 8 WHITESPACE.
No logic, API surface, or behaviour is altered.


Tasks

1. Apply formatting

  • Run dotnet format whitespace HdrHistogram.sln to automatically fix all whitespace,
    line-ending, charset, and final-newline violations across all four projects.
    Why: The brief mandates using the whitespace sub-command explicitly to avoid invoking
    style or analyzers fixers that could make non-cosmetic changes.
    Verify: Command exits with code 0 and reports files modified.

2. Spot-check Bitwise.cs

  • Inspect the diff for HdrHistogram/Utilities/Bitwise.cs (lines 40–60) using git diff
    to confirm the 8 WHITESPACE fixes are indentation-only and contain no logic change.
    Why: This is the only file with substantive (non-trivial) formatting changes; the brief
    calls it out explicitly as requiring manual verification.
    Verify: Diff shows only whitespace/indentation changes; no executable tokens added or removed.

3. Verify formatting is fully resolved

  • Run dotnet format --verify-no-changes HdrHistogram.sln and confirm it exits with
    code 0 and reports zero violations.
    Why: Acceptance criterion 1 — the formatter must report a clean state after the fix.
    Verify: Exit code is 0; output contains no violation lines.

4. Confirm build is clean

  • Run dotnet build HdrHistogram.sln and confirm it succeeds with no errors and no
    warnings introduced by this change.
    Why: Acceptance criterion 2 — reformatting must not break the build.
    Verify: Build output ends with Build succeeded and warning count is unchanged.

5. Confirm all unit tests pass

  • Run dotnet test HdrHistogram.sln and confirm every test passes.
    Why: Acceptance criterion 3 — existing tests must continue to pass without modification.
    Verify: Test output shows 0 failed, 0 skipped (or same counts as pre-change baseline).

6. Commit the formatting change

  • Stage all modified files (git add -u) and create a commit with the exact message:
    chore: apply dotnet format to match .editorconfig
    Why: Acceptance criterion 6 — the commit message must match this string exactly so that
    tooling (e.g. git log --grep) and the blame-ignore-revs entry can reference it reliably.
    Verify: git log -1 --format=%s outputs the required message verbatim.

7. Create .git-blame-ignore-revs

  • Record the SHA of the formatting commit (git rev-parse HEAD) and create
    .git-blame-ignore-revs
    at the repository root containing that SHA, prefixed with a
    comment line: # chore: apply dotnet format to match .editorconfig
    Why: Acceptance criterion 5 — the bulk formatting commit must be skippable via
    git blame --ignore-revs-file .git-blame-ignore-revs so that git blame output remains
    meaningful for future authors.
    Verify: File exists at repo root; contains the correct 40-character SHA; running
    git blame --ignore-revs-file .git-blame-ignore-revs HdrHistogram/Utilities/Bitwise.cs
    does not attribute lines to the formatting commit.

8. Commit .git-blame-ignore-revs

  • Stage and commit .git-blame-ignore-revs with message:
    chore: add .git-blame-ignore-revs for formatting commit
    Why: The brief says to include this file in the same PR; it must be its own commit so it
    is not mixed with the formatting diff.
    Verify: git log --oneline -2 shows both the formatting commit and this follow-up commit.

9. Open a pull request


Acceptance Criterion Cross-Reference

Acceptance Criterion (brief) Covered By
dotnet format --verify-no-changes HdrHistogram.sln exits code 0 Task 3
dotnet build HdrHistogram.sln succeeds with no errors or warnings Task 4
All unit tests pass (dotnet test HdrHistogram.sln) Task 5
No functional code changes — diffs contain only whitespace/newline additions Tasks 1, 2
.git-blame-ignore-revs created at repo root with formatting commit SHA Tasks 7, 8
Commit message is chore: apply dotnet format to match .editorconfig Task 6

Closes #115

@LeeCampbell LeeCampbell force-pushed the agent/115-run-dotnet-format-to-fix-existing-code-t branch from 2c6ecad to 0890835 Compare March 1, 2026 14:55
@LeeCampbell LeeCampbell merged commit 3b33f7e into HdrHistogram:main Mar 1, 2026
2 checks passed
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.

Run dotnet format to fix existing code to match .editorconfig

2 participants