Skip to content

Commit cde6a7c

Browse files
committed
Update SA1502 tests for attributed local functions
1 parent 516b3c5 commit cde6a7c

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

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

Lines changed: 34 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,39 @@ 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 TestLocalFunctionWithAttributeOnSingleLineAsync()
98+
{
99+
var testCode = @"using System;
100+
101+
class TestClass
102+
{
103+
void Outer()
104+
{
105+
[Obsolete]
106+
void Local(){|#0:{|} int value = 0; }
107+
}
108+
}
109+
";
110+
111+
var fixedCode = @"using System;
112+
113+
class TestClass
114+
{
115+
void Outer()
116+
{
117+
[Obsolete]
118+
void Local()
119+
{
120+
int value = 0;
121+
}
122+
}
123+
}
124+
";
125+
126+
await VerifyCSharpFixAsync(testCode, Diagnostic().WithLocation(0), fixedCode, CancellationToken.None).ConfigureAwait(false);
127+
}
96128
}
97129
}

0 commit comments

Comments
 (0)