You may have seen it, but what does it actually do? Do I need to add them?
When we write IL macros, we emit instruction after instruction to the method body. Instruction, is operation to do (e.g. math operations, load\store, invocations etc.) and it may have operand. The instruction is 1-byte or 2-bytes length.
Lets look on an example of loading method argument:
ldarg is a 2-bytes instruction – FE 09 – that takes 2-bytes operand with the argument index to load.
But methods are rarely have more than a few arguments and we don’t really need a 2-bytes operand.
For this we have
ldarg.s . meaning, a short form that takes only 1-byte for the argument index.
(actually there is a 1-byte ldarg.0, ldarg.1, ldarg.2, ldarg.3 beacuse they are used very often).
Cecil takes care for this optimization by calling
SimplifyMacros in the other hand, is the opposite. You need it when you rewrite an existing method. Because you may change the number of arguments\local variables\methods bytes, and it may affect the short form instruction.
So before you start to rewrite, call
SimplifyMacros and when you finish, call
That all for now 🙂