Description
ILCursor.Emit(OpCode, Instruction) and ILCursor.Emit(OpCode, Instruction[]) methods don't turn instructions into ILLabels or ILLabel[]s, but the match branch extension methods expect ILLabels or ILLabel[]s, such as x.MatchBr.
Example
This fails the match:
ILCursor c = new(il);
c.Emit(OpCodes.Br, c.Next!);
c.Goto(0);
c.GotoNext(x => x.MatchBr(out _));
This match succeeds:
ILCursor c = new(il);
c.Emit(OpCodes.Br, il.DefineLabel(c.Next!));
c.Goto(0);
c.GotoNext(x => x.MatchBr(out _));
The ILLabel conversion is already done for the source generated emit methods so this works (for other than this issue: #237):
ILCursor c = new(il);
c.EmitBr(c.Next!);
c.Goto(0);
c.GotoNext(x => x.MatchBr(out _));