As requirement, I need to replace newobj instruction with static method call. But, it may be helpful in future to have replacer for all instructions.
TryReplaceInstruction( OpCodes.Newobj, OnNewobjectCall );
var strange = new Object();
// ...
var TType OnNewobjectCall(TypeHandler type)
{
if(type == typeof(object).TypeHandler)
{
Console.WriteLine(Type.FromTypeHandler(type).Name);
}
return new object();
}
As requirement, I need to replace
newobjinstruction with static method call. But, it may be helpful in future to have replacer for all instructions.