From 6474e036ac47b18631ed6c9e5077b75870937ba4 Mon Sep 17 00:00:00 2001 From: Alex de la Mare Date: Sat, 5 Sep 2020 21:29:04 +1000 Subject: [PATCH] [3.2] Handle csproj "Remove" globs MSBuild Item returns empty strings if an attribute isn't set (which caused an IndexOutOfRangeException in NormalizePath). We were treating Excludes incorrectly, Remove directives provide the intended behaviour in the auto-including csproj format. --- .../editor/GodotTools/GodotTools.Core/StringExtensions.cs | 3 +++ .../GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs b/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs index ae2dbbf58d5..05e06babd42 100644 --- a/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs +++ b/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs @@ -23,6 +23,9 @@ namespace GodotTools.Core public static string NormalizePath(this string path) { + if (string.IsNullOrEmpty(path)) + return path; + bool rooted = path.IsAbsolutePath(); path = path.Replace('\\', '/'); diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs index 92bc6472bbf..43c28ae8252 100644 --- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs +++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs @@ -188,9 +188,10 @@ namespace GodotTools.ProjectEditor if (item.ItemType != itemType) continue; - string normalizedExclude = item.Exclude.NormalizePath(); - var glob = MSBuildGlob.Parse(normalizedExclude); + string normalizedRemove= item.Remove.NormalizePath(); + + var glob = MSBuildGlob.Parse(normalizedRemove); excluded.AddRange(result.Where(includedFile => glob.IsMatch(includedFile))); }