-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Changes from all commits
0cda3ec
0baa26d
d0788f2
b998252
0c74e7e
1f5da22
a705623
5e0bb0b
59a968d
ffcb034
9fa8fc2
55a38db
1295d25
3257330
56fd00c
5278256
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 |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. this result is better. the final formatting matches the initial formatting. |
||
private C() { } | ||
public C(int i) { } | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,7 +203,7 @@ static async Task<int> fibonacci(int n) | |
} | ||
} | ||
""", | ||
parseOptions: CSharp8ParseOptions); | ||
parseOptions: CSharp8ParseOptions); | ||
} | ||
|
||
[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] | ||
|
@@ -213,36 +213,37 @@ static async Task<int> fibonacci(int n) | |
public async Task TestLeadingTriviaAfterSemicolon(string leadingTrivia) | ||
{ | ||
await TestInRegularAndScriptAsync( | ||
$@"using System; | ||
|
||
class C | ||
{{ | ||
void M() | ||
{{ | ||
int x;{leadingTrivia} | ||
int [||]fibonacci(int n) | ||
{{ | ||
return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); | ||
}} | ||
}} | ||
}}", | ||
""" | ||
using System; | ||
$$""" | ||
using System; | ||
|
||
class C | ||
{ | ||
void M() | ||
{ | ||
int x; | ||
class C | ||
{ | ||
void M() | ||
{ | ||
int x;{{leadingTrivia}} | ||
int [||]fibonacci(int n) | ||
{ | ||
return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); | ||
} | ||
} | ||
} | ||
""", | ||
$$""" | ||
using System; | ||
|
||
static int fibonacci(int n) | ||
{ | ||
return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); | ||
} | ||
} | ||
} | ||
""", | ||
parseOptions: CSharp8ParseOptions); | ||
class C | ||
{ | ||
void M() | ||
{ | ||
int x;{{leadingTrivia}} | ||
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. this result is better. the final formatting matches the initial formatting. 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. same for the rest of the results. |
||
static int fibonacci(int n) | ||
{ | ||
return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); | ||
} | ||
} | ||
} | ||
""", | ||
parseOptions: CSharp8ParseOptions); | ||
} | ||
|
||
[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] | ||
|
@@ -252,33 +253,35 @@ static int fibonacci(int n) | |
public async Task TestLeadingTriviaAfterOpenBrace(string leadingTrivia) | ||
{ | ||
await TestInRegularAndScriptAsync( | ||
$@"using System; | ||
$$""" | ||
using System; | ||
|
||
class C | ||
{{ | ||
void M() | ||
{{{leadingTrivia} | ||
int [||]fibonacci(int n) | ||
{{ | ||
return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); | ||
}} | ||
}} | ||
}}", | ||
""" | ||
using System; | ||
class C | ||
{ | ||
void M() | ||
{{{leadingTrivia}} | ||
int [||]fibonacci(int n) | ||
{ | ||
return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); | ||
} | ||
} | ||
} | ||
""", | ||
$$""" | ||
using System; | ||
|
||
class C | ||
{ | ||
void M() | ||
{ | ||
static int fibonacci(int n) | ||
{ | ||
return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); | ||
} | ||
} | ||
} | ||
""", | ||
parseOptions: CSharp8ParseOptions); | ||
class C | ||
{ | ||
void M() | ||
{{{leadingTrivia}} | ||
static int fibonacci(int n) | ||
{ | ||
return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); | ||
} | ||
} | ||
} | ||
""", | ||
parseOptions: CSharp8ParseOptions); | ||
} | ||
|
||
[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] | ||
|
@@ -304,7 +307,7 @@ bool otherFunction() | |
}} | ||
}} | ||
}}", | ||
""" | ||
$$""" | ||
using System; | ||
|
||
class C | ||
|
@@ -314,8 +317,7 @@ void M() | |
bool otherFunction() | ||
{ | ||
return true; | ||
} | ||
|
||
}{{leadingTrivia}} | ||
static int fibonacci(int n) | ||
{ | ||
return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); | ||
|
@@ -343,15 +345,14 @@ void M() | |
int [||]fibonacci(int n) => n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); | ||
}} | ||
}}", | ||
""" | ||
$$""" | ||
using System; | ||
|
||
class C | ||
{ | ||
void M() | ||
{ | ||
bool otherFunction() => true; | ||
|
||
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. this result is better. the final formatting matches the initial formatting. |
||
bool otherFunction() => true;{{leadingTrivia}} | ||
static int fibonacci(int n) => n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,11 +133,8 @@ namespace NS | |
public static class Foo | ||
{ | ||
static int i; | ||
|
||
static void M() { } | ||
|
||
static object P { get; set; } | ||
|
||
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. this result is better. the final formatting matches the initial formatting. |
||
static event System.Action E; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. this result is better. the final formatting matches the initial formatting. |
||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
|
@@ -84,7 +83,6 @@ static void Main(string[] args) | |
var expected = """ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
|
@@ -122,7 +120,6 @@ static Task Main(string[] args) | |
global using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
internal class Program | ||
{ | ||
private static Task Main(string[] args) | ||
|
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.