-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MockFileSystem Directory.EnumerateFiles returns incorrect results, based on input pattern. #596
Comments
Thanks for reporting! Am I right assuming |
my apologies, the sample is not right. Here is something more representative.
|
This sample does also not look correct to me, the pattern has one asterisk too much: result.rreq.001.afd
* .rreq.* .* .* The following test is passing: // Arrange
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
{ XFS.Path(@"c:\test\result.rreq.001.afd"), MockFileData.NullObject }
});
// Act
var result = fileSystem.Directory.EnumerateFiles(XFS.Path(@"c:\test"), "*.rreq.*.*");
// Assert
Assert.That(result, Is.EquivalentTo(new[]
{
XFS.Path(@"c:\test\result.rreq.001.afd")
})); |
Now I get the problem. It seems like the real implementation ignores the // Arrange
var fileSystem = new FileSystem();
// var fileSystem = new MockFileSystem();
// fileSystem.Directory.CreateDirectory(XFS.Path(@"c:\tmp\"));
fileSystem.File.CreateText(XFS.Path(@"c:\tmp\result.rreq.001.afd")).Close();
// Act
var result = fileSystem.Directory.EnumerateFiles(XFS.Path(@"c:\tmp"), "*.rreq.*.*.*.*.*.*.*.*.*");
// Assert
Assert.That(result, Is.EquivalentTo(new[]
{
XFS.Path(@"c:\tmp\result.rreq.001.afd")
})); |
@pianomanjh Please check whether the issue goes away once you use the "correct" pattern:
|
If I use a different pattern, the one you describe, the issue no longer reproduces, yes. |
Why do you need that exact pattern? It seems wrong to me 🤔 .NET behavior seems to be much more complex than we anticipated when implementing this logic 🐙 https://github.com/dotnet/runtime/blob/cd02b0612b3c758037eac9f85faa4ec91b1fbbda/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemName.cs has some of the logic - we might want to reuse (parts of) it. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
There are more differences in behaviour of Directory.EnumerateFiles between mock and real file system:
|
Thanks for the additional input here @themcoo. Would you mind creating new issues for the problems so that we can tackle them separately? |
Another pattern that works in the real filesystem and not on the MockFileSystem is |
When calling Directory.EnumerateFiles on MockFileSystem, incorrect matching occurs, that differs from the real FileSystem.
Mock FileSystem
Real FileSystem
The text was updated successfully, but these errors were encountered: