We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug Pass through postfixes not excuting when have Finalizer
Expected behavior
Transpiler Prefix Finalizer GetNumbers Postfix 0, 20, 30, 99
Screenshots / Code
public class Annotations { private readonly bool _isRunning; public IEnumerable<int> GetNumbers() { Console.WriteLine(nameof(GetNumbers)); yield return 1; yield return 2; yield return 3; } } [HarmonyPatch(typeof(Annotations))] [HarmonyPatch(nameof(Annotations.GetNumbers))] public class AnnotationsPatcher { static AccessTools.FieldRef<Annotations, bool> isRunningRef = AccessTools.FieldRefAccess<Annotations, bool>("_isRunning"); public static void Patch() { var harmony = new Harmony(nameof(AnnotationsPatcher)); harmony.PatchAll(); Console.WriteLine(string.Join(", ", new Annotations().GetNumbers())); } static bool Prefix(Annotations __instance) { Console.WriteLine("Prefix"); return true; } /// <summary>Not working</summary> static IEnumerable<int> Postfix(IEnumerable<int> values) { yield return 0; foreach (var value in values) if (value > 1) yield return value * 10; yield return 99; Console.WriteLine(nameof(Postfix)); } // looks for STDFLD someField and inserts CALL MyExtraMethod before it public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { Console.WriteLine(nameof(Transpiler)); //var found = false; foreach (var instruction in instructions) { //if (instruction.opcode == OpCodes.Stfld && instruction.operand == f_someField) //{ // yield return new CodeInstruction(OpCodes.Call, m_MyExtraMethod); // found = true; //} yield return instruction; } //if (found == false) // ReportError("Cannot find <Stdfld someField> in OriginalType.OriginalMethod"); } public static void Finalizer(Exception __exception) { Console.WriteLine($"{nameof(Finalizer)} {__exception}"); } }
Runtime environment (please complete the following information):
The text was updated successfully, but these errors were encountered:
8108d8a
pardeike
No branches or pull requests
Describe the bug
Pass through postfixes not excuting when have Finalizer
Expected behavior
Screenshots / Code
Runtime environment (please complete the following information):
The text was updated successfully, but these errors were encountered: