Merge pull request #78218 from raulsntos/dotnet/reserved-assembly-name

C#: Avoid GodotSharp as project assembly name
This commit is contained in:
Rémi Verschelde 2023-06-15 15:26:22 +02:00
commit 58416245ce
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 11 additions and 2 deletions

View File

@ -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;
}