BepInEx / HarmonyX

Harmony built on top of MonoMod.RuntimeDetours with additional features
MIT License
329 stars 42 forks source link

Leaking Mono.Cecil.* types from the vanilla Harmony #67

Open Aragas opened 1 year ago

Aragas commented 1 year ago

Hello! I'm trying to switch the Bannerlord's ecosystem to HarmonyX, but there are mods that use publicly available Mono.Cecil.* types like Mono.Cecil.ModuleDefinition from the 0Harmony.dll assembly. Could Type Forwarding be added similar to how BepinEx does that? (https://github.com/BepInEx/BepInEx.MelonLoader.Loader/tree/master/MelonLoader/BackwardsCompatibility/ForwardingAttributes)

ManlyMarco commented 1 year ago

Which version of Harmony is currently being used? Are you using BepInEx or a different modding framework? (in which case, do you have the 0Harmony20 shim?)

Aragas commented 1 year ago

Harmony 2.2.2. BepinEx is not used, but we'll make our own loader soon, as we need to support both .NET Framework 472 and .NET Core 3.1 versions of the game. I already ported the type forwarding locally and I do confirm that this fixed the type leakage

Aragas commented 1 year ago

There are some patching behaviour issues I noticed. Reverse patcher's transpilers inject the wrong method with the MethodBase method parameter. Vanilla Harmony returns the method that is being reverse-patched, HarmonyX returns the blank method that is used for the IL injection