Hey Simon, On Sat, Nov 6, 2010 at 12:47 PM, Simon Cropp <[email protected]> wrote: > var constructorInfo = > typeof(Instruction).GetConstructor(BindingFlags.NonPublic | > BindingFlags.Instance, null, new[] { typeof(OpCode), typeof(object) }, > null); > var newInstruction = > (Instruction)constructorInfo.Invoke(new[] { instruction.OpCode , > instruction.Operand});
Why not using Instruction.Create ? > targetModule.Import(fieldDefinition.FieldType); > //Try really hard to import type > var methodReference = > (MethodReference)newInstruction.Operand; > > targetModule.Import(methodReference.MethodReturnType.ReturnType); > targetModule.Import(methodReference.DeclaringType); > targetModule.Import(methodReference); This sadly doesn't make sense. If you don't reuse the result of Import, you're doing something wrong basically. So basically if you have an Instruction with an Operand being a MethodReference, just create a new Instruction with the result of Import (theMethodReference). Jb -- -- mono-cecil
