Hi,

There used to be a method MethodBody.Simplify() which turns all the
"short-form" CIL instructions into the 32-bit long forms, which made
code analysis and manipulation quite a bit easier. This method seems
to have gone.

If the method is now on a different type, where is it? If the method
no longer exists, what is the rationale? Is there some sort of
recommended practice to make handling CIL easier even without the
simplification step?

Many thanks for your help,
Timwi

P.S.: Since I like Mono.Cecil, and I've received a lot of help here,
I'd like to give something back. I've written a .ToString() method for
the Mono.Cecil.Cil.Instruction class, which up until now didn't have
one. I find this very useful in debugging. Here it is. Incorporate
into Mono.Cecil as you please.

        public override string ToString()
        {
            string operand;
            if (Operand == null)
                operand = "";
            else if (Operand is Instruction)
                operand = " [" + ((Instruction) Operand).Offset + "]";
            else if (Operand is Instruction[])
            {
                var instrs = (Instruction[]) Operand;
                var offsets = new string[instrs.Length];
                for (int i = 0; i < instrs.Length; i++)
                    offsets[i] = instrs[i].Offset.ToString();
                operand = " [" + string.Join(", ", offsets) + "]";
            }
            else
                operand = " [" + Operand.ToString() + "]";

            return "(" + Offset + ")  " +
OpCode.Code.ToString().ToLowerInvariant().Replace('_', '.') + operand;
        }

-- 
--
mono-cecil

Reply via email to