Emit the start of multiline implicit expressions the same as explicit…#12624
Merged
davidwengier merged 7 commits intodev/dawengie/LetsDoHtmlFormattingfrom Jan 7, 2026
Conversation
Closed
ToddGrun
reviewed
Jan 5, 2026
| } | ||
| </div> | ||
| """, | ||
| expected: """ |
Contributor
Member
Author
There was a problem hiding this comment.
In a lot of cases, formatting is not just about putting things in the right place, but also not moving things if they're already in the right spot. In this case, for object initializers, Roslyn doesn't touch them at all, and so the tests verify that we correctly honour that. The old formatting engine had a bad habit of constantly indenting these sorts of things, every time the formatter ran.
ToddGrun
reviewed
Jan 5, 2026
...eAnalysis.Razor.Workspaces/Formatting/Passes/CSharpFormattingPass.CSharpDocumentGenerator.cs
Outdated
Show resolved
Hide resolved
ToddGrun
reviewed
Jan 5, 2026
| if (offsetFromEnd == 0) | ||
| { | ||
| // If we're not doing any extra emitting of our own, then we can safely check for newlines | ||
| return CreateLineInfo( |
Contributor
Member
Author
There was a problem hiding this comment.
Importantly, it can't specify a formattedLength, or the check for new lines wouldn't work.
…xImplicitExpressionFormatting
davidwengier
commented
Jan 7, 2026
...st/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentFormattingTest.cs
Outdated
Show resolved
Hide resolved
…Formatting_NetFx/DocumentFormattingTest.cs
b326574
into
dev/dawengie/LetsDoHtmlFormatting
1 of 10 checks passed
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.
Fixes #12622 plus a few others from #12554
Fixes #12631
We already did most of this, just for explicit expressions (ie
@( ... )) so this brings it to implicit expressions too (ie@ ...) when they're multiline. We also used to emit a/* */at the end of the first line, in case there was some non-C# content on the line, and now we check for it so that we can handle Roslyn moving an open brace, or anything else really.