Mono/C#: Fix editor using wrong project assembly path in rare cases

We were removing invalid path characters from the
name in C++ code, but the C# editor code wasn't.
This commit is contained in:
Ignacio Etcheverry 2020-08-20 22:34:57 +02:00 committed by Rémi Verschelde
parent 4f96c65e13
commit 8bb48ae57a
3 changed files with 3 additions and 2 deletions

View File

@ -43,7 +43,7 @@ namespace GodotTools.Core
path.StartsWith(DriveRoot, StringComparison.Ordinal); path.StartsWith(DriveRoot, StringComparison.Ordinal);
} }
public static string ToSafeDirName(this string dirName, bool allowDirSeparator) public static string ToSafeDirName(this string dirName, bool allowDirSeparator = false)
{ {
var invalidChars = new List<string> { ":", "*", "?", "\"", "<", ">", "|" }; var invalidChars = new List<string> { ":", "*", "?", "\"", "<", ">", "|" };

View File

@ -430,7 +430,7 @@ namespace GodotTools.Export
private static string DetermineDataDirNameForProject() private static string DetermineDataDirNameForProject()
{ {
var appName = (string)ProjectSettings.GetSetting("application/config/name"); var appName = (string)ProjectSettings.GetSetting("application/config/name");
string appNameSafe = appName.ToSafeDirName(allowDirSeparator: false); string appNameSafe = appName.ToSafeDirName();
return $"data_{appNameSafe}"; return $"data_{appNameSafe}";
} }

View File

@ -45,6 +45,7 @@ namespace GodotTools
get get
{ {
var projectAssemblyName = (string)ProjectSettings.GetSetting("application/config/name"); var projectAssemblyName = (string)ProjectSettings.GetSetting("application/config/name");
projectAssemblyName = projectAssemblyName.ToSafeDirName();
if (string.IsNullOrEmpty(projectAssemblyName)) if (string.IsNullOrEmpty(projectAssemblyName))
projectAssemblyName = "UnnamedProject"; projectAssemblyName = "UnnamedProject";
return projectAssemblyName; return projectAssemblyName;