Skip to content
New issue

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

.NET 7 support #31

Open
Walouh opened this issue Jan 23, 2023 · 2 comments
Open

.NET 7 support #31

Walouh opened this issue Jan 23, 2023 · 2 comments

Comments

@Walouh
Copy link

Walouh commented Jan 23, 2023

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.

@Walouh Walouh changed the title .NET .NET 7 support Jan 23, 2023
@nike4613 nike4613 pinned this issue Jan 25, 2023
@nike4613
Copy link
Contributor

.NET 7 support in MonoMod.Common is not going to be supported for two reasons:

  1. 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 reorganize branch of the main MonoMod repository, and as MonoModReorg on NuGet.

    MonoMod.Core is 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....

  2. 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.

@ELLIOTTCABLE
Copy link

ELLIOTTCABLE commented Feb 28, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants