private IEnumerable <string> EnumerateFullFileSystemPaths(string path, string searchPattern, bool includeFiles, bool includeDirectories) { FindPredicate predicate = (ref ReadOnlySpan <char> fileName) => { return(FileMatcher.IsAllFilesWildcard(searchPattern) || FileMatcher.IsMatch(fileName, searchPattern)); }; FindTransform <string> transform = (ref ReadOnlySpan <char> fileName) => Path.Join(path.AsSpan(), fileName); IEnumerable <string> directories = includeDirectories ? _directoryCache.EnumerateDirectories(path, searchPattern, predicate, transform) : Enumerable.Empty <string>(); IEnumerable <string> files = includeFiles ? _directoryCache.EnumerateFiles(path, searchPattern, predicate, transform) : Enumerable.Empty <string>(); return(Enumerable.Concat(directories, files)); }