|
| 1 | +# Issue #115: Run dotnet format to fix existing code to match .editorconfig |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +The `.editorconfig` file was introduced in issue #114 (commit `14b962b`). |
| 6 | +Existing source code predates these conventions and does not yet conform to them. |
| 7 | +This issue is a one-time bulk reformatting pass using `dotnet format` to bring all files into alignment. |
| 8 | +The change must be isolated in its own commit so that `git blame --ignore-rev` can skip it. |
| 9 | + |
| 10 | +## What Needs to Change and Why |
| 11 | + |
| 12 | +Running `dotnet format --verify-no-changes` on the current solution reports **346 formatting violations across 101 files**: |
| 13 | + |
| 14 | +- **78 FINALNEWLINE violations** — files that do not end with a newline character (`insert_final_newline = true` in `.editorconfig`) |
| 15 | +- **8 WHITESPACE violations** — indentation issues in `HdrHistogram/Utilities/Bitwise.cs` (lines 43–55) |
| 16 | + |
| 17 | +The changes are purely cosmetic (whitespace and newlines). |
| 18 | +No logic, API surface, or behaviour is altered. |
| 19 | + |
| 20 | +## Affected Files |
| 21 | + |
| 22 | +All four projects are affected: |
| 23 | + |
| 24 | +- `HdrHistogram/` — 51 `.cs` source files (main library) |
| 25 | +- `HdrHistogram.UnitTests/` — 35 `.cs` test files |
| 26 | +- `HdrHistogram.Examples/` — 4 `.cs` example files |
| 27 | +- `HdrHistogram.Benchmarking/` — 13 `.cs` benchmark files |
| 28 | + |
| 29 | +**Total: 101 files, 346 violations.** |
| 30 | + |
| 31 | +The file with the most substantive changes is: |
| 32 | + |
| 33 | +- `HdrHistogram/Utilities/Bitwise.cs` — 8 whitespace/indentation fixes |
| 34 | + |
| 35 | +All other files require only a trailing newline added at end-of-file. |
| 36 | + |
| 37 | +## Acceptance Criteria |
| 38 | + |
| 39 | +- [ ] `dotnet format --verify-no-changes` exits with code 0 after the fix is applied |
| 40 | +- [ ] `dotnet build` succeeds with no errors or warnings introduced by this change |
| 41 | +- [ ] All unit tests pass (`dotnet test`) |
| 42 | +- [ ] No functional code changes — diffs contain only whitespace and newline additions |
| 43 | +- [ ] A `.git-blame-ignore-revs` file is created at the repo root containing the SHA of the formatting commit |
| 44 | +- [ ] The commit message is `chore: apply dotnet format to match .editorconfig` |
| 45 | + |
| 46 | +## Test Strategy |
| 47 | + |
| 48 | +No new tests are required — this is a pure formatting change. |
| 49 | +Existing tests must continue to pass without modification. |
| 50 | + |
| 51 | +Verification steps: |
| 52 | + |
| 53 | +1. Run `dotnet format --verify-no-changes` — must exit 0 |
| 54 | +2. Run `dotnet build HdrHistogram.sln` — must succeed |
| 55 | +3. Run `dotnet test HdrHistogram.sln` — all tests must pass |
| 56 | +4. Inspect the diff with `git diff` before committing — confirm only whitespace/newline changes |
| 57 | + |
| 58 | +## Implementation Steps |
| 59 | + |
| 60 | +1. Run `dotnet format HdrHistogram.sln` to apply all fixes automatically |
| 61 | +2. Verify with `dotnet format --verify-no-changes HdrHistogram.sln` |
| 62 | +3. Run `dotnet build HdrHistogram.sln` to confirm build is clean |
| 63 | +4. Run `dotnet test HdrHistogram.sln` to confirm tests pass |
| 64 | +5. Commit with message: `chore: apply dotnet format to match .editorconfig` |
| 65 | +6. Record the commit SHA and create `.git-blame-ignore-revs` with that SHA |
| 66 | +7. Commit `.git-blame-ignore-revs` (separate commit or same PR) |
| 67 | +8. Open a PR against `main` |
| 68 | + |
| 69 | +## Risks and Open Questions |
| 70 | + |
| 71 | +- **Risk:** `dotnet format` may apply analyser-driven style changes (not just whitespace) if analyser rules are enabled in `.editorconfig` or project files. |
| 72 | + Mitigation: review `git diff` before committing to confirm the scope is whitespace-only. |
| 73 | +- **Risk:** CRLF/LF normalisation could affect files on Windows dev machines. |
| 74 | + Mitigation: `.editorconfig` enforces `end_of_line = lf`; this is the intended target. |
| 75 | +- **Open question:** Should `.git-blame-ignore-revs` be committed in the same PR or a follow-up? |
| 76 | + Preference from issue: same PR. |
| 77 | +- **Note:** The `Bitwise.cs` indentation changes (8 violations) are the only non-trivial whitespace fixes; they should be spot-checked manually to confirm no logic change. |
0 commit comments