diff options
author | therzok <marius.ungureanu@xamarin.com> | 2019-07-21 11:04:56 +0300 |
---|---|---|
committer | therzok <marius.ungureanu@xamarin.com> | 2019-07-22 14:29:44 +0300 |
commit | fb717de70e8a2c6702beb03ea956c7b978302c71 (patch) | |
tree | 6936c7ae1576217677be1a5c92ce93e164cd1e4c /main/src/core/MonoDevelop.Core | |
parent | 0559b083a7c9be3e0b107a6b7b32fb9254847789 (diff) |
[Core] Change the recursive handling of ExpandWildcardFilePath
Instead of doing the recursive matching by manually recursively descending via a parameter, use the filesystem's APIs to check the nested directories to validate the data
Diffstat (limited to 'main/src/core/MonoDevelop.Core')
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs index 7c318c25c1..a1126023c7 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs @@ -862,7 +862,7 @@ namespace MonoDevelop.Projects.MSBuild return CreateEvaluatedItem (context, pinfo, project, sourceItem, include, file, recursiveDir); }; MSBuildProject rootProject = pinfo.GetRootMSBuildProject (); - return ExpandWildcardFilePath (rootProject, rootProject.BaseDirectory, FilePath.Null, false, subpath, func, directoryExcludeRegex); + return ExpandWildcardFilePath (rootProject, rootProject.BaseDirectory, FilePath.Null, subpath, func, directoryExcludeRegex); } static IEnumerable<string> GetIncludesForWildcardFilePath (MSBuildProject project, string path, Regex directoryExcludeRegex = null) @@ -870,7 +870,7 @@ namespace MonoDevelop.Projects.MSBuild var subpath = SplitWildcardFilePath (path); WildcardExpansionFunc<string> func = (file, include, recursiveDir) => include; - return ExpandWildcardFilePath (project, project.BaseDirectory, FilePath.Null, false, subpath, func, directoryExcludeRegex); + return ExpandWildcardFilePath (project, project.BaseDirectory, FilePath.Null, subpath, func, directoryExcludeRegex); } static string[] SplitWildcardFilePath (string path) @@ -883,7 +883,7 @@ namespace MonoDevelop.Projects.MSBuild delegate T WildcardExpansionFunc<T> (string filePath, string include, string recursiveDir); - static IEnumerable<T> ExpandWildcardFilePath<T> (MSBuildProject project, FilePath basePath, FilePath baseRecursiveDir, bool recursive, in ReadOnlySpan<string> filePath, WildcardExpansionFunc<T> func, Regex directoryExcludeRegex) + static IEnumerable<T> ExpandWildcardFilePath<T> (MSBuildProject project, FilePath basePath, FilePath baseRecursiveDir, in ReadOnlySpan<string> filePath, WildcardExpansionFunc<T> func, Regex directoryExcludeRegex) { var res = Enumerable.Empty<T> (); @@ -893,10 +893,10 @@ namespace MonoDevelop.Projects.MSBuild var path = filePath [0]; if (path == "..") - return ExpandWildcardFilePath (project, basePath.ParentDirectory, baseRecursiveDir, recursive, filePath.Slice (1), func, directoryExcludeRegex); + return ExpandWildcardFilePath (project, basePath.ParentDirectory, baseRecursiveDir, filePath.Slice (1), func, directoryExcludeRegex); if (path == ".") - return ExpandWildcardFilePath (project, basePath, baseRecursiveDir, recursive, filePath.Slice (1), func, directoryExcludeRegex); + return ExpandWildcardFilePath (project, basePath, baseRecursiveDir, filePath.Slice (1), func, directoryExcludeRegex); if (directoryExcludeRegex != null && directoryExcludeRegex.IsMatch (basePath.ToString ().Replace ('/', '\\'))) return res; @@ -913,7 +913,12 @@ namespace MonoDevelop.Projects.MSBuild if (baseRecursiveDir.IsNullOrEmpty) baseRecursiveDir = basePath; - return ExpandWildcardFilePath (project, basePath, baseRecursiveDir, true, filePath.Slice (1), func, directoryExcludeRegex); + res = res.Concat (ExpandWildcardFilePath (project, basePath, baseRecursiveDir, filePath.Slice (1), func, directoryExcludeRegex)); + + foreach (var dir in Directory.EnumerateDirectories (basePath, "*", SearchOption.AllDirectories)) + res = res.Concat (ExpandWildcardFilePath (project, dir, baseRecursiveDir, filePath.Slice (1), func, directoryExcludeRegex)); + + return res; } if (filePath.Length == 1) { @@ -932,16 +937,11 @@ namespace MonoDevelop.Projects.MSBuild // The recursive search is done below. if (path.IndexOfAny (wildcards) != -1) { - foreach (var dir in Directory.EnumerateDirectories (basePath, path)) - res = res.Concat (ExpandWildcardFilePath (project, dir, baseRecursiveDir, false, filePath.Slice (1), func, directoryExcludeRegex)); + foreach (var dir in Directory.EnumerateDirectories (basePath, path)) { + res = res.Concat (ExpandWildcardFilePath (project, dir, baseRecursiveDir, filePath.Slice (1), func, directoryExcludeRegex)); + } } else - res = res.Concat (ExpandWildcardFilePath (project, basePath.Combine (path), baseRecursiveDir, false, filePath.Slice (1), func, directoryExcludeRegex)); - } - - if (recursive) { - // Recursive search. Try to match the remaining subpath in all subdirectories. - foreach (var dir in Directory.EnumerateDirectories (basePath)) - res = res.Concat (ExpandWildcardFilePath (project, dir, baseRecursiveDir, true, filePath, func, directoryExcludeRegex)); + res = res.Concat (ExpandWildcardFilePath (project, basePath.Combine (path), baseRecursiveDir, filePath.Slice (1), func, directoryExcludeRegex)); } return res; @@ -996,8 +996,8 @@ namespace MonoDevelop.Projects.MSBuild MSBuildItemEvaluated CreateEvaluatedItem (MSBuildEvaluationContext context, ProjectInfo pinfo, MSBuildProject project, MSBuildItem sourceItem, string include, string evaluatedFile = null, string recursiveDir = null) { - include = StringInternPool.AddShared (include);
-
+ include = StringInternPool.AddShared (include); + var it = new MSBuildItemEvaluated (project, sourceItem.Name, sourceItem.Include, include); var md = new Dictionary<string,IMSBuildPropertyEvaluated> (); // Only evaluate properties for non-transforms. @@ -1060,10 +1060,10 @@ namespace MonoDevelop.Projects.MSBuild void Evaluate (ProjectInfo project, MSBuildEvaluationContext context, MSBuildImport import, bool evalItems) { - if (evalItems) {
- // Properties have already been evaluated
- // Don't evaluate properties, only items and other elements
- var importedProjects = GetImportedProjects (project, import);
+ if (evalItems) { + // Properties have already been evaluated + // Don't evaluate properties, only items and other elements + var importedProjects = GetImportedProjects (project, import); for (int i = 0; i < importedProjects.Count; ++i) { var p = importedProjects [i]; |