From 1db039595088d1f16b15a82950470c9b38c1bb17 Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Sun, 13 Sep 2020 03:44:29 +0200 Subject: C#: Fix csproj not synced on file move/removal from FS dock When NormalizePath was called with an absolute path (with drive letter) on Windows, it would prepend a file path separator to the path, e.g.: '\C:\Program Files\'. Apparently this was still accepted as a valid path by DotNetGlob and it stopped working when we switched to MSBuildGlob. --- .../editor/GodotTools/GodotTools.Core/StringExtensions.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'modules/mono') diff --git a/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs b/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs index 05e06babd4..b217ae4bf7 100644 --- a/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs +++ b/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Runtime.InteropServices; namespace GodotTools.Core { @@ -35,7 +36,17 @@ namespace GodotTools.Core path = string.Join(Path.DirectorySeparatorChar.ToString(), parts).Trim(); - return rooted ? Path.DirectorySeparatorChar + path : path; + if (!rooted) + return path; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + string maybeDrive = parts[0]; + if (maybeDrive.Length == 2 && maybeDrive[1] == ':') + return path; // Already has drive letter + } + + return Path.DirectorySeparatorChar + path; } private static readonly string DriveRoot = Path.GetPathRoot(Environment.CurrentDirectory); @@ -49,7 +60,7 @@ namespace GodotTools.Core public static string ToSafeDirName(this string dirName, bool allowDirSeparator = false) { - var invalidChars = new List { ":", "*", "?", "\"", "<", ">", "|" }; + var invalidChars = new List {":", "*", "?", "\"", "<", ">", "|"}; if (allowDirSeparator) { -- cgit v1.2.3