-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Fix formatting when making an accessor readonly #76054
base: main
Are you sure you want to change the base?
Conversation
@@ -40,7 +40,6 @@ class {|FixAllInContainingType:Program|} | |||
|
|||
var expected = """ | |||
Console.WriteLine("Hello, World!"); | |||
|
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 result is better. the final formatting matches the initial formatting.
@@ -114,7 +114,6 @@ public event Action e5 { add { } remove { } } | |||
event Action I.e6 { add { } remove { } } | |||
|
|||
static C() { } | |||
|
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 result is better. the final formatting matches the initial formatting.
{ | ||
void M() | ||
{ | ||
int x;{{leadingTrivia}} |
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 result is better. the final formatting matches the initial formatting.
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.
same for the rest of the results.
using System; | ||
|
||
class C | ||
{ | ||
void M() | ||
{ | ||
bool otherFunction() => true; | ||
|
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 result is better. the final formatting matches the initial formatting.
static object P { get; set; } | ||
|
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 result is better. the final formatting matches the initial formatting.
@@ -53,7 +53,6 @@ static void Main(string[] args) | |||
|
|||
var expected = """ | |||
using System; | |||
|
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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