Fix formatting when making an accessor readonly#76054
Fix formatting when making an accessor readonly#76054CyrusNajmabadi merged 16 commits intodotnet:mainfrom
Conversation
|
|
||
| var expected = """ | ||
| Console.WriteLine("Hello, World!"); | ||
|
|
There was a problem hiding this comment.
this result is better. the final formatting matches the initial formatting.
| event Action I.e6 { add { } remove { } } | ||
|
|
||
| static C() { } | ||
|
|
There was a problem hiding this comment.
this result is better. the final formatting matches the initial formatting.
| { | ||
| void M() | ||
| { | ||
| int x;{{leadingTrivia}} |
There was a problem hiding this comment.
this result is better. the final formatting matches the initial formatting.
There was a problem hiding this comment.
same for the rest of the results.
| void M() | ||
| { | ||
| bool otherFunction() => true; | ||
|
|
There was a problem hiding this comment.
this result is better. the final formatting matches the initial formatting.
| static void M() { } | ||
|
|
||
| static object P { get; set; } | ||
|
|
There was a problem hiding this comment.
this result is better. the final formatting matches the initial formatting.
|
|
||
| var expected = """ | ||
| using System; | ||
|
|
There was a problem hiding this comment.
this result is better. the final formatting matches the initial formatting.
| // adding/removing/modifying modifiers does not mean we want the parent construct to change its formatting | ||
| // respective to what's around it. | ||
| if (!withLeadingElasticMarker) | ||
| list[i] = list[i].WithoutLeadingTrivia(); |
There was a problem hiding this comment.
the crux of the fix. we do not want elastic trivia at teh start of a member by default, and especially not if we're just mutating modifiers. We want the modifiers to just be inertly placed into the member, leaving the formatting the same as how it started.
callers can choose if they do want leading elastic trivia added
Fixes #69876