Skip to content

Commit 43d256b

Browse files
committed
Update SA1134 tests for attributed local functions
1 parent e139096 commit 43d256b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1134CSharp9UnitTests.cs

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

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

814
public partial class SA1134CSharp9UnitTests : SA1134CSharp8UnitTests
915
{
16+
[Fact]
17+
[WorkItem(3978, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3978")]
18+
public async Task TestAttributeOnSameLineAsLocalFunctionAsync()
19+
{
20+
var testCode = @"using System;
21+
22+
class TestClass
23+
{
24+
void Outer()
25+
{
26+
{|#0:[|}Attr] void Local()
27+
{
28+
}
29+
}
30+
}
31+
32+
[AttributeUsage(AttributeTargets.All)]
33+
class AttrAttribute : Attribute
34+
{
35+
}
36+
";
37+
38+
var fixedCode = @"using System;
39+
40+
class TestClass
41+
{
42+
void Outer()
43+
{
44+
[Attr]
45+
void Local()
46+
{
47+
}
48+
}
49+
}
50+
51+
[AttributeUsage(AttributeTargets.All)]
52+
class AttrAttribute : Attribute
53+
{
54+
}
55+
";
56+
57+
await VerifyCSharpFixAsync(testCode, Diagnostic().WithLocation(0), fixedCode, CancellationToken.None).ConfigureAwait(false);
58+
}
1059
}
1160
}

0 commit comments

Comments
 (0)