I have a switch statement which does not handle all enum values. The IL 
code shows

   L_0069: switch (L_008f, L_024b, L_019c, L_024b, L_024b, L_01ae, L_0257)


L_024b for last return instruction.


After injection L_024b does not exist anymore and I tried to replace L_024b in 
switch statement by new leave instruction (encapsulated code by try finally 
block). 


While looping through values in Operand array of switch instruction all items 
which should contain L_024b are null.


I implemented following code to fix this 

if (instruction.Operand != null && instruction.OpCode == OpCodes.Switch)
        {
          Instruction[] switchInstructions = instruction.Operand as 
Instruction[];
          for (int i = 0; i < switchInstructions.Length; i++)
          {
            var ins = switchInstructions[i];
            if (ins == null)
            {
              switchInstructions[i] = leaveInstruction;
            }
          }
        }



But after saving dll to disk and having a look into IL code with .Net Reflector 
the array still contains L_024b which does not exist anymore.


Has anybody an idea why replacing this instruction reference does not work?

Does anybody know why values in array are null if looking into them via 
debugger, but are not if looking into IL code via reflector? 



-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to