Hi,

As an alternative , for an ArrayType I did this
ArrayType arrType = new ArrayType(type.GetElementType());
typeRef = (TypeReference)arrType ;
Instruction newIns =   Instruction.Create(ins.OpCode, typeRef );

csk

On Jun 17, 12:14 pm, srcKode <[email protected]> wrote:
> Hi JB ,
>
> I didn't get it but let me explain .
> During my trials on importing a type from one assembly to another
> assembly I tried to import the 'Instruction' class from the cecil
> library to a dummy assembly.
>
> In the Instruction class we have a method ToString()
> which has the code:
>
> case OperandType.InlineSwitch:
>                                 var labels = (Instruction []) operand;
>
> so when you inject the instructions one by one into the target ...the
> operand  here would be Mono.Cecil.Cil.Instruction[] and the underlying
> ElementType 'Mono.Cecil.Cil.Instruction' ... but having imported this
> class to a dummy assembly it should be Dummy.Instruction[] and
> Dummy.Instruction.So I chose to change the element type here.
>
> its works brilliantly.
>
> Now when I try to migrate the code to 0.9.5 I don't see the same
> option.Was there a reason to change it the way it is now?
>
> :)
> csk
>
> On Jun 17, 11:32 am, Jb Evain <[email protected]> wrote:
>
> > Hi,
>
> > On Fri, Jun 17, 2011 at 8:27 AM, srcKode <[email protected]> wrote:
> > > Is there a way possible to change the underlying Type of an
> > > Instruction Operand in 0.9.5.
>
> > > In the earlier version  of cecil I had used it as shown below
>
> > > ((Mono.Cecil.TypeSpecification)(ins.Operand)).ElementType =
> > > type.GetElementType();
>
> > That seems valid code, not clear at all, but valid nonetheless :)
>
> > Jb

-- 
--
mono-cecil

Reply via email to