Browse documentation

Class HarmonyMethod

Namespace
HarmonyLib
Assembly
0Harmony.dll

A wrapper around a method to use it as a patch (for example a Prefix)

public class HarmonyMethod
Inheritance
object
HarmonyMethod
Extension Methods

Constructors

HarmonyMethod()

Default constructor

public HarmonyMethod()

HarmonyMethod(Delegate)

Creates a patch from a given method

public HarmonyMethod(Delegate @delegate)

Parameters

delegate Delegate

The original method

HarmonyMethod(Delegate, int, string[], string[], bool?)

Creates a patch from a given method

public HarmonyMethod(Delegate @delegate, int priority = -1, string[] before = null, string[] after = null, bool? debug = null)

Parameters

delegate Delegate

The original method

priority int

The patch Priority

before string[]

A list of harmony IDs that should come after this patch

after string[]

A list of harmony IDs that should come before this patch

debug bool?

Set to true to generate debug output

HarmonyMethod(MethodInfo)

Creates a patch from a given method

public HarmonyMethod(MethodInfo method)

Parameters

method MethodInfo

The original method

HarmonyMethod(MethodInfo, int, string[], string[], bool?)

Creates a patch from a given method

public HarmonyMethod(MethodInfo method, int priority = -1, string[] before = null, string[] after = null, bool? debug = null)

Parameters

method MethodInfo

The original method

priority int

The patch Priority

before string[]

A list of harmony IDs that should come after this patch

after string[]

A list of harmony IDs that should come before this patch

debug bool?

Set to true to generate debug output

HarmonyMethod(Type, string, Type[])

Creates a patch from a given method

public HarmonyMethod(Type methodType, string methodName, Type[] argumentTypes = null)

Parameters

methodType Type

The patch class/type

methodName string

The patch method name

argumentTypes Type[]

The optional argument types of the patch method (for overloaded methods)

Fields

after

Install this patch after patches with these Harmony IDs

public string[] after

Field Value

string[]

argumentTypes

Array of argument types of the patch method

public Type[] argumentTypes

Field Value

Type[]

before

Install this patch before patches with these Harmony IDs

public string[] before

Field Value

string[]

category

Patch Category

public string category

Field Value

string

debug

Create debug output for this patch

public bool? debug

Field Value

bool?

declaringType

Class/type declaring this patch

public Type declaringType

Field Value

Type

infixOuterBody

The body searched by an Infix; null keeps the declared method

public InfixOuterBody? infixOuterBody

Field Value

InfixOuterBody?

innerMethod

The Infix call selector

public InnerMethod innerMethod

Field Value

InnerMethod

innerTarget

The Infix member-operation or literal selector

public InnerTarget innerTarget

Field Value

InnerTarget

method

The original method

public MethodInfo method

Field Value

MethodInfo

methodName

Patch method name

public string methodName

Field Value

string

methodType

Optional patch MethodType

public MethodType? methodType

Field Value

MethodType?

nonVirtualDelegate

Whether to use Call (true) or VirtualCall (false) mechanics for HarmonyDelegate-attributed delegate

public bool nonVirtualDelegate

Field Value

bool

priority

Priority of the patch

public int priority

Field Value

int

reversePatchType

Reverse patch type, see HarmonyReversePatchType

public HarmonyReversePatchType? reversePatchType

Field Value

HarmonyReversePatchType?

Methods

HarmonyFields()

Gets the names of all internal patch info fields

public static List<string> HarmonyFields()

Returns

List<string>

A list of field names

Merge(List<HarmonyMethod>)

Merges annotations

public static HarmonyMethod Merge(List<HarmonyMethod> attributes)

Parameters

attributes List<HarmonyMethod>

The list of HarmonyMethod to merge

Returns

HarmonyMethod

The merged HarmonyMethod

ToString()

Returns a string that represents the annotation

public override string ToString()

Returns

string

A string representation

Operators

implicit operator HarmonyMethod(Delegate)

Creates a patch from a given method

public static implicit operator HarmonyMethod(Delegate @delegate)

Parameters

delegate Delegate

The original method

Returns

HarmonyMethod

implicit operator HarmonyMethod(MethodInfo)

Creates a patch from a given method

public static implicit operator HarmonyMethod(MethodInfo method)

Parameters

method MethodInfo

The original method

Returns

HarmonyMethod
Harmony 3 preview

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