Skip to content

Commit c6fc6bb

Browse files
committed
Update SA1505 tests for attributed local functions
1 parent cde6a7c commit c6fc6bb

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1505CSharp9UnitTests.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;
@@ -28,5 +26,43 @@ public record TestRecord;
2826

2927
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false);
3028
}
29+
30+
[Fact]
31+
[WorkItem(3978, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3978")]
32+
public async Task TestLocalFunctionWithAttributeFollowedByBlankLineAsync()
33+
{
34+
var testCode = @"using System;
35+
36+
class TestClass
37+
{
38+
void Outer()
39+
{
40+
[Obsolete]
41+
void Local()
42+
{|#0:{|}
43+
44+
int value = 0;
45+
}
46+
}
47+
}
48+
";
49+
50+
var fixedCode = @"using System;
51+
52+
class TestClass
53+
{
54+
void Outer()
55+
{
56+
[Obsolete]
57+
void Local()
58+
{
59+
int value = 0;
60+
}
61+
}
62+
}
63+
";
64+
65+
await VerifyCSharpFixAsync(testCode, Diagnostic().WithLocation(0), fixedCode, CancellationToken.None).ConfigureAwait(false);
66+
}
3167
}
3268
}

0 commit comments

Comments
 (0)