Skip to content

Commit bc35406

Browse files
committed
Update SA1008 for asynchronous streams
1 parent a4273dd commit bc35406

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1008CSharp8UnitTests.cs

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4-
#nullable disable
5-
64
namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules
75
{
86
using System.Threading;
@@ -237,5 +235,53 @@ await VerifyCSharpFixAsync(
237235
fixedCode,
238236
CancellationToken.None).ConfigureAwait(false);
239237
}
238+
239+
[Fact]
240+
[WorkItem(3007, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3007")]
241+
public async Task TestAwaitForEachSpaceAfterParenAsync()
242+
{
243+
var testCode = @"
244+
namespace TestNamespace
245+
{
246+
using System.Collections.Generic;
247+
using System.Threading.Tasks;
248+
249+
public class TestClass
250+
{
251+
public async Task ConsumeAsync(IAsyncEnumerable<int> values)
252+
{
253+
await foreach {|#0:(|} var value in values)
254+
{
255+
_ = value;
256+
}
257+
}
258+
}
259+
}
260+
";
261+
var fixedCode = @"
262+
namespace TestNamespace
263+
{
264+
using System.Collections.Generic;
265+
using System.Threading.Tasks;
266+
267+
public class TestClass
268+
{
269+
public async Task ConsumeAsync(IAsyncEnumerable<int> values)
270+
{
271+
await foreach (var value in values)
272+
{
273+
_ = value;
274+
}
275+
}
276+
}
277+
}
278+
";
279+
280+
await VerifyCSharpFixAsync(
281+
testCode,
282+
Diagnostic(DescriptorNotFollowed).WithLocation(0),
283+
fixedCode,
284+
CancellationToken.None).ConfigureAwait(false);
285+
}
240286
}
241287
}

0 commit comments

Comments
 (0)