| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Update `FxCoreBaseRuntime.Compile` to pass generic type arguments to `RuntimeHelpers.PrepareMethod` when the method is declared on a generic type. This ensures that the runtime prepares the correct method instantiation. Add unit tests `Test_GenericClassDetour` and `Test_GenericClassDetourWithoutGenericParameter` to `DetourTest` to verify detours on generic types.
There was a problem hiding this comment.
We do not support patching generics at all at the moment, and while I'm perfectly willing to take improvements in this area, this is an extremely difficult area, and I doubt this fixes the fundamental problem.
Sorry, something went wrong.
| Assert.Equal(1, obj1.GetDouble()); | ||
| Assert.Equal(1, obj2.GetDouble()); | ||
|
|
||
| var detour1 = DetourFactory.Current.CreateDetour(originalMethod1, replacement1); |
There was a problem hiding this comment.
This should be in a using block.
Sorry, something went wrong.
| else | ||
| { | ||
| RuntimeHelpers.PrepareMethod(handle); | ||
| } |
There was a problem hiding this comment.
If we're going to try to do any handling of generics, it should be complete, and deal with method instantiations properly as well. As such, the generic type param list construction should probably be its own helper (maybe in utils? There may also already be an appropriate helper somewhere in the JIT hook logic.)
Sorry, something went wrong.
Test Results
Failing runs❌ MonoMod.UnitTest.DetourTest.Test_GenericClassDetour❌ MonoMod.UnitTest.DetourTest.Test_GenericClassDetourWithoutGenericParameter
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Until now, I had to stay on Harmony 2.2.2, because patches on generic types where not working with Harmony 2.3 using MonoMod.Core anymore. This PR would allow to patch them again. I verified in our production app, and am able to apply the patches again.
Changes:
Update FxCoreBaseRuntime.Compile to pass generic type arguments to RuntimeHelpers.PrepareMethod when the method is declared on a generic type. This ensures that the runtime prepares the correct method instantiation.
Add unit tests Test_GenericClassDetour and Test_GenericClassDetourWithoutGenericParameter to DetourTest to verify detours on generic types.