Hey Jannik,

There's no builtin way to serialize an instruction stream.

The issue is that operands that are targetting a metadata element are
module and context specific (calling a generic method for instance),
so you'll need to include that somehow in your serialization format.

Jb

On Tue, May 12, 2015 at 8:29 AM, Jannk Sam <[email protected]> wrote:
> Hello,
>
>
> I already wrote an email and then found this small discussion area...
>
> I am looking for a simple way saving my method instructions into a file, so
> I can load them up and use them later on.
>
>
> I found a solution to save the opcodes using basic reflection:
>
>
>     [Serializable]
>
>     public class Instruction
>
>     {
>
>         private string _opcode;
>
>
>
>         public OpCode OpCode
>
>         {
>
>             get
>
>             {
>
>                 return
>
>                     typeof (OpCodes).GetFields(BindingFlags.Static |
> BindingFlags.Public)
>
>                         .Where(x => x.FieldType == typeof (OpCode))
>
>                         .Select(x => (OpCode) x.GetValue(null))
>
>                         .First(x => x.Name == _opcode);
>
>             }
>
>             set
>
>             {
>
>                 _opcode = value.Name;
>
>             }
>
>         }
>
>     }
>
>
> But since the operands can have multiple types, is it possible to save them?
>
> Since the Instructions etc. are not serializable, I can’t save the raw
> property, I have to convert it somehow.
>
> Thanks in advance!
>
>
> Jannik
>
> --
> --
> --
> 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.

-- 
-- 
--
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