Show / Hide Table of Contents

Class HarmonyMethod

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

Inheritance
object
HarmonyMethod
Namespace: HarmonyLib
Assembly: 0Harmony.dll
Syntax
public class HarmonyMethod

Constructors

HarmonyMethod()

Default constructor

Declaration
public HarmonyMethod()

HarmonyMethod(Delegate)

Creates a patch from a given method

Declaration
public HarmonyMethod(Delegate @delegate)
Parameters
Type Name Description
Delegate delegate

The original method

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

Creates a patch from a given method

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

The original method

int priority

The patch Priority

string[] before

A list of harmony IDs that should come after this patch

string[] after

A list of harmony IDs that should come before this patch

bool? debug

Set to true to generate debug output

HarmonyMethod(MethodInfo)

Creates a patch from a given method

Declaration
public HarmonyMethod(MethodInfo method)
Parameters
Type Name Description
MethodInfo method

The original method

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

Creates a patch from a given method

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

The original method

int priority

The patch Priority

string[] before

A list of harmony IDs that should come after this patch

string[] after

A list of harmony IDs that should come before this patch

bool? debug

Set to true to generate debug output

HarmonyMethod(Type, string, Type[])

Creates a patch from a given method

Declaration
public HarmonyMethod(Type methodType, string methodName, Type[] argumentTypes = null)
Parameters
Type Name Description
Type methodType

The patch class/type

string methodName

The patch method name

Type[] argumentTypes

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

Fields

after

Install this patch after patches with these Harmony IDs

Declaration
public string[] after
Field Value
Type Description
string[]

argumentTypes

Array of argument types of the patch method

Declaration
public Type[] argumentTypes
Field Value
Type Description
Type[]

before

Install this patch before patches with these Harmony IDs

Declaration
public string[] before
Field Value
Type Description
string[]

category

Patch Category

Declaration
public string category
Field Value
Type Description
string

debug

Create debug output for this patch

Declaration
public bool? debug
Field Value
Type Description
bool?

declaringType

Class/type declaring this patch

Declaration
public Type declaringType
Field Value
Type Description
Type

method

The original method

Declaration
public MethodInfo method
Field Value
Type Description
MethodInfo

methodName

Patch method name

Declaration
public string methodName
Field Value
Type Description
string

methodType

Optional patch MethodType

Declaration
public MethodType? methodType
Field Value
Type Description
MethodType?

nonVirtualDelegate

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

Declaration
public bool nonVirtualDelegate
Field Value
Type Description
bool

priority

Priority of the patch

Declaration
public int priority
Field Value
Type Description
int

reversePatchType

Reverse patch type, see HarmonyReversePatchType

Declaration
public HarmonyReversePatchType? reversePatchType
Field Value
Type Description
HarmonyReversePatchType?

Methods

HarmonyFields()

Gets the names of all internal patch info fields

Declaration
public static List<string> HarmonyFields()
Returns
Type Description
List<string>

A list of field names

Merge(List<HarmonyMethod>)

Merges annotations

Declaration
public static HarmonyMethod Merge(List<HarmonyMethod> attributes)
Parameters
Type Name Description
List<HarmonyMethod> attributes

The list of HarmonyMethod to merge

Returns
Type Description
HarmonyMethod

The merged HarmonyMethod

ToString()

Returns a string that represents the annotation

Declaration
public override string ToString()
Returns
Type Description
string

A string representation

Overrides
object.ToString()

Operators

implicit operator HarmonyMethod(Delegate)

Creates a patch from a given method

Declaration
public static implicit operator HarmonyMethod(Delegate @delegate)
Parameters
Type Name Description
Delegate delegate

The original method

Returns
Type Description
HarmonyMethod

implicit operator HarmonyMethod(MethodInfo)

Creates a patch from a given method

Declaration
public static implicit operator HarmonyMethod(MethodInfo method)
Parameters
Type Name Description
MethodInfo method

The original method

Returns
Type Description
HarmonyMethod

Extension Methods

HarmonyMethodExtensions.Clone(HarmonyMethod)
HarmonyMethodExtensions.CopyTo(HarmonyMethod, HarmonyMethod)
HarmonyMethodExtensions.Merge(HarmonyMethod, HarmonyMethod)
In this article
Back to top Generated by DocFX