Skip to content

Commit 4212365

Browse files
committed
Fix compilation errors in tests
1 parent c2d3eec commit 4212365

File tree

1 file changed

+12
-34
lines changed

1 file changed

+12
-34
lines changed

src/EditorFeatures/CSharpTest/AssignOutParameters/AssignOutParametersAtStartTests.cs

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Threading.Tasks;
66
using Microsoft.CodeAnalysis.CSharp.AssignOutParameters;
77
using Microsoft.CodeAnalysis.Test.Utilities;
8-
using Microsoft.CodeAnalysis.Testing;
98
using Xunit;
109
using VerifyCS = Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions.CSharpCodeFixVerifier<
1110
Microsoft.CodeAnalysis.Testing.EmptyDiagnosticAnalyzer,
@@ -132,7 +131,7 @@ public async Task TestMissingWhenAssignedThroughAllPaths()
132131
{
133132
var code = @"class C
134133
{
135-
char M(out int i)
134+
char M(bool b, out int i)
136135
{
137136
if (b)
138137
i = 1;
@@ -143,11 +142,7 @@ char M(out int i)
143142
}
144143
}";
145144

146-
await VerifyCS.VerifyCodeFixAsync(
147-
source: code,
148-
// Test0.cs(5,13): error CS0103: The name 'b' does not exist in the current context
149-
DiagnosticResult.CompilerError("CS0103").WithSpan(5, 13, 5, 14).WithArguments("b"),
150-
fixedSource: code);
145+
await VerifyCS.VerifyCodeFixAsync(code, code);
151146
}
152147

153148
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAssignOutParameters)]
@@ -171,22 +166,13 @@ public async Task TestMultiple_AssignedInReturn1()
171166
// Handled by other fixer
172167
var code = @"class C
173168
{
174-
char M(out int i, out string s)
169+
string M(out int i, out string s)
175170
{
176-
{|CS0177:return s = "";
177-
|} }
171+
{|CS0177:return s = """";|}
172+
}
178173
}";
179174

180-
await VerifyCS.VerifyCodeFixAsync(
181-
source: code,
182-
new[]
183-
{
184-
// Test0.cs(5,20): error CS1010: Newline in constant
185-
DiagnosticResult.CompilerError("CS1010").WithSpan(5, 20, 5, 20),
186-
// Test0.cs(5,22): error CS1002: ; expected
187-
DiagnosticResult.CompilerError("CS1002").WithSpan(5, 22, 5, 22),
188-
},
189-
fixedSource: code);
175+
await VerifyCS.VerifyCodeFixAsync(code, code);
190176
}
191177

192178
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAssignOutParameters)]
@@ -195,17 +181,13 @@ public async Task TestMultiple_AssignedInReturn2()
195181
// Handled by other fixer
196182
var code = @"class C
197183
{
198-
char M(out int i, out string s)
184+
string M(out int i, out string s)
199185
{
200186
{|CS0177:return (i = 0).ToString();|}
201187
}
202188
}";
203189

204-
await VerifyCS.VerifyCodeFixAsync(
205-
source: code,
206-
// Test0.cs(5,16): error CS0029: Cannot implicitly convert type 'string' to 'char'
207-
DiagnosticResult.CompilerError("CS0029").WithSpan(5, 16, 5, 34).WithArguments("string", "char"),
208-
fixedSource: code);
190+
await VerifyCS.VerifyCodeFixAsync(code, code);
209191
}
210192

211193
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAssignOutParameters)]
@@ -272,10 +254,9 @@ char M(bool b, out int i)
272254
}
273255
274256
i = 1;
257+
throw null;
275258
}
276259
}",
277-
// Test0.cs(3,10): error CS0161: 'C.M(bool, out int)': not all code paths return a value
278-
DiagnosticResult.CompilerError("CS0161").WithSpan(3, 10, 3, 11).WithArguments("C.M(bool, out int)"),
279260
@"class C
280261
{
281262
char M(bool b, out int i)
@@ -287,6 +268,7 @@ char M(bool b, out int i)
287268
}
288269
289270
i = 1;
271+
throw null;
290272
}
291273
}");
292274
}
@@ -347,15 +329,11 @@ void X()
347329
D d = (out int i) =>
348330
{
349331
{|CS0177:return 'a';|}
350-
}
332+
};
351333
}
352334
}";
353335

354-
await VerifyCS.VerifyCodeFixAsync(
355-
source: code,
356-
// Test0.cs(9,10): error CS1002: ; expected
357-
DiagnosticResult.CompilerError("CS1002").WithSpan(9, 10, 9, 10),
358-
fixedSource: code);
336+
await VerifyCS.VerifyCodeFixAsync(code, code);
359337
}
360338

361339
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAssignOutParameters)]

0 commit comments

Comments
 (0)