summaryrefslogtreecommitdiffstats
path: root/modules/mono/csharp_script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/csharp_script.cpp')
-rw-r--r--modules/mono/csharp_script.cpp53
1 files changed, 31 insertions, 22 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 53f696ba1b..f46bb7ee84 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -30,7 +30,23 @@
#include "csharp_script.h"
-#include <stdint.h>
+#include "godotsharp_dirs.h"
+#include "managed_callable.h"
+#include "mono_gd/gd_mono_cache.h"
+#include "signal_awaiter_utils.h"
+#include "utils/macros.h"
+#include "utils/naming_utils.h"
+#include "utils/path_utils.h"
+#include "utils/string_utils.h"
+
+#ifdef DEBUG_METHODS_ENABLED
+#include "class_db_api_json.h"
+#endif
+
+#ifdef TOOLS_ENABLED
+#include "editor/editor_internal_calls.h"
+#include "editor/script_templates/templates.gen.h"
+#endif
#include "core/config/project_settings.h"
#include "core/debugger/engine_debugger.h"
@@ -39,33 +55,25 @@
#include "core/os/mutex.h"
#include "core/os/os.h"
#include "core/os/thread.h"
+#include "servers/text_server.h"
#ifdef TOOLS_ENABLED
#include "core/os/keyboard.h"
#include "editor/editor_file_system.h"
-#include "editor/editor_internal_calls.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/inspector_dock.h"
#include "editor/node_dock.h"
-#include "editor/script_templates/templates.gen.h"
-#endif
-
-#ifdef DEBUG_METHODS_ENABLED
-#include "class_db_api_json.h"
#endif
-#include "godotsharp_dirs.h"
-#include "managed_callable.h"
-#include "mono_gd/gd_mono_cache.h"
-#include "servers/text_server.h"
-#include "signal_awaiter_utils.h"
-#include "utils/macros.h"
-#include "utils/naming_utils.h"
-#include "utils/string_utils.h"
+#include <stdint.h>
#define CACHED_STRING_NAME(m_var) (CSharpLanguage::get_singleton()->get_string_names().m_var)
+// Types that will be skipped over (in favor of their base types) when setting up instance bindings.
+// This must be a superset of `ignored_types` in bindings_generator.cpp.
+const Vector<String> ignored_types = { "PhysicsServer2DExtension", "PhysicsServer3DExtension" };
+
#ifdef TOOLS_ENABLED
static bool _create_project_solution_if_needed() {
CRASH_COND(CSharpLanguage::get_singleton()->get_godotsharp_editor() == nullptr);
@@ -736,11 +744,7 @@ bool CSharpLanguage::is_assembly_reloading_needed() {
return false; // Already up to date
}
} else {
- String assembly_name = GLOBAL_GET("dotnet/project/assembly_name");
-
- if (assembly_name.is_empty()) {
- assembly_name = ProjectSettings::get_singleton()->get_safe_project_name();
- }
+ String assembly_name = path::get_csharp_project_name();
assembly_path = GodotSharpDirs::get_res_temp_assemblies_dir()
.path_join(assembly_name + ".dll");
@@ -1245,11 +1249,16 @@ bool CSharpLanguage::setup_csharp_script_binding(CSharpScriptBinding &r_script_b
StringName type_name = p_object->get_class_name();
- // ¯\_(ツ)_/¯
const ClassDB::ClassInfo *classinfo = ClassDB::classes.getptr(type_name);
- while (classinfo && !classinfo->exposed) {
+
+ // This skipping of GDExtension classes, as well as whatever classes are in this list of ignored types, is a
+ // workaround to allow GDExtension classes to be used from C# so long as they're only used through base classes that
+ // are registered from the engine. This will likely need to be removed whenever proper support for GDExtension
+ // classes is added to C#. See #75955 for more details.
+ while (classinfo && (!classinfo->exposed || classinfo->gdextension || ignored_types.has(classinfo->name))) {
classinfo = classinfo->inherits_ptr;
}
+
ERR_FAIL_NULL_V(classinfo, false);
type_name = classinfo->name;