Description
Instruction.MatchCall() and similar throw NullReferenceException because MonoMod.Utils.Extensions.Is(this MethodReference method, ...) tries to do method.DeclaringType.Whatever() and DeclaringType is null on dynamic methods
Relevant extension methods:
|
public static bool Is(this MethodReference method, string typeFullName, string name) |
|
public static bool Is(this MethodReference method, Type type, string name) |
Example
var dynamicMethod = new System.Reflection.Emit.DynamicMethod("method", typeof(void), [], true);
var dmd = new DynamicMethodDefinition("", null, []);
var il = dmd.GetILProcessor();
var instr = il.Create(OpCodes.Call, dynamicMethod);
instr.MatchCall("TestType", "TestName");
Description
Instruction.MatchCall()and similar throw NullReferenceException becauseMonoMod.Utils.Extensions.Is(this MethodReference method, ...)tries to domethod.DeclaringType.Whatever()andDeclaringTypeis null on dynamic methodsRelevant extension methods:
MonoMod/src/MonoMod.Utils/Extensions.UtilsIL.cs
Line 60 in f2da9f5
MonoMod/src/MonoMod.Utils/Extensions.UtilsIL.cs
Line 77 in f2da9f5
Example