Browse documentation

Class HarmonyInfix

Namespace
HarmonyLib
Assembly
0Harmony.dll

Selects operations inside the outer patched method for an inner prefix, postfix, or finalizer

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public sealed class HarmonyInfix : HarmonyAttribute
Inheritance
object
Attribute
HarmonyInfix
Inherited Members

Constructors

HarmonyInfix(object)

Selects a non-null string, int, long, float, or double literal load

public HarmonyInfix(object constant)

Parameters

constant object

The exact literal value; its CLR type selects the corresponding IL literal category

HarmonyInfix(Type, InnerTargetKind, params Type[])

Selects newobj instructions for an instance constructor

public HarmonyInfix(Type declaringType, InnerTargetKind kind, params Type[] argumentTypes)

Parameters

declaringType Type

The constructed type

kind InnerTargetKind

Constructor

argumentTypes Type[]

The constructor parameter types

HarmonyInfix(Type, string)

Selects an unambiguous named method

public HarmonyInfix(Type declaringType, string methodName)

Parameters

declaringType Type

The method's declaring type

methodName string

The method name

HarmonyInfix(Type, string, InnerTargetKind, params Type[])

Selects a method, property accessor, or field operation

public HarmonyInfix(Type declaringType, string memberName, InnerTargetKind kind, params Type[] argumentTypes)

Parameters

declaringType Type

The member's declaring type

memberName string

The member name

kind InnerTargetKind

Method, Getter, Setter, FieldRead, or FieldWrite

argumentTypes Type[]

Method or property index parameters, excluding a setter's value; empty for fields

HarmonyInfix(Type, string, params Type[])

Selects a named method with the supplied argument types

public HarmonyInfix(Type declaringType, string methodName, params Type[] argumentTypes)

Parameters

declaringType Type

The method's declaring type

methodName string

The method name

argumentTypes Type[]

The method parameter types

HarmonyInfix(Type, string, Type[], ArgumentType[])

Selects a named method with ref, out, or pointer argument variations

public HarmonyInfix(Type declaringType, string methodName, Type[] argumentTypes, ArgumentType[] argumentVariations)

Parameters

declaringType Type

The method's declaring type

methodName string

The method name

argumentTypes Type[]

The method parameter types

argumentVariations ArgumentType[]

One ArgumentType for each argument type

Properties

OuterBody

Whether to search the selected method or its recognized state-machine body

public InfixOuterBody OuterBody { get; set; }

Property Value

InfixOuterBody

Remarks

Auto leaves ordinary methods unchanged. It selects one body, not lambdas, local functions or other helper methods. Use StateMachineMoveNext(MethodBase) to find that body for GetPatchInfo(MethodBase) or unpatching.

Positions

One-based matches; negative positions count from the end, and empty selects all

public int[] Positions { get; set; }

Property Value

int[]

Remarks

Counts after transpilers, before Infix insertion. Zero, null and missing positions are invalid; at least one match is required. Installation copies the positions, so later edits do not affect installed patches.

Harmony 3

For Harmony 2, read the 2.x documentation.