summaryrefslogtreecommitdiffstats
path: root/modules/mono/utils
diff options
context:
space:
mode:
authorRaul Santos <raulsntos@gmail.com>2023-06-15 11:41:56 +0200
committerRaul Santos <raulsntos@gmail.com>2023-06-15 11:43:35 +0200
commit7a031be7695aa991daa4696930f0ebf6bb46ecb4 (patch)
tree05de6719af06e4362f5169183b7bad102c882f7a /modules/mono/utils
parent773414606079fa745d1c37fce49324ab6a09e972 (diff)
downloadredot-engine-7a031be7695aa991daa4696930f0ebf6bb46ecb4.tar.gz
C#: Avoid GodotSharp as project assembly name
The name GodotSharp conflicts with the name of the Godot assembly, this causes a cyclic dependency.
Diffstat (limited to 'modules/mono/utils')
-rw-r--r--modules/mono/utils/path_utils.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp
index 7b3f212734..a720c81faf 100644
--- a/modules/mono/utils/path_utils.cpp
+++ b/modules/mono/utils/path_utils.cpp
@@ -232,10 +232,12 @@ String relative_to(const String &p_path, const String &p_relative_to) {
return relative_to_impl(path_abs_norm, relative_to_abs_norm);
}
+const Vector<String> reserved_assembly_names = { "GodotSharp", "GodotSharpEditor", "Godot.SourceGenerators" };
+
String get_csharp_project_name() {
- String name = ProjectSettings::get_singleton()->get_setting_with_override("dotnet/project/assembly_name");
+ String name = GLOBAL_GET("dotnet/project/assembly_name");
if (name.is_empty()) {
- name = ProjectSettings::get_singleton()->get_setting_with_override("application/config/name");
+ name = GLOBAL_GET("application/config/name");
Vector<String> invalid_chars = Vector<String>({ //
// Windows reserved filename chars.
":", "*", "?", "\"", "<", ">", "|",
@@ -248,9 +250,16 @@ String get_csharp_project_name() {
name = name.replace(invalid_chars[i], "-");
}
}
+
if (name.is_empty()) {
name = "UnnamedProject";
}
+
+ // Avoid reserved names that conflict with Godot assemblies.
+ if (reserved_assembly_names.has(name)) {
+ name += "_";
+ }
+
return name;
}