Browse documentation

Enum MethodDispatchType

Namespace
HarmonyLib
Assembly
0Harmony.dll

Specifies the type of method call dispatching mechanics

public enum MethodDispatchType

Fields

Call = 1

Call the method using static dispatching, regardless of whether method is virtual (including overriden) or non-virtual (including static)

a.k.a. non-virtual dispatching, early binding, or static binding. This directly corresponds with the System.Reflection.Emit.OpCodes.Call instruction.

For both virtual (including overriden) and non-virtual (including static) methods, the exact specified method implementation is called, without virtual/override mechanics.

VirtualCall = 0

Call the method using dynamic dispatching if method is virtual (including overriden)

This is the built-in form of late binding (a.k.a. dynamic binding) and is the default dispatching mechanic in C#. This directly corresponds with the System.Reflection.Emit.OpCodes.Callvirt instruction.

For virtual (including overriden) methods, the instance type's most-derived/overriden implementation of the method is called. For non-virtual (including static) methods, same behavior as Call: the exact specified method implementation is called.

Note: This is not a fully dynamic dispatch, since non-virtual (including static) methods are still called non-virtually. A fully dynamic dispatch in C# involves using the dynamic type (actually a fully dynamic binding, since even the name and overload resolution happens at runtime), which MethodDispatchType does not support.

Harmony 3 preview

For the stable release, read the 2.x documentation.