fix: name the packaging-icon patch signature so it binds beside added overloads - #336
Conversation
… overloads
ProductPackagingContentPatches named IconGenerator.GeneratePackagingIcon by name only. The game has one
method of that name, (string, string, int), but Polyfill rewrites the IL2CPP interop assembly and adds a
(string, string) compatibility overload. With Polyfill installed Harmony cannot choose ("Ambiguous match
found") and MelonLoader skips the whole patch class, so custom product/package visuals and icons are
unpatched. Without Polyfill, and on Mono, it bound as before.
Both patches now name the game's signature. A new test resolves every attribute-declared patch target in
S1API against the referenced game assembly and fails when a name matches no method or more than one. It
catches this only when the referenced interop assembly has the extra overload (as a Polyfill-rewritten one
does); against a stock assembly these two patches already resolved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I pushed 6f9b7cb to remove the redundant introduction in the patch-target test. Kept the explanation of Harmony's argument matching and the XML docs. No runtime changes in this follow-up. Full builds and suites pass: 741 Mono, 721 IL2CPP. |
|
Tested on 0.4.7f7 Mono and IL2CPP. The Harmony prefix and finalizer both bound to GeneratePackagingIcon(string, string, int). The method produced a 128x128 baggie/ogkush icon on the first load and after reloading. CI passed. The combined build of #332, #333, #334, #336 and #337 also passed all 770 Mono and 744 IL2CPP tests. Merged into beta. |
Summary
ProductPackagingContentPatchesnamesIconGenerator.GeneratePackagingIconwithout its argument types. The game has one method of that name,(string, string, int iconSize = 512). Polyfill, which rewrites the IL2CPP interop assembly, adds a(string, string)overload beside it. With Polyfill installed, Harmony can't choose between the two:MelonLoader then skips the whole class, which is all six of its patches (custom product/package visuals and icons).
The change. Both patches name the game's signature,
(string, string, int).A new test,
HarmonyPatchTargetTests, resolves every attribute-declared patch target in S1API against the referenced game assembly. It fails when a name matches no method or more than one. These two were the only failures. It skipsTargetMethod(s)classes and non-method targets. It catches this case only when built against an interop assembly with the extra overload, as a Polyfill-rewritten one has.Polyfill also fixes its side: DooDesch-Mods/ScheduleOne-Polyfill#109.
Compatibility
0Harmony.Validation
Mono
dotnet build S1API.sln -c MonoMelon --no-restore -p:AutomateLocalDeployment=false: 0 errors, 0 warnings.dotnet test ... -c MonoMelon: 741 passed (740 onbetaplus 1 new).IL2CPP
dotnet build S1API.sln -c Il2CppMelon --no-restore -p:AutomateLocalDeployment=false: 0 errors, 0 warnings.dotnet test ... -c Il2CppMelon: 721 passed (720 plus 1 new; it fails without the fix when built against a Polyfill-rewritten interop).Runtime evidence
How it was tested. Automated runs on 0.4.7f7 load a save, teleport to each custom NPC, record whether its model is shown and its network state, return to the menu and load again. They used a combined build of #332 to #339.
I also played the IL2CPP case by hand.
betaas it is: Harmony's patch info shows nothing attached toIconGenerator.GeneratePackagingIconorMultiTypeVisualsSetter.ApplyVisuals.ProductIconManager.GetIconreturns no icon for Drug Expansion's MDMA in a baggie, jar or brick.Documentation
None needed.
🤖 Generated with Claude Code