diff options
| author | RedworkDE <10944644+RedworkDE@users.noreply.github.com> | 2023-03-06 21:39:24 +0100 |
|---|---|---|
| committer | RedworkDE <10944644+RedworkDE@users.noreply.github.com> | 2023-06-14 21:07:58 +0200 |
| commit | 92f13ba9ea9f18425c36a2e738cc9102f6151fa9 (patch) | |
| tree | d71271ab47994e12e826779b90523cebe85f6dfe /modules/mono/utils/path_utils.cpp | |
| parent | 33957aee69683cf1f542a8622e5a9efd23070f1c (diff) | |
| download | redot-engine-92f13ba9ea9f18425c36a2e738cc9102f6151fa9.tar.gz | |
C#: Unify project name handling and fix issues with the handling of some special characters
Co-authored-by: Raul Santos <raulsntos@gmail.com>
Diffstat (limited to 'modules/mono/utils/path_utils.cpp')
| -rw-r--r-- | modules/mono/utils/path_utils.cpp | 23 |
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 |
