summaryrefslogtreecommitdiffstats
path: root/modules/mono/utils
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/utils')
-rw-r--r--modules/mono/utils/path_utils.cpp23
-rw-r--r--modules/mono/utils/path_utils.h3
2 files changed, 25 insertions, 1 deletions
diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp
index b5a3816ed7..7b3f212734 100644
--- a/modules/mono/utils/path_utils.cpp
+++ b/modules/mono/utils/path_utils.cpp
@@ -231,4 +231,27 @@ String relative_to(const String &p_path, const String &p_relative_to) {
return relative_to_impl(path_abs_norm, relative_to_abs_norm);
}
+
+String get_csharp_project_name() {
+ String name = ProjectSettings::get_singleton()->get_setting_with_override("dotnet/project/assembly_name");
+ if (name.is_empty()) {
+ name = ProjectSettings::get_singleton()->get_setting_with_override("application/config/name");
+ Vector<String> invalid_chars = Vector<String>({ //
+ // Windows reserved filename chars.
+ ":", "*", "?", "\"", "<", ">", "|",
+ // Directory separators.
+ "/", "\\",
+ // Other chars that have been found to break assembly loading.
+ ";", "'", "=", "," });
+ name = name.strip_edges();
+ for (int i = 0; i < invalid_chars.size(); i++) {
+ name = name.replace(invalid_chars[i], "-");
+ }
+ }
+ if (name.is_empty()) {
+ name = "UnnamedProject";
+ }
+ return name;
+}
+
} // namespace path
diff --git a/modules/mono/utils/path_utils.h b/modules/mono/utils/path_utils.h
index 25d130fc58..fc043c3f15 100644
--- a/modules/mono/utils/path_utils.h
+++ b/modules/mono/utils/path_utils.h
@@ -31,7 +31,6 @@
#ifndef MONO_PATH_UTILS_H
#define MONO_PATH_UTILS_H
-#include "core/string/string_builder.h"
#include "core/string/ustring.h"
namespace path {
@@ -58,6 +57,8 @@ String abspath(const String &p_path);
String realpath(const String &p_path);
String relative_to(const String &p_path, const String &p_relative_to);
+
+String get_csharp_project_name();
} // namespace path
#endif // MONO_PATH_UTILS_H