.NET 7 support
Hi, is there any plans for the .NET 7 to be supported ? We're actually using Harmony in one of our unit testing stack to patch some methods (that we couldn't mock the easy way), but Harmony cannot support .NET 7 until this is updated to support it, as far as I understand.
It seems like there's a pull request available here #27+ would someone know the status for it ?
Thanks a lot.
.NET 7 support in MonoMod.Common is not going to be supported for two reasons:
-
MonoMod.Common is being dropped. It is still "current" for now purely because its replacement does not yet have complete platform support parity (namely, lacking any amount of support for MacOS). Its replacement is available as the
reorganizebranch of the main MonoMod repository, and asMonoModReorgon NuGet.MonoMod.Coreis a sort of spiritual successor to MonoMod.Common, though it exists only as an actual managed library rather than a set of source files. This rewrite was done so that MonoMod has an architecture which is easier to work with, both when it comes to implementing support for newer runtimes, operating systems, architectures and features. This ties into.... -
MonoMod.Common's architecture is not exactly amenable to the changes that are required for proper .NET 7 support. It just so happens that
reorganize's architecture, which was designed primarily for the W^X requirement of the Apple M1, also enables fairly simple support for .NET 7.The reason .NET 7 is difficult to support actually has to do with its own W^X support. The JIT interface was changed somewhat, so that the runtime can copy new code into place in one operation. MonoMod's own JIT hooks therefore require changes to accommodate that, and it turns out that those changes are incredibly difficult with the old design.
Note that the above explanations are the 100-foot overview. If you want more details, I can provide them, though it dives pretty heavily into both MonoMod and .NET runtime internals.
If you want more details, I can provide them, though it dives pretty heavily into both MonoMod and .NET runtime internals.
As a completely unrelated interested party with some significant knowledge of language runtimes and FOSS-maintenance-API-design topics, I'd love to hear more about those changes.
Don't waste your time just for me, but if there's already a design document, blog post, sth else you could link to, I'd absolutely lap it up ...
Edit: Because it was hard enough Googling up resources on this, some interesting references:
- The .NET design document on
W^X(pronounced "read OR write", by the way, not "doubleyou raised to the ex" 😉); - Apple's documentation on porting JITs to Apple Silicon (shockingly detailed, tbh?) give a good summary of the problem, and how 'something like Harmony' (ish) can fix it.
Of course, personally no idea why the old MonoMod.Core is unamenable to the required 'mark writable, write, mark executable' dance; the above is just my limited-outsider-couple-of-hours-research; and I am interested in the changes required that're going into your reorg. (=
Edit 2: Okay, managed to find out a lot more for myself. More useful links, for anybody following along at home: https://github.com/MonoMod/MonoMod/blob/853dbd08/docs/Core/CoreCLRJitHooks.md and https://github.com/MonoMod/MonoMod/blob/853dbd0/docs/Core/Architecture.md from the reorganize branch (why didn't I look there first!? my documentation-expectations of FOSS are clearly calibrated too low.); and this detailed message breaking down the remaining work from @nike4613 in the Harmony Discord.