Skip to content

Not all matches are returned from DirectoryInfo.EnumerateFileSystemInfo #651

Closed

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.

Activity

  1. issue-label-bot commented on Oct 9, 2020

    @issue-label-bot

    Issue-Label Bot is automatically applying the label type: bug to this issue, with a confidence of 0.91. Please mark this comment with 👍 or 👎 to give our bot feedback!

    Links: app homepage, dashboard and code for this bot.

  2. added
    state: ready to pickIssues that are ready for being worked on
    and removed on Oct 12, 2020
  3. fgreinacher commented on Oct 12, 2020

    @fgreinacher
    Contributor

    Fixed via #652

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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