@Ian G: I have compiled the list from ECMA 335 and found out that I can use
List<MethodInfo> mis =
myObject.GetType().GetMethods().Where((MethodInfo mi) =>
{
mi.GetCustomAttributes(typeof(MyAttribute), true).Length > 0;
}
).ToList();
foreach(MethodInfo mi in mis)
{
List<Instruction> lst = ReflectionHelper.ReadIL(mi);
... find useful opcode
FieldInfo fi = mi.Module.ResolveField((int)usefulOpcode.Argument);
object o = fi.GetValue(myObject);
...
}
And the opcode length list is here, if anyone needs it:
Dictionary<OperandType, int> operandSizes
= new Dictionary<OperandType, int>()
{
{OperandType.InlineBrTarget, 4},
{OperandType.InlineField, 4},
{OperandType.InlineI, 4},
{OperandType.InlineI8,8},
{OperandType.InlineMethod,4},
{OperandType.InlineNone,0},
{OperandType.InlineR,8},
{OperandType.InlineSig,4},
{OperandType.InlineString,4},
{OperandType.InlineSwitch,4},
{OperandType.InlineTok,4},
{OperandType.InlineType,4},
{OperandType.InlineVar,2},
{OperandType.ShortInlineBrTarget,1},
{OperandType.ShortInlineI,1},
{OperandType.ShortInlineR,4},
{OperandType.ShortInlineVar,1}
};