Skip to content

Commit d511f98

Browse files
inline test strings
1 parent a6098be commit d511f98

File tree

36 files changed

+433
-782
lines changed

36 files changed

+433
-782
lines changed

src/Analyzers/CSharp/Tests/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -909,13 +909,12 @@ public S()
909909
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/58593")]
910910
public async Task TestMissingInStructWithoutFieldInitializer()
911911
{
912-
var source = """
912+
await TestCodeFixMissingAsync("""
913913
struct [||]S
914914
{
915915
object X;
916916
}
917-
""";
918-
await TestCodeFixMissingAsync(source);
917+
""");
919918

920919
#if !CODE_STYLE
921920
await TestRefactoringMissingAsync(source);

src/Analyzers/CSharp/Tests/ImplementInterface/ImplementInterfaceCodeFixTests.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5371,7 +5371,7 @@ public void Goo(byte x = 1)
53715371
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545736")]
53725372
public async Task TestCastedOptionalParameter1()
53735373
{
5374-
const string code = """
5374+
await TestWithAllCodeStyleOptionsOffAsync("""
53755375
using System;
53765376
interface I
53775377
{
@@ -5381,9 +5381,7 @@ interface I
53815381
class C : {|CS0535:I|}
53825382
{
53835383
}
5384-
""";
5385-
5386-
const string expected = """
5384+
""", """
53875385
using System;
53885386
interface I
53895387
{
@@ -5397,9 +5395,7 @@ public void Goo(ConsoleColor x = (ConsoleColor)(-1))
53975395
throw new NotImplementedException();
53985396
}
53995397
}
5400-
""";
5401-
5402-
await TestWithAllCodeStyleOptionsOffAsync(code, expected);
5398+
""");
54035399
}
54045400

54055401
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545737")]

src/Analyzers/CSharp/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3078,7 +3078,7 @@ class C
30783078
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/62856")]
30793079
public async Task DoNotWarnForAwaiterMethods()
30803080
{
3081-
const string code = """
3081+
await VerifyCS.VerifyAnalyzerAsync("""
30823082
using System;
30833083
using System.Runtime.CompilerServices;
30843084
using System.Threading.Tasks;
@@ -3096,15 +3096,13 @@ private void GetResult() { }
30963096
public void OnCompleted(Action continuation) => Task.Run(continuation);
30973097
public void UnsafeOnCompleted(Action continuation) => Task.Run(continuation);
30983098
}
3099-
""";
3100-
3101-
await VerifyCS.VerifyAnalyzerAsync(code);
3099+
""");
31023100
}
31033101

31043102
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/62856")]
31053103
public async Task WarnForAwaiterMethodsNotImplementingInterface()
31063104
{
3107-
const string code = """
3105+
await VerifyCS.VerifyCodeFixAsync("""
31083106
using System;
31093107
using System.Runtime.CompilerServices;
31103108
using System.Threading.Tasks;
@@ -3117,8 +3115,7 @@ class C
31173115
public void OnCompleted(Action continuation) => Task.Run(continuation);
31183116
public void UnsafeOnCompleted(Action continuation) => Task.Run(continuation);
31193117
}
3120-
""";
3121-
const string fixedCode = """
3118+
""", """
31223119
using System;
31233120
using System.Runtime.CompilerServices;
31243121
using System.Threading.Tasks;
@@ -3128,9 +3125,7 @@ class C
31283125
public void OnCompleted(Action continuation) => Task.Run(continuation);
31293126
public void UnsafeOnCompleted(Action continuation) => Task.Run(continuation);
31303127
}
3131-
""";
3132-
3133-
await VerifyCS.VerifyCodeFixAsync(code, fixedCode);
3128+
""");
31343129
}
31353130

31363131
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/57470")]

src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ void Method(System.Collections.Generic.IEnumerable<(Program, Program)> x)
10481048
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/47038")]
10491049
public async Task NotNullableType_ForeachVarDeconstruction2()
10501050
{
1051-
var before = """
1051+
await TestInRegularAndScriptAsync("""
10521052
#nullable enable
10531053
10541054
class C
@@ -1067,8 +1067,7 @@ void M(C[] items)
10671067
}
10681068
}
10691069
}
1070-
""";
1071-
var after = """
1070+
""", """
10721071
#nullable enable
10731072
10741073
class C
@@ -1087,8 +1086,7 @@ void M(C[] items)
10871086
}
10881087
}
10891088
}
1090-
""";
1091-
await TestInRegularAndScriptAsync(before, after, new(options: ExplicitTypeEverywhere()));
1089+
""", new(options: ExplicitTypeEverywhere()));
10921090
}
10931091

10941092
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/40477")]

src/CodeStyle/Tools/Program.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,10 @@ bool AddRule(DiagnosticDescriptor rule)
197197

198198
private static void CreateTargetsFile(string language, string outputDir, string targetsFileName)
199199
{
200-
var fileContents =
201-
$@"<Project>{GetTargetContents(language)}
202-
</Project>";
203-
204200
var directory = Directory.CreateDirectory(outputDir);
205201
var fileWithPath = Path.Combine(directory.FullName, targetsFileName);
206-
File.WriteAllText(fileWithPath, fileContents);
202+
File.WriteAllText(fileWithPath, $@"<Project>{GetTargetContents(language)}
203+
</Project>");
207204
return;
208205

209206
static string GetTargetContents(string language)

0 commit comments

Comments
 (0)