summaryrefslogtreecommitdiffstats
path: root/modules/mono/utils/path_utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/utils/path_utils.cpp')
-rw-r--r--modules/mono/utils/path_utils.cpp23
1 files changed, 23 insertions, 0 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