Browse documentation

Class Patch

Namespace
HarmonyLib
Assembly
0Harmony.dll

A serializable patch

public class Patch
Inheritance
object
Patch

Constructors

Patch(HarmonyMethod, int, string)

Creates a patch

public Patch(HarmonyMethod method, int index, string owner)

Parameters

method HarmonyMethod

The method of the patch

index int

Zero-based index

owner string

An owner (Harmony ID)

Patch(MethodInfo, int, string, int, string[], string[], bool)

Creates a patch

public Patch(MethodInfo patch, int index, string owner, int priority, string[] before, string[] after, bool debug)

Parameters

patch MethodInfo

The method of the patch

index int

Zero-based index

owner string

An owner (Harmony ID)

priority int

The priority, see Priority

before string[]

A list of Harmony IDs for patches that should run after this patch

after string[]

A list of Harmony IDs for patches that should run before this patch

debug bool

A flag that will log the replacement method via FileLog every time this patch is used to build the replacement, even in the future

Fields

after

Keep this patch after the patches indicated in the list of Harmony IDs

public readonly string[] after

Field Value

string[]

before

Keep this patch before the patches indicated in the list of Harmony IDs

public readonly string[] before

Field Value

string[]

debug

A flag that will log the replacement method via FileLog every time this patch is used to build the replacement, even in the future

public readonly bool debug

Field Value

bool

index

Zero-based index

public readonly int index

Field Value

int

innerMethod

For an infix patch, this defines the inner method that we will apply the patch to

[OptionalField]
public readonly InnerMethod innerMethod

Field Value

InnerMethod

innerTarget

The selected extended operation; method-call patches retain their existing innerMethod representation

[OptionalField]
public readonly InnerTarget innerTarget

Field Value

InnerTarget

owner

The owner (Harmony ID)

public readonly string owner

Field Value

string

priority

The priority, see Priority

public readonly int priority

Field Value

int

Properties

PatchMethod

The method of the static patch method

public MethodInfo PatchMethod { get; set; }

Property Value

MethodInfo

Methods

CompareTo(object)

Determines how patches sort

public int CompareTo(object obj)

Parameters

obj object

The other patch

Returns

int

integer to define sort order (-1, 0, 1)

Equals(object)

Determines whether patches have the same callback. Infix records compare stored module and method identity, without resolving the callback, and are distinct from ordinary patch records. Owners and selectors are not compared.

public override bool Equals(object obj)

Parameters

obj object

The other patch

Returns

bool

true if equal

GetHashCode()

Hash function

public override int GetHashCode()

Returns

int

A hash code

GetMethod(MethodBase)

Get the patch method or a DynamicMethod if original patch method is a patch factory

public MethodInfo GetMethod(MethodBase original)

Parameters

original MethodBase

The original method/constructor

Returns

MethodInfo

The method of the patch

Harmony 3 preview

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