Currently a continue statement is getting decompiled as a goto statement that jumps to a label at the end of the loop. While yes, this is the correct behavior for a continue statement, the placement of the label is not valid in C#, because there is no statement after it. I think that it should be fairly easy to implement this by searching up the AST and locating the first loop statement, if the end of that loop statement is the same as the target of the branch, it is a continue statement. Also, this would still leave situations where a goto statement was used to continue in a loop that is farther up broken, for these I would suggest putting a continue statement at the end of the loop immediately after the label, because this would achieve the desired effect. (and is likely how the code was written to begin with)
A block of code illustrating the issue, as it is currently decompiled:
That should be getting decompiled as:
Now, the second issue is a bit more confusing, so I'll instead start with what the original code would have been.
Currently, this would be missing the continue statement at the end of the outer loop, which is needed for it to be valid C#.
A block of code illustrating the issue, as it is currently decompiled:
for
(
int
i = 0; i < 32; i++)
{
if
(SomeBoolean)
goto
EndOfLoop;
// SomeOtherCodeHere
EndOfLoop:
}
for
(
int
i = 0; i < 32; i++)
{
if
(SomeBoolean)
continue
;
// SomeOtherCodeHere
}
Now, the second issue is a bit more confusing, so I'll instead start with what the original code would have been.
for
(
int
i = 0; i < 32; i++)
{
for
(
int
i2 = 0; i2 < 43; i2++)
{
if
(SomeBoolean)
goto
EndOfOuterLoop;
// SomeOtherCodeHere
}
EndOfOuterLoop:
continue
;
}
Currently, this would be missing the continue statement at the end of the outer loop, which is needed for it to be valid C#.