You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preserve document line endings in code fixes - #4360
Code fixes that insert or rearrange lines should follow the document's existing newline sequence instead of introducing CRLF/LF mismatches.
What changed
Centralized newline selection around nearby source text, with workspace formatting options as a fallback when the document has no line endings. Updated affected documentation, layout, readability, and ordering fixes. SA1600 safely separates inline declarations before inserting docs, and SA1518 recognizes CR, LF, and CRLF for EOF checks.
Added regression coverage for LF insertion/removal, inline constructors, and CR-only EOF handling. The analyzer change scans only the existing EOF whitespace span; it does not add work to unrelated syntax nodes.
Validation
973 affected-rule tests passed on the C# 6 compiler project.
1,551 affected-rule tests passed on the C# 15 compiler project.
Add LF regression tests for the documentation fixes using this overload: Inheritdoc, SA1609, SA1615, and SA1642. Keep the verifier's CRLF workspace option and check the final output through VerifyCSharpFixAsync, including Fix All. Their existing tests do not explicitly exercise LF input. The new SA1600 test is not a substitute: SA1600 now returns a text edit, while these providers return syntax roots that can undergo code-action formatting. Tests should verify that this later processing preserves the selected newline.
Handle all Roslyn-supported newline characters in SA1518 fixer
With newlineAtEndOfFile = require, a file such as class C { }\u2028 is diagnosed because this loop does not count U+2028. The updated SA1518 fixer selects that same newline from SourceText.Lines, so applying the fix leaves the diagnostic unresolved. U+0085 and U+2029 have the same problem. Count all these Roslyn-supported newline characters and add regression tests that verify the diagnostic clears after fixing.
❌ Patch coverage is 98.79518% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.65%. Comparing base (2b8bc7d) to head (c59daea). ⚠️ Report is 9 commits behind head on master.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Code fixes that insert or rearrange lines should follow the document's existing newline sequence instead of introducing CRLF/LF mismatches.
What changed
Centralized newline selection around nearby source text, with workspace formatting options as a fallback when the document has no line endings. Updated affected documentation, layout, readability, and ordering fixes. SA1600 safely separates inline declarations before inserting docs, and SA1518 recognizes CR, LF, and CRLF for EOF checks.
Added regression coverage for LF insertion/removal, inline constructors, and CR-only EOF handling. The analyzer change scans only the existing EOF whitespace span; it does not add work to unrelated syntax nodes.
Validation
git diff --checkpassed.Fixes #3656