-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add FileSystemEnumerable usage example #5245
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
Conversation
@@ -35,7 +35,17 @@ | |||
<Docs> | |||
<typeparam name="TResult">The type that this enumerable encapsulates.</typeparam> | |||
<summary>Allows utilizing custom filter predicates and transform delegates for enumeration purposes.</summary> | |||
<remarks>To be added.</remarks> | |||
<remarks> |
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.
I decided to put the example in the remarks of the type, because I think it's the most visible place.
static string myTransform(ref FileSystemEntry entry) => | ||
entry.ToFullPath(); | ||
|
||
static bool myPredicate(ref FileSystemEntry entry) => | ||
!entry.IsDirectory && | ||
Path.GetExtension(entry.ToFullPath()).Equals(".txt", StringComparison.InvariantCultureIgnoreCase); |
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.
I tried to write the same example in Visual Basic but the predicate and the transform were giving me headaches. I know there are no local methods in VB, but I couldn't figure out the syntax for the delegate with a ByRef argument. I'll give it another try soon.
Also, I was getting a build failure when trying to use ByRef FileSystemEntry
:
FileSystemEntry' is obsolete: 'Types with embedded references are not supported in this version of your compiler.
I'll ask someone in my team why this is happening.
Docs Build status updates of commit 047e2c5: ✅ Validation status: passed
For more details, please refer to the build report. 8000 Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report. For any questions, please:
|
Docs Build status updates of commit 1b50097: ✅ Validation status: passed
For more details, please refer to the build report. Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report. For any questions, please:
|
Docs Build status updates of commit 120eb24: ✅ Validation status: passed
For more details, please refer to the build report. Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report. For any questions, please:
|
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.
LGTM
samples/snippets/csharp/VS_Snippets_CLR/IO.Enumeration.FileSystemEnumerable/CS/Sample1.cs
Outdated
Show resolved
Hide resolved
…temEnumerable/CS/Sample1.cs Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
samples/snippets/csharp/VS_Snippets_CLR/IO.Enumeration.FileSystemEnumerable/CS/Sample1.cs
Outdated
Show resolved
Hide resolved
…temEnumerable/CS/Sample1.cs
Docs Build status updates of commit 374c58d: ✅ Validation status: passed
For more details, please refer to the build report. Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report. For any questions, please:
|
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.
LGTM!
Docs Build status updates of commit 26e5797: ✅ Validation status: passed
For more details, please refer to the build report. Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report. For any questions, please:
|
I noticed this class has no examples, so I added one with basic filtering options. Whenever I get a chance, I'll write additional examples with more advanced filters.