public void ByRefResultPrefix()
        {
            var originalClass = typeof(Assets.Class11);

            Assert.IsNotNull(originalClass);

            var originalMethod = originalClass.GetMethod(nameof(Assets.Class11.TestMethod));

            Assert.IsNotNull(originalMethod);

            var patchClass = typeof(Assets.Class11Patch);

            Assert.IsNotNull(patchClass);

            var prefix = patchClass.GetMethod(nameof(Assets.Class11Patch.Prefix));

            Assert.IsNotNull(prefix);

            var harmonyInstance = new Harmony("test");

            Assert.IsNotNull(harmonyInstance);

            var patchResult = harmonyInstance.Patch(originalMethod, new HarmonyMethod(prefix));

            // Assert.IsNotNull(patchResult);

            var instance = new Assets.Class11();
            var result   = instance.TestMethod(0);

            Assert.IsFalse(instance.originalMethodRan);
            Assert.IsTrue(Assets.Class11Patch.prefixed);

            Assert.AreEqual("patched", result);
        }
Exemple #2
0
        public static string Want(Class11 a, int b)
        {
            string text = null;

            if (!Test(ref text, b))
            {
                goto skip;
            }
            originalMethodRanS = true;
            return("original" + b);

skip:
            return(text);
        }