Skip to content
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

MockDirectory.EnumerateFiles search pattern behaves differently from Directory.EnumerateFiles in .NET 5+ #895

Open
Gav-Brown opened this issue Oct 13, 2022 · 2 comments
Labels
area: testinghelpers Issues that address the testing helpers state: ready to pick Issues that are ready for being worked on type: bug Issues that describe misbehaving functionality

Comments

@Gav-Brown
Copy link

In .NET 5 the behaviour of the file extension search pattern changed from .NET Framework.
See EnumerateFiles, specifically the table entry

book.xls, book.xlsx | *.xls | book.xls | book.xls, book.xlsx

To Reproduce
Steps to reproduce the behaviour:

  1. Create files a.txt and b.txt2 in a directory.
  2. Run Directory.EnumerateFiles(dir, "*.txt", SearchOption.AllDirectories)
  3. Compare .NET 5 or 6 behaviour to MockDirectory

Expected behaviour
Only a.txt should be returned.

Actual behaviour
Both a.txt and b.txt2 are returned.

Can also just use *.t as search pattern which should return no files in a folder of .txt files etc.

@Gav-Brown Gav-Brown added state: needs discussion Issues that need further discussion type: bug Issues that describe misbehaving functionality labels Oct 13, 2022
@fgreinacher
Copy link
Contributor

Good find, thanks for the detailed explanation!

When fixing this we need to ensure that we keep the current behavior for .NET Framework (what about .NET Core?).

@fgreinacher fgreinacher added state: ready to pick Issues that are ready for being worked on area: testinghelpers Issues that address the testing helpers and removed state: needs discussion Issues that need further discussion labels Oct 14, 2022
@Gav-Brown
Copy link
Author

Thanks, By the way, ignore the *.t test as this behaviour only applies to 3 letter extensions, I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: testinghelpers Issues that address the testing helpers state: ready to pick Issues that are ready for being worked on type: bug Issues that describe misbehaving functionality
Projects
None yet
Development

No branches or pull requests

2 participants