Mono: Better handling of missing/outdated API assemblies

Remove the old API assembly invalidation system. It's pretty simple since now the editor has a hard dependency on the API assemblies and SCons takes care of prebuilding them.
If we fail to load a project's API assembly because it was either missing or outdated, we just copy the prebuilt assemblies to the project and try again. We also do this when creating the solution and before building, just in case the user removed them from the disk after they were loaded.
This way the API assemblies will be always loaded successfully. If they are not, it's a bug.

Also fixed:

- EditorDef was behaving like GlobalDef in GodotTools.
- NullReferenceException because we can't serialize System.WeakReference yet. Use Godot.WeakRef in the mean time.
This commit is contained in:
Ignacio Etcheverry
2019-07-11 14:01:25 +02:00
parent 4061e132ff
commit e59ac40712
7 changed files with 262 additions and 552 deletions

View File

@@ -114,15 +114,20 @@ void CSharpLanguage::init() {
gdmono = memnew(GDMono);
gdmono->initialize();
#ifndef MONO_GLUE_ENABLED
WARN_PRINT("This binary is built with `mono_glue=no` and cannot be used for scripting");
#endif
#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED)
// Generate bindings here, before loading assemblies. `initialize_load_assemblies` aborts
// the applications if the api assemblies or the main tools assembly is missing, but this
// is not a problem for BindingsGenerator as it only needs the tools project editor assembly.
List<String> cmdline_args = OS::get_singleton()->get_cmdline_args();
BindingsGenerator::handle_cmdline_args(cmdline_args);
#endif
#ifndef MONO_GLUE_ENABLED
print_line("Run this binary with `--generate-mono-glue path/to/modules/mono/glue`");
#endif
gdmono->initialize_load_assemblies();
#ifdef TOOLS_ENABLED
EditorNode::add_init_callback(&_editor_init_callback);
@@ -710,14 +715,6 @@ bool CSharpLanguage::is_assembly_reloading_needed() {
return false; // No assembly to load
}
#ifdef TOOLS_ENABLED
if (!gdmono->get_core_api_assembly() && gdmono->metadata_is_api_assembly_invalidated(APIAssembly::API_CORE))
return false; // The core API assembly to load is invalidated
if (!gdmono->get_editor_api_assembly() && gdmono->metadata_is_api_assembly_invalidated(APIAssembly::API_EDITOR))
return false; // The editor API assembly to load is invalidated
#endif
return true;
}