Skip to content

Better line ending failure diagnostics#1799

Merged
SimonCropp merged 2 commits into
mainfrom
line-ending-failure-diagnostics
Jul 16, 2026
Merged

Better line ending failure diagnostics#1799
SimonCropp merged 2 commits into
mainfrom
line-ending-failure-diagnostics

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

No description provided.

The verified file line ending check threw before received was written, so a
CRLF verified file produced no output at all. That reads as "verify did
nothing" rather than a line ending problem, and the cause was buried:
VerifyEngine wraps every exception in "Failed to compare files", so the outer
message runners surface said nothing about line endings.

Write received before throwing, so the failure produces a snapshot, and
accepting it rewrites verified with \n endings. Throw a dedicated
VerifiedLineEndingException that VerifyEngine rethrows unwrapped, and name the
likely cause (git checking the file out with \r\n) and the .gitattributes fix
in the message.

Surfaced by VerifyTests/Verify.DiffPlex#474, where the missing output was
misattributed to Verify.DiffPlex.

Also correct two dead guards. NET10 is not a symbol the SDK defines (it is
NET10_0), so #if NET10 was always false, and TrailingNewlinesRaw was
additionally nested inside the #if NET9_0 above it, requiring both symbols.
TrailingNewlinesRaw, SecondsFractionUpperLong and SecondsFractionUpperShort had
never compiled; all three pass once the guards are corrected. Notably
TrailingNewlinesRaw covers the trailing newline half of #1762, which until now
had no running test.

TrailingNewlinesRaw hand-manages its verified file (delete, write, verify,
delete), so the tracked NewLineTests.TrailingNewlinesRaw.verified.txt was a
leftover that every run deletes, leaving a dirty tree. Untrack it, matching
StringWithDifferingNewline which uses the same pattern. Also remove the
TrailingNewlinesObject snapshot, whose test is commented out.
The suggested .gitattributes line hardcoded *.verified.txt, but the verified
file may be json, xml, or any other registered text extension, so the
suggestion did not match the file it was reported against.

Interpolate FilePair.Extension instead, and cover it with a json case. The
extension being unread would now also fail the build (CS9113).
@SimonCropp SimonCropp added this to the 31.24.3 milestone Jul 16, 2026
@SimonCropp
SimonCropp merged commit 342743b into main Jul 16, 2026
6 of 7 checks passed
@SimonCropp
SimonCropp deleted the line-ending-failure-diagnostics branch July 16, 2026 13:14
This was referenced Jul 16, 2026
This was referenced Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant