Skip to content

Not all matches are returned from DirectoryInfo.EnumerateFileSystemInfo #651

@P-Storm

Description

@P-Storm

Describe the bug
Not all matches are returned from DirectoryInfo.EnumerateFileSystemInfo. It looks like that the RecurseSubdirectories is ignored.

To Reproduce

        [Test]
        public void Delete_Me()
        {
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>()
            {
                { @"c:\bla.txt", null },
                { @"c:\Test\test.txt", null },
                { @"c:\Test\more-test.png", null },
                { @"c:\Test\A\deep-nested.png", null },
            });

            var path = @"C:\";
            var searchPattern = "*";
            var enumerateFileSystemEntries = fileSystem.Directory
                .EnumerateFileSystemEntries(path, searchPattern, SearchOption.AllDirectories)
                .OrderBy(r => r);

            var directoryInfo = fileSystem.DirectoryInfo.FromDirectoryName(path);
            var fileSystemInfos = directoryInfo.EnumerateFileSystemInfos(searchPattern, new EnumerationOptions()
                {
                    MatchType = MatchType.Win32,
                    RecurseSubdirectories = true,
                    IgnoreInaccessible = true,
                    ReturnSpecialDirectories = false,
                    AttributesToSkip = FileAttributes.Hidden,
                    MatchCasing = MatchCasing.PlatformDefault,
                })
                .Select(r => r.FullName);

            CollectionAssert.AreEquivalent(enumerateFileSystemEntries, fileSystemInfos);
        }

  Expected: equivalent to < "c:\bla.txt", "C:\temp", "c:\Test", "c:\Test\A", "c:\Test\A\deep-nested.png", "c:\Test\more-test.png", "c:\Test\test.txt" >
  But was:  < "c:\Test", "C:\temp", "c:\bla.txt" >
  Missing (4): < "c:\Test\A", "c:\Test\A\deep-nested.png", "c:\Test\more-test.png", "c:\Test\test.txt" >

Expected behavior
I would expect that EnumerateFileSystemEntries and EnumerateFileSystemInfos resulted in the same list. It is doing that for the .net core implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: testinghelpersIssues that address the testing helpersstate: ready to pickIssues that are ready for being worked ontype: bugIssues that describe misbehaving functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions