Hi,

On Mon, May 2, 2011 at 1:56 AM, Philip_L <[email protected]> wrote:
> Now for some reason, Cecil tries to branch out of the method with the
> following instruction:
>
>  IL_004d:  br.s       IL_ffffffd5
>
> When I step through the code with the debugger and look at the
> original branch instructions, none of those branch instructions ever
> try to jump out of the method. Am I doing something wrong here, or is
> this a bug in Cecil?

I only had a short look. It seems to indicate two things:

1) Either you're not re-adding the operand instruction properly. Make
sure it's in the collection in the debugger:
(instructions.Contains((Instruction)instruction.Operand)).

2) You're injecting too much code in between a small branch and its
target, creating an overflow. By default Cecil lets you do so, but you
can use the pattern:

body.SimplifyMacros ();

// modify body

body.OptimizeMacros ();

Using the methods in Cecil.Rocks.

Jb

-- 
--
mono-cecil

Reply via email to