HarmonyX icon indicating copy to clipboard operation
HarmonyX copied to clipboard

Empty Harmony Annotations Cause ArguementException: No Target Method Found

Open RobbinBob opened this issue 1 year ago • 3 comments

Ran into an issue where defining a class and then using the [HarmonyPatch] attribute on that class, to mark the class or contents as a patch, then completing the attributes on the individual methods. Doing it this way causes it to throw an ArguementException error as the empty HarmonyPatch attribute is not treated as a flag and instead causes it to fail.

Incomplete code example showing a class with that attribute workflow:

[HarmonyPatch] // Seems to error here
internal static class PatchContainer
{
  [HarmonyPrefix]
  [HarmonyPatch(typeof(Type...), nameof(Method...))]
  private static bool SomeMethod_Prefix()...

This workflow should be fine as HarmonyX wiki specifies it replicates the same system Harmony uses, even pointing to documentation showcasing this workflow

RobbinBob avatar Dec 17 '23 04:12 RobbinBob

How are you patching? Does the exact same code run fine under normal Harmony?

ManlyMarco avatar Dec 17 '23 11:12 ManlyMarco

Using .PatchAll

Yes it works fine on regular harmony

RobbinBob avatar Dec 18 '23 08:12 RobbinBob