HarmonyX is a runtime method patching library for .NET, forked from Harmony 2 and maintained by BepInEx. It allows modifying existing methods at runtime by injecting prefixes, postfixes, transpilers, finalizers, and IL manipulators. The library is primarily used in game modding, especially for Unity games via BepInEx, but can be used in any .NET application requiring runtime code transformation. The architecture centers on the Harmony class as the public API, which delegates to PatchProcessor and PatchClassProcessor for applying patches. Patches are defined via attributes or programmatically. The core patching backends are ManagedMethodPatcher (for methods with IL bodies) and NativeDetourMethodPatcher (for native/external methods). IL manipulation is handled by HarmonyManipulator, which uses MonoMod.Cil and Mono.Cecil to rewrite method bodies. The library also provides utilities like AccessTools (reflection helpers), Traverse (field/property traversal), CodeMatcher (IL pattern matching), and MethodInvoker (fast delegate invocation). Key data flows: A patch request specifies a target method and patch methods. The PatchManager resolves the appropriate patcher, which creates a detour or IL rewrite. For IL-based patching, the original method body is read via Mono.Cecil, converted to CodeInstruction objects, processed by transpilers and manipulators, and then written back using a custom IL emitter. The patched method then calls the original (or a copy) with the injected code. The library supports complex ordering via priority and before/after attributes, and handles edge cases like generics, value types, ref returns, and async methods. External dependencies include MonoMod.RuntimeDetour, MonoMod.Utils, and Mono.Cecil for IL manipulation. The library targets multiple .NET frameworks (net35, net452, netstandard2.0) and is distributed as a NuGet package (HarmonyX).