Skip to content

Commit a826987

Browse files
committed
Document SA1107 behavior anomaly
Closes #2862
1 parent fc44eb9 commit a826987

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1107UnitTests.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules
55
{
66
using System.Threading;
77
using System.Threading.Tasks;
8-
using Microsoft.CodeAnalysis;
98
using Microsoft.CodeAnalysis.Testing;
109
using StyleCop.Analyzers.ReadabilityRules;
11-
using TestHelper;
1210
using Xunit;
1311
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
1412
StyleCop.Analyzers.ReadabilityRules.SA1107CodeMustNotContainMultipleStatementsOnOneLine,
@@ -142,5 +140,31 @@ int i
142140
DiagnosticResult expected = DiagnosticResult.CompilerError("CS1002").WithLocation(7, 14).WithMessage("; expected");
143141
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
144142
}
143+
144+
[Fact]
145+
[WorkItem(2862, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2862")]
146+
public async Task TestEmptyStatementAfterBlockAsync()
147+
{
148+
string testCode = @"
149+
class Program
150+
{
151+
static void Main(string[] args)
152+
{
153+
{
154+
}[|;|]
155+
}
156+
}
157+
";
158+
159+
await new CSharpTest
160+
{
161+
TestCode = testCode,
162+
FixedCode = testCode,
163+
164+
// A code fix is offered even though no changes are applied by it
165+
NumberOfIncrementalIterations = 1,
166+
NumberOfFixAllIterations = 1,
167+
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
168+
}
145169
}
146170
}

0 commit comments

Comments
 (0)