public void Test_StructInstanceByRef() { var originalClass = typeof(Assets.Struct2); Assert.IsNotNull(originalClass); var originalMethod = originalClass.GetMethod("TestMethod"); Assert.IsNotNull(originalMethod); var patchClass = typeof(Assets.Struct2Patch); Assert.IsNotNull(patchClass); var postfix = patchClass.GetMethod("Postfix"); Assert.IsNotNull(postfix); var harmonyInstance = new Harmony("test"); Assert.IsNotNull(harmonyInstance); var result = harmonyInstance.Patch(originalMethod, null, new HarmonyMethod(postfix)); Assert.IsNotNull(result); var instance = new Assets.Struct2() { s = "before" }; instance.TestMethod("original"); Assert.AreEqual("patched", instance.s); }
public static void Postfix(ref Struct2 __instance) { __instance.s = "patched"; }