Skip to content

Commit 20f9d77

Browse files
committed
Update SA1113 for static anonymous functions
1 parent 9b237ac commit 20f9d77

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1113CSharp9UnitTests.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,47 @@
33

44
namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules
55
{
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
using Microsoft.CodeAnalysis.Testing;
69
using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules;
10+
using Xunit;
11+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
12+
StyleCop.Analyzers.ReadabilityRules.SA1113CommaMustBeOnSameLineAsPreviousParameter,
13+
StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>;
714

815
public partial class SA1113CSharp9UnitTests : SA1113CSharp8UnitTests
916
{
17+
[Fact]
18+
[WorkItem(3973, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3973")]
19+
public async Task TestStaticAnonymousFunctionCommaOnNextLineAsync()
20+
{
21+
var testCode = @"using System;
22+
23+
public class TestClass
24+
{
25+
public void TestMethod()
26+
{
27+
Func<int, int, int> func = static (int first
28+
{|#0:,|} int second) => first + second;
29+
}
30+
}
31+
";
32+
33+
var fixedCode = @"using System;
34+
35+
public class TestClass
36+
{
37+
public void TestMethod()
38+
{
39+
Func<int, int, int> func = static (int first,
40+
int second) => first + second;
41+
}
42+
}
43+
";
44+
45+
DiagnosticResult expected = Diagnostic().WithLocation(0);
46+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
47+
}
1048
}
1149
}

0 commit comments

Comments
 (0)