Skip to content

Commit 07a82cf

Browse files
committed
Update SA1508 tests for attributed local functions
1 parent c6fc6bb commit 07a82cf

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1508CSharp9UnitTests.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;
@@ -93,5 +91,43 @@ public async Task TestMultiLineRecordWithParameterAsync(string keyword)
9391
FixedCode = testCode,
9492
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
9593
}
94+
95+
[Fact]
96+
[WorkItem(3978, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3978")]
97+
public async Task TestLocalFunctionWithAttributePrecededByBlankLineAsync()
98+
{
99+
var testCode = @"using System;
100+
101+
class TestClass
102+
{
103+
void Outer()
104+
{
105+
[Obsolete]
106+
void Local()
107+
{
108+
int value = 0;
109+
110+
{|#0:}|}
111+
}
112+
}
113+
";
114+
115+
var fixedCode = @"using System;
116+
117+
class TestClass
118+
{
119+
void Outer()
120+
{
121+
[Obsolete]
122+
void Local()
123+
{
124+
int value = 0;
125+
}
126+
}
127+
}
128+
";
129+
130+
await VerifyCSharpFixAsync(testCode, Diagnostic().WithLocation(0), fixedCode, CancellationToken.None).ConfigureAwait(false);
131+
}
96132
}
97133
}

0 commit comments

Comments
 (0)