Skip to content

Commit 689c979

Browse files
committed
Add SA1400 test for local functions
1 parent fb67000 commit 689c979

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1400CSharp7UnitTests.cs

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

44
namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules
55
{
6+
using System.Threading;
7+
using System.Threading.Tasks;
68
using StyleCop.Analyzers.Test.MaintainabilityRules;
9+
using Xunit;
710

811
public class SA1400CSharp7UnitTests : SA1400UnitTests
912
{
13+
/// <summary>
14+
/// Verifies that local functions, which do not support access modifiers, do not trigger SA1400.
15+
/// </summary>
16+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
17+
[Fact]
18+
public async Task TestLocalFunctionAsync()
19+
{
20+
var testCode = @"
21+
internal class ClassName
22+
{
23+
public void MethodName()
24+
{
25+
void LocalFunction()
26+
{
27+
}
28+
}
29+
}
30+
";
31+
32+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
33+
}
1034
}
1135
}

0 commit comments

Comments
 (0)