@@ -11,157 +11,163 @@ public static class Diagnostics
1111 [ Test ]
1212 public static void WebClientDownloadStringTaskAsync ( )
1313 {
14- var code = @"
15- #pragma warning disable SYSLIB0014
16- namespace N
17- {
18- using System.Net;
19- using System.Threading.Tasks;
20-
21- public class C
22- {
23- public Task<string> M()
24- {
25- using (var client = new WebClient())
14+ var code = """
15+ #pragma warning disable SYSLIB0014
16+ namespace N
2617 {
27- return ↓client.DownloadStringTaskAsync(string.Empty);
18+ using System.Net;
19+ using System.Threading.Tasks;
20+
21+ public class C
22+ {
23+ public Task<string> M()
24+ {
25+ using (var client = new WebClient())
26+ {
27+ return ↓client.DownloadStringTaskAsync(string.Empty);
28+ }
29+ }
30+ }
2831 }
29- }
30- }
31- }" ;
32+ """ ;
3233 RoslynAssert . Diagnostics ( Analyzer , ExpectedDiagnostic , code ) ;
3334 }
3435
3536 [ Test ]
3637 public static void ValueTask ( )
3738 {
38- var code = @"
39- namespace N
40- {
41- using System.Threading.Tasks;
42-
43- public static class C
44- {
45- public static ValueTask<int> MAsync()
46- {
47- using (System.IO.File.OpenRead(string.Empty))
39+ var code = """
40+ namespace N
4841 {
49- return ↓InnerAsync();
42+ using System.Threading.Tasks;
43+
44+ public static class C
45+ {
46+ public static ValueTask<int> MAsync()
47+ {
48+ using (System.IO.File.OpenRead(string.Empty))
49+ {
50+ return ↓InnerAsync();
51+ }
52+ }
53+
54+ private static async ValueTask<int> InnerAsync()
55+ {
56+ await Task.Delay(10).ConfigureAwait(false);
57+ return 1;
58+ }
59+ }
5060 }
51- }
52-
53- private static async ValueTask<int> InnerAsync()
54- {
55- await Task.Delay(10).ConfigureAwait(false);
56- return 1;
57- }
58- }
59- }" ;
61+ """ ;
6062 RoslynAssert . Diagnostics ( Analyzer , ExpectedDiagnostic , code ) ;
6163 }
6264
6365 [ Test ]
6466 public static void UsingDeclaration ( )
6567 {
66- var code = @"
67- namespace N
68- {
69- using System.Threading.Tasks;
70-
71- public static class C
72- {
73- public static ValueTask<int> MAsync()
74- {
75- using var file = System.IO.File.OpenRead(string.Empty);
76- return ↓InnerAsync();
77- }
78-
79- private static async ValueTask<int> InnerAsync()
80- {
81- await Task.Delay(10).ConfigureAwait(false);
82- return 1;
83- }
84- }
85- }" ;
68+ var code = """
69+ namespace N
70+ {
71+ using System.Threading.Tasks;
72+
73+ public static class C
74+ {
75+ public static ValueTask<int> MAsync()
76+ {
77+ using var file = System.IO.File.OpenRead(string.Empty);
78+ return ↓InnerAsync();
79+ }
80+
81+ private static async ValueTask<int> InnerAsync()
82+ {
83+ await Task.Delay(10).ConfigureAwait(false);
84+ return 1;
85+ }
86+ }
87+ }
88+ """ ;
8689 RoslynAssert . Diagnostics ( Analyzer , ExpectedDiagnostic , code ) ;
8790 }
8891
8992 [ Test ]
9093 public static void UsingDeclarationInner ( )
9194 {
92- var code = @"
93- namespace N
94- {
95- using System.Threading.Tasks;
96-
97- public static class C
98- {
99- public static ValueTask<int> MAsync()
100- {
101- using var file = System.IO.File.OpenRead(string.Empty);
102- while (true)
95+ var code = """
96+ namespace N
10397 {
104- return ↓InnerAsync();
98+ using System.Threading.Tasks;
99+
100+ public static class C
101+ {
102+ public static ValueTask<int> MAsync()
103+ {
104+ using var file = System.IO.File.OpenRead(string.Empty);
105+ while (true)
106+ {
107+ return ↓InnerAsync();
108+ }
109+ }
110+
111+ private static async ValueTask<int> InnerAsync()
112+ {
113+ await Task.Delay(10).ConfigureAwait(false);
114+ return 1;
115+ }
116+ }
105117 }
106- }
107-
108- private static async ValueTask<int> InnerAsync()
109- {
110- await Task.Delay(10).ConfigureAwait(false);
111- return 1;
112- }
113- }
114- }" ;
118+ """ ;
115119 RoslynAssert . Diagnostics ( Analyzer , ExpectedDiagnostic , code ) ;
116120 }
117121
118122 [ Test ]
119123 public static void LocalTask ( )
120124 {
121- var code = @"
122- #pragma warning disable SYSLIB0014
123- namespace N
124- {
125- using System.Net;
126- using System.Threading.Tasks;
127-
128- public class C
129- {
130- public Task<string> M()
131- {
132- using (var client = new WebClient())
125+ var code = """
126+ #pragma warning disable SYSLIB0014
127+ namespace N
133128 {
134- var task = client.DownloadStringTaskAsync(string.Empty);
135- return ↓task;
129+ using System.Net;
130+ using System.Threading.Tasks;
131+
132+ public class C
133+ {
134+ public Task<string> M()
135+ {
136+ using (var client = new WebClient())
137+ {
138+ var task = client.DownloadStringTaskAsync(string.Empty);
139+ return ↓task;
140+ }
141+ }
142+ }
136143 }
137- }
138- }
139- }" ;
144+ """ ;
140145 RoslynAssert . Diagnostics ( Analyzer , ExpectedDiagnostic , code ) ;
141146 }
142147
143148 [ Test ]
144149 public static void TaskCompletionSourceTask ( )
145150 {
146- var code = @"
147- #pragma warning disable SYSLIB0014
148- namespace N
149- {
150- using System.Net;
151- using System.Threading.Tasks;
152-
153- public class C
154- {
155- static Task M()
156- {
157- var tcs = new TaskCompletionSource<bool>();
158- using (var client = new WebClient())
151+ var code = """
152+ #pragma warning disable SYSLIB0014
153+ namespace N
159154 {
160- return ↓tcs.Task;
155+ using System.Net;
156+ using System.Threading.Tasks;
157+
158+ public class C
159+ {
160+ static Task M()
161+ {
162+ var tcs = new TaskCompletionSource<bool>();
163+ using (var client = new WebClient())
164+ {
165+ return ↓tcs.Task;
166+ }
167+ }
168+ }
161169 }
162- }
163- }
164- }" ;
170+ """ ;
165171 RoslynAssert . Diagnostics ( Analyzer , ExpectedDiagnostic , code ) ;
166172 }
167173}
0 commit comments