When a method has been implemented on an interface directly as opposed to in a class implementing that interface, there appears to be no way to patch it. Instead there is an exception raised that says "Owner can't be an array or an interface."
Repro:
interface IFoo
{
public void FooImpl();
public void Foo() { FooImpl(); }
}
class Foo : IFoo
{
public void FooImpl() { Console.WriteLine("Foo"); }
}
[HarmonyPatch(typeof(IFoo), nameof(IFoo.Foo))]
static class FooPatch
{
static void Prefix(IFoo __instance) { Console.WriteLine("Bar"); }
}
When a method has been implemented on an interface directly as opposed to in a class implementing that interface, there appears to be no way to patch it. Instead there is an exception raised that says "Owner can't be an array or an interface."
Repro: