Skip to content

NullReferenceException when matching on an instruction with DynamicMethodReference operand #303

@Ved-s

Description

@Ved-s

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

Image

Relevant extension methods:

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");

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions