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
Advanced filter in FromDirectory #166
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! It looks like a very useful feature!
Just a few comments about style and safety.
src/Yarhl/FileSystem/NodeFactory.cs
Outdated
if (string.IsNullOrEmpty(dirPath)) | ||
throw new ArgumentNullException(nameof(dirPath)); | ||
|
||
if (dirPath[dirPath.Length - 1] == Path.DirectorySeparatorChar) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one-line conditions not related to guards should have braces to prevent future bugs (the previous function doesn't follow this rule this rule but I think it's old code before this rule was introduced).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good. Thanks!
Description
This PR allows using a
Func
to define the filter inNodeFactory.FromDirectory
methods.This way, the users can define more precisely the files to add to the container.
On the other side, this method will be slower than wildcard filters because it first enumerates all files and, later, filters them.
Example
Get files using a regular expression: