Skip to content

Commit 1ef093e

Browse files
committed
Update SA1513 tests for attributed local functions
1 parent 07a82cf commit 1ef093e

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

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

Lines changed: 38 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.CSharp9.LayoutRules
75
{
86
using System.Threading;
@@ -65,5 +63,43 @@ public int X
6563
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
6664
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
6765
}
66+
67+
[Fact]
68+
[WorkItem(3978, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3978")]
69+
public async Task TestLocalFunctionRequiresBlankLineAsync()
70+
{
71+
var testCode = @"using System;
72+
73+
class TestClass
74+
{
75+
void Outer()
76+
{
77+
[Obsolete]
78+
void Local()
79+
{
80+
}{|#0:
81+
|} int value = 0;
82+
}
83+
}
84+
";
85+
86+
var fixedCode = @"using System;
87+
88+
class TestClass
89+
{
90+
void Outer()
91+
{
92+
[Obsolete]
93+
void Local()
94+
{
95+
}
96+
97+
int value = 0;
98+
}
99+
}
100+
";
101+
102+
await VerifyCSharpFixAsync(testCode, Diagnostic().WithLocation(0), fixedCode, CancellationToken.None).ConfigureAwait(false);
103+
}
68104
}
69105
}

0 commit comments

Comments
 (0)