Skip to content

Commit 3951927

Browse files
committed
Update SA1116 for static anonymous functions
1 parent cb3ab3f commit 3951927

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,39 @@ public void Method()
5151
DiagnosticResult expected = Diagnostic().WithLocation(10, 21);
5252
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
5353
}
54+
55+
[Fact]
56+
[WorkItem(3973, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3973")]
57+
public async Task TestStaticAnonymousFunctionFirstParameterOnSameLineAsync()
58+
{
59+
var testCode = @"
60+
using System;
61+
62+
public class TestClass
63+
{
64+
public void TestMethod()
65+
{
66+
Func<int, int, int> func = static ({|#0:int first|},
67+
int second) => first + second;
68+
}
69+
}
70+
";
71+
72+
var fixedCode = @"
73+
using System;
74+
75+
public class TestClass
76+
{
77+
public void TestMethod()
78+
{
79+
Func<int, int, int> func = static (
80+
int first,
81+
int second) => first + second;
82+
}
83+
}
84+
";
85+
86+
await VerifyCSharpFixAsync(testCode, Diagnostic().WithLocation(0), fixedCode, CancellationToken.None).ConfigureAwait(false);
87+
}
5488
}
5589
}

0 commit comments

Comments
 (0)