Fix MakerCardSave applying patches multiple times in some cases #92
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
IllusionMods/IllusionModdingAPI!92
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-mcs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull Request Overview
This PR fixes an issue where
MakerCardSavepatches were being applied multiple times. The fix refactors the patching logic from using HarmonyTranspiler attributes to explicit patching in the static constructor, ensuring patches are only applied once during class initialization.Key Changes:
FindSaveMethodfrom a transpiler that patches as a side effect to a pure method that returns the target methodTip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
The error message should include the exception details. Consider using LogError overload that accepts the exception as a second parameter, or use string interpolation to include the full exception information:
KoikatuAPI.Logger.LogError($\"Patching MakerCardSave failed! {e.Message}\", e);@ -70,38 +72,29 @@ namespace KKAPI.Makeril.GotoNext(instruction => instruction.MatchLdftn(out targetMethodReference));The error message should provide more context about what was expected versus what was found. Consider:
throw new ArgumentException($\"Expected MethodReference but found {code.Operand?.GetType().FullName ?? \"null\"}\");