Skip to content

fix: cross-platform line ending normalization in CodeFix tests#19

Merged
Arthurvdv merged 1 commit into
masterfrom
fix/cross-platform-line-ending-normalization
Jun 16, 2026
Merged

fix: cross-platform line ending normalization in CodeFix tests#19
Arthurvdv merged 1 commit into
masterfrom
fix/cross-platform-line-ending-normalization

Conversation

@Arthurvdv

Copy link
Copy Markdown
Member

Summary

  • Normalize both actual and expected code to LF before comparison in Verify.CodeAction(), making HasFix tests stable across Windows, Linux, and macOS regardless of git core.autocrlf settings
  • Replace platform-specific ConvertToLineEndingsAwareString (only normalized actual output on Linux/macOS) with unconditional NormalizeLineEndings applied to both sides
  • Fix pre-existing bug where multi-document comparison reused the wrong SourceText variable (sourceText instead of docSourceText)

Context

All 135 HasFix tests in ALCops Analyzers fail on Linux/WSL because:

  1. .al fixture files have CRLF (from git core.autocrlf=true)
  2. ConvertToLineEndingsAwareString strips CRLF→LF on the actual code fix output on Linux
  3. The expected code from fixture files was never normalized
  4. The comparison at line 57 (actualCode != expectedCode) compares LF vs CRLF → always fails

Test plan

  • Built RoslynTestKit locally, copied DLL into Analyzers NuGet cache
  • Ran full Analyzers test suite: 1,108 tests, 0 failures (previously 135 failures)

🤖 Generated with Claude Code

Verify.CodeAction() normalized only the actual code fix output (CRLF→LF
on Linux/macOS) but not the expected code from fixture files. This caused
all HasFix tests to fail on Linux/WSL when fixture files had CRLF endings.

Replace platform-specific ConvertToLineEndingsAwareString with an
unconditional NormalizeLineEndings that normalizes both actual and
expected to LF before comparison, making tests stable across all
platforms regardless of git autocrlf settings or OS line endings.

Also fixes a bug where multi-document comparison reused the wrong
SourceText variable (sourceText instead of docSourceText).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Arthurvdv Arthurvdv merged commit b040556 into master Jun 16, 2026
1 check passed
@Arthurvdv Arthurvdv deleted the fix/cross-platform-line-ending-normalization branch June 16, 2026 08:02
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.

1 participant