godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.13k stars 91 forks source link

Add support for C# hot reloading #7746

Open strich opened 1 year ago

strich commented 1 year ago

Describe the project you are working on

Potentially developing a game where the vast majority of the game code will be in C# and will be the primary language used by our code team most of the time.

Describe the problem or limitation you are having in your project

Being unable to make quick small changes to see the effect in-game in real-time drastically reduces in productivity in those scenarios.

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

In any modern C# project (not talking Unity/gamedev here), Visual Studio and Rider supports hot reload. More information here for VS and here for Rider. It is important to note that whilst it is robust it does not cover all cases and will fallback with a warning that a restart is required. The general category of change that requires a restart is anything that adds/changes object signatures (adding properties, methods, etc).

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

Unfortunately I do not have much understanding of how C# integrates into Godot at this stage, but ideally we are able to leverage Visual Studio or Rider directly to support it?

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

No.

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

It's core to the developer experience.

nicolasgustafsson commented 1 year ago

Related: https://github.com/godotengine/godot/issues/67719 https://devblogs.microsoft.com/dotnet/introducing-net-hot-reload/

It seems that .NET 6 and above supports it natively, and it does work currently(changes are applied), but only once. From local testing I can confirm this is the case. I have not managed to get the listed workaround to work and the workaround itself seems a lot more limited than the native support.

NilsMoller commented 1 year ago

Related: godotengine/godot#67719 https://devblogs.microsoft.com/dotnet/introducing-net-hot-reload/

It seems that .NET 6 and above supports it natively, and it does work currently(changes are applied), but only once. From local testing I can confirm this is the case. I have not managed to get the listed workaround to work and the workaround itself seems a lot more limited than the native support.

This seems to be my situation too. Rider shows a notification that the hot reload did not work, even though the first change did. Then any subsequent changes are not reloaded.

Anutrix commented 5 months ago

The runtime added support for applying changes while debugging on Linux/macOS in .NET 8, so a runtime version of .NET 8+ is required when applying code changes for .NET apps running on these operating systems.

Source: https://code.visualstudio.com/docs/csharp/debugging#_supported-projects-and-scenarios I wonder if this is different.