Skip to content

Commit 516b3c5

Browse files
committed
Update SA1501 tests for attributed local functions
1 parent 56de02d commit 516b3c5

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1501CSharp9UnitTests.cs

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

44
namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules
55
{
6+
using System.Threading;
7+
using System.Threading.Tasks;
68
using StyleCop.Analyzers.Test.CSharp8.LayoutRules;
9+
using Xunit;
10+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
11+
StyleCop.Analyzers.LayoutRules.SA1501StatementMustNotBeOnASingleLine,
12+
StyleCop.Analyzers.LayoutRules.SA1501CodeFixProvider>;
713

814
public partial class SA1501CSharp9UnitTests : SA1501CSharp8UnitTests
915
{
16+
[Fact]
17+
[WorkItem(3978, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3978")]
18+
public async Task TestLocalFunctionWithAttributeOnSingleLineAsync()
19+
{
20+
var testCode = @"using System;
21+
22+
class TestClass
23+
{
24+
void Outer()
25+
{
26+
[Obsolete]
27+
void Local(){|#0:{|} int value = 0; }
28+
}
29+
}
30+
";
31+
32+
var fixedCode = @"using System;
33+
34+
class TestClass
35+
{
36+
void Outer()
37+
{
38+
[Obsolete]
39+
void Local()
40+
{
41+
int value = 0;
42+
}
43+
}
44+
}
45+
";
46+
47+
await VerifyCSharpFixAsync(testCode, Diagnostic().WithLocation(0), fixedCode, CancellationToken.None).ConfigureAwait(false);
48+
}
1049
}
1150
}

0 commit comments

Comments
 (0)