-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Enhance FileSystemEnumerable to track depth recursion #43748
Comments
|
I believe we have no need to have "no limit" value:
Also this complicates implementation without need. If we will have "no limit" value we will have to:
If we compare with JsonSerializerOptions.MaxDepth the last has a real default = 64 but for recursion default is "no limit" that is MaxValue.
I added this in OP.
The value should be positive by definition - no need to check in implementation. No breaking changes. On windows long path length is 32,767 characters so max recursion depth is about 16000 and this less then uint.MaxValue. But I'd agree to follow common pattern if the pattern is
My request is for 6.0 milestone since this is useful for PowerSHell and I am ready to pull PR with the API. |
namespace System.IO
{
public partial class EnumerationOptions
{
public int MaxRecursionDepth { get; set; }
}
} |
Yes, really it is to return only current directory items. The proposal was updated based on the review. |
I am ready to pull PR if .Net team approves. |
I assigned this issue to you, @iSazonov . Thank you for your help! Looking forward to review the PR. |
Splitted from #1953
Background and Motivation
In PowerShell Core repo we are trying to migrate to
FileSystemEnumerable
. Prototype shows great performance improvements.We need to implement Depth parameter for Get-ChildItem cmdlet (aka
dir
). The parameter limits a depth of recursion.This cannot be achieved without creating new classes (based on FileSystemEnumerator and FileSystemEnumerable) and creating non-trivial code as it requires processing a directory tree. All this negates the benefits of this API.
Proposed API
Usage Examples
Alternative Designs
What is better name - MaxRecursionDepth vs MaxDepthRecursion vs MaxDepthOfRecursion vs MaxDepth ?
(there is
JsonSerializerOptions.MaxDepth
)Risks
Minor performance regression due to we have to keep additional uint value in a subdirectory queue.
Implementation details
Current implementation uses Queue to track subdirectories. We could put in the queue current depth +1 value together with subdirectory path. This allow to restore correct depth value at subdirectory dequeue.
And we need add Depth check in recursion condition.
The text was updated successfully, but these errors were encountered: