Description
S1116 reports an issue when there is an empty statement after a label at the end of a compound statement. However, this empty statement (semicolon) is required by the syntax.
Repro steps
int[][] a = { new int[] { 1, 2 }, new int[] { 3, 4 } };
foreach (int[] aa in a) {
foreach (int x in aa) {
if (x < 2)
goto next;
}
next:;
}
Expected behavior
S1116 does not report an issue.
Actual behavior
S1116 complains about an empty statement on the line next:;
Apart from that, S907 correctly complains about the goto statement.
Known workarounds
Disable the rule or mark the issue as false positive.
Related information
- C#/VB.NET Plugins version: csharp version 9.30.0.95878
- Visual Studio version: 2022
- MSBuild / dotnet version: .NET 6.0
- SonarScanner for .NET version (if used): SonarScanner for MSBuild 5.14 (.NET Core) with SonarCloud
- Operating System: Windows 10.0.17763.737
Description
S1116 reports an issue when there is an empty statement after a label at the end of a compound statement. However, this empty statement (semicolon) is required by the syntax.
Repro steps
Expected behavior
S1116 does not report an issue.
Actual behavior
S1116 complains about an empty statement on the line
next:;Apart from that, S907 correctly complains about the goto statement.
Known workarounds
Disable the rule or mark the issue as false positive.
Related information