Respect document line endings in C# code actions and refactorings#84347
Draft
Copilot wants to merge 3 commits into
Draft
Respect document line endings in C# code actions and refactorings#84347Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix hard coded windows line endings in code action fixer
Jun 30, 2026
| .Append(XmlText(XmlTextNewLine(lineFormattingOptions.NewLine, continueXmlDocumentationComment: false)))], | ||
| EndOfDocumentationCommentToken | ||
| .WithTrailingTrivia(DocumentationCommentExterior("*/"), ElasticCarriageReturnLineFeed)); | ||
| .WithTrailingTrivia(DocumentationCommentExterior("*/"), ElasticEndOfLine(lineFormattingOptions.NewLine))); |
Contributor
There was a problem hiding this comment.
this is weird, and shouldn't be necessary. by virtue of being elastic, the formatter should replace this with the right newline based on the options passed into it.
Member
There was a problem hiding this comment.
I never identified where elastic newlines were supposed to be rewritten. I took at stab at adding it to the trivia rewriter (#83224) but haven't had time to review all the tests that broke due to changed formatting.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Several C# code actions were introducing hard-coded CRLF trivia into documents that otherwise used LF, which caused Linux runs to produce mixed line endings and forced a set of issue-tracked tests to stay disabled. This PR updates the affected generators/refactorings to follow the document/host newline convention instead of assuming Windows line endings.
Shared newline generation
ElasticCarriageReturnLineFeedto elastic end-of-line trivia based on the current environment newline.Direct C# fixer/refactoring call sites
iftoswitchRaw string conversion
Issue-tracked tests