C#: Use custom project setting for C# project files name

The setting is initially assigned the name of the Godot project,
but it's kept freezed to prevent issues when renaming the Godot
project.

The user can always rename the C# project and solution manually and
change the setting to the new name.

Co-authored-by: Ignacio Roldán Etcheverry <ignalfonsore@gmail.com>
(cherry picked from commit 31d09a807e)
This commit is contained in:
Raul Santos 2022-08-15 18:51:50 +02:00 committed by Rémi Verschelde
parent cd6764611c
commit 465a6569e4
9 changed files with 65 additions and 31 deletions

View file

@ -722,19 +722,24 @@ bool CSharpLanguage::is_assembly_reloading_needed() {
GDMonoAssembly *proj_assembly = gdmono->get_project_assembly();
String appname = ProjectSettings::get_singleton()->get("application/config/name");
String appname_safe = OS::get_singleton()->get_safe_dir_name(appname);
if (appname_safe.empty()) {
appname_safe = "UnnamedProject";
String assembly_name = ProjectSettings::get_singleton()->get_setting("mono/project/assembly_name");
if (assembly_name.empty()) {
String appname_safe = OS::get_singleton()->get_safe_dir_name(appname);
if (appname_safe.empty()) {
appname_safe = "UnnamedProject";
}
assembly_name = appname_safe;
}
appname_safe += ".dll";
assembly_name += ".dll";
if (proj_assembly) {
String proj_asm_path = proj_assembly->get_path();
if (!FileAccess::exists(proj_asm_path)) {
// Maybe it wasn't loaded from the default path, so check this as well
proj_asm_path = GodotSharpDirs::get_res_temp_assemblies_dir().plus_file(appname_safe);
proj_asm_path = GodotSharpDirs::get_res_temp_assemblies_dir().plus_file(assembly_name);
if (!FileAccess::exists(proj_asm_path))
return false; // No assembly to load
}
@ -742,7 +747,7 @@ bool CSharpLanguage::is_assembly_reloading_needed() {
if (FileAccess::get_modified_time(proj_asm_path) <= proj_assembly->get_modified_time())
return false; // Already up to date
} else {
if (!FileAccess::exists(GodotSharpDirs::get_res_temp_assemblies_dir().plus_file(appname_safe)))
if (!FileAccess::exists(GodotSharpDirs::get_res_temp_assemblies_dir().plus_file(assembly_name)))
return false; // No assembly to load
}