-
Notifications
You must be signed in to change notification settings - Fork 43
Patch annotations
Geoffrey Horsington edited this page Jan 22, 2020
·
2 revisions
The main way to apply patches is by annotating your patch classes or patch methods with special Harmony attributes. In addition, Harmony supports some special magic methods to handle various aspects of patching.
HarmonyX supports two types of patches: class patches and method patches.
Class patches are defined by annotating a class with HarmonyPatch
attribute, while method patches are defined by annotating each method with HarmonyPatch
.
Please refer to the next subsections for more information on patch annotations. Here's a table that outlines main differences between the two patch types:
Feature | Class patches | Method patches |
---|---|---|
Declared by... | Adding HarmonyPatch attribute to a class
|
Adding HarmonyPatch attribute to a method
|
Supported patch types | Prefixes, postfixes, transpilers, finalizers, reverse patchers | Prefixes, postfixes, transpilers, finalizers |
Additional lifetime methods |
HarmonyPrepare , HarmonyTargetMethod(s) , HarmonyCleanup
|
None |
Applied with | Harmony.PatchAll(Assembly assembly) |
Harmony.PatchAll(Type type) |
- Basic usage
-
HarmonyX extensions
1.1. Patching and unpatching
1.2. Prefixes are flowthrough
1.3. Targeting multiple methods with one patch
1.4. Patching enumerators
1.5. Transpiler helpers
1.6. ILManipulators
1.7. Extended patch targets
1.8. New patch attributes -
Extending HarmonyX
2.1. Custom patcher backends -
Misc
4.1. Patch parameters - Implementation differences from Harmony