Back to Harmony

Class HarmonyMethod

docs/api/HarmonyLib.HarmonyMethod.html

2.4.2.07.9 KB
Original Source

Class HarmonyMethod

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

Inheritance

System.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
TypeNameDescription
System.Delegatedelegate

The original method

|

HarmonyMethod(Delegate, Int32, String[], String[], Nullable<Boolean>)

Creates a patch from a given method

Declaration
public HarmonyMethod(Delegate delegate, int priority = -1, string[] before = null, string[] after = null, bool? debug = default(bool? ))
Parameters
TypeNameDescription
System.Delegatedelegate

The original method

| | System.Int32 | priority |

The patch Priority

| | System.String[] | before |

A list of harmony IDs that should come after this patch

| | System.String[] | after |

A list of harmony IDs that should come before this patch

| | System.Nullable\ | debug |

Set to true to generate debug output

|

HarmonyMethod(MethodInfo)

Creates a patch from a given method

Declaration
public HarmonyMethod(MethodInfo method)
Parameters
TypeNameDescription
System.Reflection.MethodInfomethod

The original method

|

HarmonyMethod(MethodInfo, Int32, String[], String[], Nullable<Boolean>)

Creates a patch from a given method

Declaration
public HarmonyMethod(MethodInfo method, int priority = -1, string[] before = null, string[] after = null, bool? debug = default(bool? ))
Parameters
TypeNameDescription
System.Reflection.MethodInfomethod

The original method

| | System.Int32 | priority |

The patch Priority

| | System.String[] | before |

A list of harmony IDs that should come after this patch

| | System.String[] | after |

A list of harmony IDs that should come before this patch

| | System.Nullable\ | 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
TypeNameDescription
System.TypemethodType

The patch class/type

| | System.String | methodName |

The patch method name

| | System.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
TypeDescription
System.String[]

argumentTypes

Array of argument types of the patch method

Declaration
public Type[] argumentTypes
Field Value
TypeDescription
System.Type[]

before

Install this patch before patches with these Harmony IDs

Declaration
public string[] before
Field Value
TypeDescription
System.String[]

category

Patch Category

Declaration
public string category
Field Value
TypeDescription
System.String

debug

Create debug output for this patch

Declaration
public bool? debug
Field Value
TypeDescription
System.Nullable\

declaringType

Class/type declaring this patch

Declaration
public Type declaringType
Field Value
TypeDescription
System.Type

method

The original method

Declaration
public MethodInfo method
Field Value
TypeDescription
System.Reflection.MethodInfo

methodName

Patch method name

Declaration
public string methodName
Field Value
TypeDescription
System.String

methodType

Optional patch MethodType

Declaration
public MethodType? methodType
Field Value
TypeDescription
System.Nullable<MethodType>

nonVirtualDelegate

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

Declaration
public bool nonVirtualDelegate
Field Value
TypeDescription
System.Boolean

priority

Priority of the patch

Declaration
public int priority
Field Value
TypeDescription
System.Int32

reversePatchType

Reverse patch type, see HarmonyReversePatchType

Declaration
public HarmonyReversePatchType? reversePatchType
Field Value
TypeDescription
System.Nullable<HarmonyReversePatchType>

Methods

HarmonyFields()

Gets the names of all internal patch info fields

Declaration
public static List<string> HarmonyFields()
Returns
TypeDescription
System.Collections.Generic.List\

A list of field names

|

Merge(List<HarmonyMethod>)

Merges annotations

Declaration
public static HarmonyMethod Merge(List<HarmonyMethod> attributes)
Parameters
TypeNameDescription
System.Collections.Generic.List<HarmonyMethod>attributes

The list of HarmonyMethod to merge

|

Returns
TypeDescription
HarmonyMethod

The merged HarmonyMethod

|

ToString()

Returns a string that represents the annotation

Declaration
public override string ToString()
Returns
TypeDescription
System.String

A string representation

|

Overrides

System.Object.ToString()

Operators

Implicit(Delegate to HarmonyMethod)

Creates a patch from a given method

Declaration
public static implicit operator HarmonyMethod(Delegate delegate)
Parameters
TypeNameDescription
System.Delegatedelegate

The original method

|

Returns
TypeDescription
HarmonyMethod

Implicit(MethodInfo to HarmonyMethod)

Creates a patch from a given method

Declaration
public static implicit operator HarmonyMethod(MethodInfo method)
Parameters
TypeNameDescription
System.Reflection.MethodInfomethod

The original method

|

Returns
TypeDescription
HarmonyMethod

Extension Methods

HarmonyMethodExtensions.CopyTo(HarmonyMethod, HarmonyMethod)

HarmonyMethodExtensions.Clone(HarmonyMethod)

HarmonyMethodExtensions.Merge(HarmonyMethod, HarmonyMethod)