diff options
author | Ignacio Roldán Etcheverry <ignalfonsore@gmail.com> | 2022-10-16 23:55:54 +0200 |
---|---|---|
committer | Ignacio Roldán Etcheverry <ignalfonsore@gmail.com> | 2022-10-17 00:22:48 +0200 |
commit | 2303c267831cdeaec8240a5ac5aca61379a376a1 (patch) | |
tree | 26d4d64599f29b6aa03d57f6ffb654d71d09060b /modules/mono/csharp_script.cpp | |
parent | 3a59c833f1b7e34ddef57522800288a0dee8562d (diff) | |
download | redot-engine-2303c267831cdeaec8240a5ac5aca61379a376a1.tar.gz |
C#: Load assemblies as collectible only in the Godot editor
We use collectible AssemblyLoadContexts as that's the only way to allow
reloading assemblies after building. However, collectible assemblies
have some restrictions:
- https://learn.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/collectible-assemblies#restrictions-on-collectible-assemblies
Those restrictions can cause issues with third-party code, such as some
mocking libraries.
In order to work around this problem, we're going to load assemblies
as collectible only in Godot editor, and not when running games.
These issues will still exist in the editor, but this will be enough
for some users.
Diffstat (limited to 'modules/mono/csharp_script.cpp')
-rw-r--r-- | modules/mono/csharp_script.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 345d2e4694..a4bffc1e3c 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -710,6 +710,12 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { return; } + if (!Engine::get_singleton()->is_editor_hint()) { + // We disable collectible assemblies in the game player, because the limitations cause + // issues with mocking libraries. As such, we can only reload assemblies in the editor. + return; + } + // TODO: // Currently, this reloads all scripts, including those whose class is not part of the // assembly load context being unloaded. As such, we unnecessarily reload GodotTools. |