Skip to content

chore: LF line endings everywhere - #27

Merged
rent-a-developer merged 4 commits into
mainfrom
chore/26-lf-line-endings
Sep 2, 2026
Merged

rent-a-developer merged 4 commits into
mainfrom
chore/26-lf-line-endings

Conversation

@rent-a-developer

Copy link
Copy Markdown
Owner

Closes #26.

Every text file is now LF, in the repository and in the working tree, on every OS. The repository has no
batch files, so there is no exception.

Commits

  1. test: expect LF in SQL fragment assertions — seven assertions compared an SQL fragment taken
    verbatim from a multi-line raw string literal against Environment.NewLine. C# does not normalize
    newlines inside literals, so a literal's value is the file's bytes. That only matched while .cs
    checked out platform-native. With LF everywhere the expected value is a plain LF escape. Without this
    the tests fail on Windows while CI, which runs them on Linux, stays green.
  2. chore: rename tidy-cs.ps1 to tidy-code.ps1 — the script covers more than C#. All references updated.
  3. chore: store every text file as LF — .gitattributes reduced to * text=auto eol=lf plus the
    binary list; .editorconfig sets end_of_line = lf; CI gains a renormalization guard;
    CONTRIBUTING.md documents the policy.
  4. test: normalize the expected ToString output to the host newline — InterpolatedSqlStatement.ToString builds its output with AppendLine and ReplaceLineEndings, so it is host-native. The expected raw string literal is now always LF, which no longer matches on Windows.

git add --renormalize . was a no-op — the index was already all-LF — so there is no renormalization
commit and no new .git-blame-ignore-revs entry.

Why

The per-type table needed a decision for every new file type, and the types nobody listed silently got
whatever each contributor's core.autocrlf produced. .cs checked out CRLF on Windows and LF on Linux,
so byte-level tooling saw different bytes per OS. The explicit eol= now overrides core.autocrlf and
core.eol, so contributors need no git configuration at all.

scripts/tidy-code.ps1 needed no change for this: it runs CSharpier last, and CSharpier honours
end_of_line = lf, so any file left as CRLF by another tool is rewritten to LF automatically.

For contributors

  • Nothing to configure. core.autocrlf no longer matters.
  • Optional one-time clone refresh for an all-LF working tree — commit or stash first, as the second
    command discards uncommitted work:
    git rm -r --cached . -q
    git reset --hard
  • If a tool writes CRLF into your working tree, git status shows the file as modified while
    git diff stays empty. Run pwsh -File scripts/tidy-code.ps1, or git checkout -- <path>.
  • With core.safecrlf=true (not a default) git add refuses such a file; run the tidy script, or set
    core.safecrlf warn.
  • Open branches rebase cleanly; a line-ending conflict resolves with git merge -X renormalize.

Verification

  • dotnet test passes on Windows and on Linux.
  • lint green, including the new renormalization guard.
  • git ls-files --eol shows no i/crlf or i/mixed entries.
  • No reference to tidy-cs.ps1 remains.

rent-a-developer and others added 4 commits September 2, 2026 10:01
The fragments come verbatim from a multi-line raw string literal, so
their newlines are the source file's bytes, not the host's.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The script covers style and member ordering too, not only formatting
of C# files.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
.gitattributes loses its per-type pins, so a new file type needs no
decision, and the explicit eol= overrides whatever core.autocrlf a
contributor has. The lint job now fails if a file is stored otherwise.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
InterpolatedSqlStatement.ToString builds its output with AppendLine and
ReplaceLineEndings, so it is host-native. The expected raw string
literal is now always LF, which no longer matches on Windows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@rent-a-developer rent-a-developer self-assigned this Sep 2, 2026
@rent-a-developer rent-a-developer linked an issue Sep 2, 2026 that may be closed by this pull request
7 tasks
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@rent-a-developer
rent-a-developer merged commit b5d06df into main Sep 2, 2026
15 checks passed
@rent-a-developer
rent-a-developer deleted the chore/26-lf-line-endings branch September 2, 2026 23:28
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.

LF line endings everywhere

1 participant