drok / Harmony-CitiesSkylines

Harmony 2.x assembly provider mod for Cities: Skylines
Other
13 stars 3 forks source link

Mods should not UnpatchAll() #10

Closed drok closed 3 years ago

drok commented 3 years ago

The Harmony.UnpatchAll() with a null argument or no argument causes all patches to be removed (globally).

Some mods use this call as a quick an easy way to cleanup at OnDisable() time.

This corrupts the state of the Harmony Mod itself, which needs harmony1 patches to remain installed, as well as it's own exception hooks.

There needs to be a way to disallow mods from performing certain actions, like UnpatchAll(), removing patches applied by the Harmony Mod, or patching the mod itself.

Solution

The correct way to remove the mod's own patches is to give UnpatchAll() the same argument used to instantiate Harmony. Eg. if you have new Harmony("my.mod.name"), unpatch with UnpatchAll("my.mod.name")

drok commented 3 years ago

Issue is detected, reported, and the UnpatchAll() behaviour is blocked as of 0f715f8