godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.1k stars 69 forks source link

C# built in .net runtime #8611

Open PublicVoidUpdate opened 8 months ago

PublicVoidUpdate commented 8 months ago

Describe the project you are working on

Porting c# godot projects to various platforms including the PSVita, the 3Ds and more.

Describe the problem or limitation you are having in your project

The engine of Godot and many of its features are possible to be ported, for example SonicMastr/godot-vita right here on github, but many if not all do not support c#.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

"But if a CIL interpreter that directly talked to Godot was made, it would be possible to add that to Godot as a whole, not just this project, and then Godot wouldn't need the .NET runtime per say. Or, in down-the-river terms, it would help everyone everywhere, official or fork, so you might be able to get more people interested in making/helping on such a thing, not just us who are interested in Godot on a depreciated handheld." - c08oprkiua

This would solve the issue of old handheld consoles because a interpreter would be bundled and wouldnt need an official port, but it would also straight up remove the need for .NET and make any Godot project even more easy to use. And this would fix the Mobile Godot Mono issues.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

similar to Unity's system, a interpreter(or JIT ig) would be built within the exported application.

If this enhancement will not be used often, can it be worked around with a few lines of script?

This cannot be worked around by current methods, the only current solution is to avoid using c# in projects for other consoles. Or in the case of other devices, .NET must be installed alongside the project.

Is there a reason why this should be core and not an add-on in the asset library?

An addon would not be able to provide this functionality afaik, but even so, this would give the Mono branch significantly more compatibility.

PublicVoidUpdate commented 8 months ago

conversation that started this

Delsin-Yu commented 8 months ago

If you are talking about something similar to IL2CPP VM, I doubt it's possible to achieve on that Godot end (Unity itself is tightly integrated with their custom fork of Mono VM where Godot is not).

The NativeAOT publish mode of the modern dotnet (.Net 6+) might be a good entry point. It compiles the CIL directly into native code. However, I think is a long journey to add extra platform support for NativeAOT.

A feasible option would be writing a custom GDExtension plugin or modifying the source code to boot the PSVita built-in dotnet runtime at the initialization level, similar to how Godot mono module bootstrapping the CoreCLR runtime via HostFXR, however, I only have very limited knowledge about how the PSVita built-in dotnet runtime works.

I misunderstood the comment, PSVita does not have a built-in dotnet runtime, so a custom compiler that compiles a subset of C# into native / cpp code is required.