-
Notifications
You must be signed in to change notification settings - Fork 236
Emit the start of multiline implicit expressions the same as explicit… #12624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d3a6f15
385c2fe
63e4db3
b57255c
b9a8fc3
3c3052e
227b67b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7579,6 +7579,274 @@ public Task ObjectInitializers3() | |
| </div> | ||
| """); | ||
|
|
||
| [FormattingTestFact] | ||
| [WorkItem("https://github.com/dotnet/razor/issues/12622")] | ||
| public Task ObjectInitializers4() | ||
| => RunFormattingTestAsync( | ||
| input: """ | ||
| <div> | ||
| @if (true) | ||
| { | ||
| @Html.TextBox(new Test() | ||
| { | ||
| test = 5 | ||
| }) | ||
| <div></div> | ||
| } | ||
| </div> | ||
| """, | ||
| expected: """ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
| <div> | ||
| @if (true) | ||
| { | ||
| @Html.TextBox(new Test() | ||
| { | ||
| test = 5 | ||
| }) | ||
| <div></div> | ||
| } | ||
| </div> | ||
| """); | ||
|
|
||
| [FormattingTestFact] | ||
| [WorkItem("https://github.com/dotnet/razor/issues/12622")] | ||
| public Task ObjectInitializers5() | ||
| => RunFormattingTestAsync( | ||
| input: """ | ||
| <div> | ||
| @if (true) | ||
| { | ||
| @Html.TextBox(new Test() { test = 5 }) | ||
| <div></div> | ||
| } | ||
| </div> | ||
| """, | ||
| expected: """ | ||
| <div> | ||
| @if (true) | ||
| { | ||
| @Html.TextBox(new Test() { test = 5 }) | ||
| <div></div> | ||
| } | ||
| </div> | ||
| """); | ||
|
|
||
| [FormattingTestFact] | ||
| [WorkItem("https://github.com/dotnet/razor/issues/12622")] | ||
| public Task ObjectInitializers6() | ||
| => RunFormattingTestAsync( | ||
| input: """ | ||
| @if (true) | ||
| { | ||
| @Html.TextBox(new Test() | ||
| { | ||
| test = 5 | ||
| }) | ||
| <div></div> | ||
| } | ||
| """, | ||
| expected: """ | ||
| @if (true) | ||
| { | ||
| @Html.TextBox(new Test() | ||
| { | ||
| test = 5 | ||
| }) | ||
| <div></div> | ||
| } | ||
| """); | ||
|
|
||
| [FormattingTestFact] | ||
| [WorkItem("https://github.com/dotnet/razor/issues/12622")] | ||
| public Task ObjectInitializers7() | ||
| => RunFormattingTestAsync( | ||
| input: """ | ||
| <div> | ||
| <div> | ||
| @Html.TextBox(new | ||
| { | ||
| test = 5, | ||
| }) | ||
| </div> | ||
| <div> | ||
| @Html.TextBox(new | ||
| { | ||
| test = 5, | ||
| }) | ||
| </div> | ||
| </div> | ||
| """, | ||
| expected: """ | ||
| <div> | ||
| <div> | ||
| @Html.TextBox(new | ||
| { | ||
| test = 5, | ||
| }) | ||
| </div> | ||
| <div> | ||
| @Html.TextBox(new | ||
| { | ||
| test = 5, | ||
| }) | ||
| </div> | ||
| </div> | ||
| """); | ||
|
|
||
| [FormattingTestFact] | ||
| [WorkItem("https://github.com/dotnet/razor/issues/12622")] | ||
| public Task ObjectInitializers8() | ||
| => RunFormattingTestAsync( | ||
| input: """ | ||
| @if (true) | ||
| { | ||
| @Html.TextBox(new Test() { | ||
| test = 5 | ||
| }) | ||
| <div></div> | ||
| } | ||
| """, | ||
| expected: """ | ||
| @if (true) | ||
| { | ||
| @Html.TextBox(new Test() | ||
| { | ||
| test = 5 | ||
| }) | ||
| <div></div> | ||
| } | ||
| """); | ||
|
|
||
| [FormattingTestFact] | ||
| [WorkItem("https://github.com/dotnet/razor/issues/12622")] | ||
| public Task ObjectInitializers9() | ||
| => RunFormattingTestAsync( | ||
| input: """ | ||
| @if (true) | ||
| { | ||
| @Html.TextBox(new Test() { | ||
| test = 5 | ||
| }) | ||
| <div></div> | ||
| } | ||
| """, | ||
| expected: """ | ||
| @if (true) | ||
| { | ||
| @Html.TextBox(new Test() { | ||
| test = 5 | ||
| }) | ||
| <div></div> | ||
| } | ||
| """, | ||
| csharpSyntaxFormattingOptions: RazorCSharpSyntaxFormattingOptions.Default with | ||
| { | ||
| NewLines = RazorCSharpSyntaxFormattingOptions.Default.NewLines & ~RazorNewLinePlacement.BeforeOpenBraceInObjectCollectionArrayInitializers | ||
| }); | ||
|
|
||
| [FormattingTestFact] | ||
| [WorkItem("https://github.com/dotnet/razor/issues/12622")] | ||
| public Task ObjectInitializers10() | ||
| => RunFormattingTestAsync( | ||
| input: """ | ||
| @if (true) | ||
| { | ||
| @Html.TextBox(new Test() | ||
| { | ||
| test = 5 | ||
| }) | ||
| <div></div> | ||
| } | ||
| """, | ||
| expected: """ | ||
| @if (true) | ||
| { | ||
| @Html.TextBox(new Test() { | ||
| test = 5 | ||
| }) | ||
| <div></div> | ||
| } | ||
| """, | ||
| csharpSyntaxFormattingOptions: RazorCSharpSyntaxFormattingOptions.Default with | ||
| { | ||
| NewLines = RazorCSharpSyntaxFormattingOptions.Default.NewLines & ~RazorNewLinePlacement.BeforeOpenBraceInObjectCollectionArrayInitializers | ||
| }); | ||
|
|
||
| [FormattingTestFact] | ||
| [WorkItem("https://github.com/dotnet/razor/issues/12622")] | ||
| public Task ObjectInitializers11() | ||
| => RunFormattingTestAsync( | ||
| input: """ | ||
| <div> | ||
| <div> | ||
| <div> | ||
| @if (true) | ||
| { | ||
| <div> | ||
| @Html.TextBox(new | ||
| { | ||
| test = 6 | ||
| }) | ||
| </div> | ||
|
|
||
| <div></div> | ||
| } | ||
| </div> | ||
| </div> | ||
| </div> | ||
| """, | ||
| expected: """ | ||
| <div> | ||
| <div> | ||
| <div> | ||
| @if (true) | ||
| { | ||
| <div> | ||
| @Html.TextBox(new | ||
| { | ||
| test = 6 | ||
| }) | ||
| </div> | ||
|
|
||
| <div></div> | ||
| } | ||
| </div> | ||
| </div> | ||
| </div> | ||
| """); | ||
|
|
||
| [FormattingTestFact] | ||
| [WorkItem("https://github.com/dotnet/razor/issues/12631")] | ||
| public Task ObjectInitializers12() | ||
| => RunFormattingTestAsync( | ||
| input: """ | ||
| @await Component.InvokeAsync("ReviewAndPublishModal", | ||
| new { | ||
| id = "ReviewPublishModal", | ||
| title = "Review and publish", | ||
| text = Model.ReviewNotes, | ||
| state = Model.State, | ||
| allowSave = allowSaveReview, | ||
| allowPublish = allowPublish, | ||
| isPublished =isCurrentPublished | ||
| } | ||
| ) | ||
| """, | ||
| expected: """ | ||
| @await Component.InvokeAsync("ReviewAndPublishModal", | ||
| new | ||
| { | ||
| id = "ReviewPublishModal", | ||
| title = "Review and publish", | ||
| text = Model.ReviewNotes, | ||
| state = Model.State, | ||
| allowSave = allowSaveReview, | ||
| allowPublish = allowPublish, | ||
| isPublished = isCurrentPublished | ||
| } | ||
| ) | ||
| """); | ||
|
|
||
| [FormattingTestFact] | ||
| public Task PartialDocument() | ||
| => RunFormattingTestAsync( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to specify formattedLength similar to the other call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importantly, it can't specify a formattedLength, or the check for new lines wouldn't work.