Caves of Qud

Caves of Qud

Harmony Injector
HawkleyFox  [developer] 27 Feb, 2019 @ 10:58pm
Updating Mods made for HarmonyShim to use Harmony Injector
It seems the line you suggest to add to get compatibility going for Harmony Injector isn't working out. I get the following error.

ERROR: 0(36,17) : error 576: Namespace `global::' contains a definition with same name as alias `Harmony'

I've tried different variations after looking at the code for your HarmonyShim backward compatibility namespace and, while it perfectly mocks the API, I always got the following error.

ERROR: 0(36,25) : error 119: Expression denotes a `type', where a `variable', `value' or `method group' was expected

I suspected that the `Harmony` namespace is not getting shadowed by the `using` directive due to the way the in-game C# compiler works; it seems to more-or-less concatenate all C# files used by mods together into one mega-file before compiling it, so there ends up being two `Harmony` identifiers and C# always favors using the namespace instead of the class or alias.

So the compiler thought that when I'm calling `Harmony.Patch`, it thinks I'm trying to get at the Harmony DLL's `Harmony` namespace and not the `HarmonyShim.Harmony` static class.

The fix was to use `using static HarmonyShim.Harmony;` and replacing calls to `Harmony.Patch(...)` with just `Patch(...)`.

Alternatively, using the fully-qualified path should also work: `HarmonyShim.Harmony.Patch(...)`

In case anyone else needs to update their mods for Harmony Injector, one of these options should do the trick. Bonus is it works both with HarmonyShim or Harmony Injector, so full backwards compatibility is retained and no one's game will be broken by updating your mod.
< >
Showing 1-1 of 1 comments
namkazt  [developer] 31 Mar, 2019 @ 10:18pm 
yeah, i just want it less change as possible HarmonyShim.Harmony.Patch(...) should work. i will add it on document some how.
< >
Showing 1-1 of 1 comments
Per page: 1530 50