Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Make Get-ChildItem honor Depth parameter with Include/Exclude#4985

Merged
adityapatwardhan merged 3 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
Windos:gci-recurse-exclude-includeCopy head branch name to clipboard
Oct 23, 2017
Merged

Make Get-ChildItem honor Depth parameter with Include/Exclude#4985
adityapatwardhan merged 3 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
Windos:gci-recurse-exclude-includeCopy head branch name to clipboard

Conversation

@Windos

@Windos Windos commented Oct 3, 2017

Copy link
Copy Markdown
Contributor

Addresses issue #3726 by adding decrementing depth to ProcessPathItems.

Includes tests specifically for the examples listed in the issue and also testing that recursion still works when excluding or including a string.

Windos added 2 commits October 3, 2017 22:32
Honors capped recursion when using Include or Exclude filters with Get-ChildItem

int unUsedChildrenNotMatchingFilterCriteria = 0;
ProcessPathItems(providerInstance, providerPath, recurse, context, out unUsedChildrenNotMatchingFilterCriteria, ProcessMode.Enumerate);
ProcessPathItems(providerInstance, providerPath, recurse, context, out unUsedChildrenNotMatchingFilterCriteria, ProcessMode.Enumerate, depth: depth);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to exclude parameters with defaults and use overloads.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pushed new commit swapping optional parameter for overload. Is it along the right track?

@iSazonov

iSazonov commented Oct 4, 2017

Copy link
Copy Markdown
Collaborator

@daxian-dbw Can we ask @Windos to fix (replace with overloads) skipIsItemContainerCheck defaults in the PR? It seems adding new parameter (depth) complicate the Api and it would be good to eliminate that now.

@daxian-dbw

Copy link
Copy Markdown
Member

Well, the optional parameter was introduced to be an alternative of overloads, to reduce the number of overloads of a method.
If we remove skipIsItemContainerCheck by adding overloads, then there will be 4 overloads of ProcessPathItems, which IMHO might be cumbersome.

The optional parameter should never be used for public APIs or even internal APIs that may be called from other friend assemblies because the default value is baked into the caller, and that means if we change the default value, the caller assembly needs to be re-compile to get the new default value.
However, it's fine for private methods, as long as it doesn't affect readability much.

@iSazonov

iSazonov commented Oct 5, 2017

Copy link
Copy Markdown
Collaborator

@daxian-dbw I asked because adding second optional parameter reduced readability. Do we have to create overloads in this case or can we just replace its with one method with all the parameters?

@Windos

Windos commented Oct 6, 2017

Copy link
Copy Markdown
Contributor Author

I'm happy to put the work in regardless of which direction is decided on.

@daxian-dbw

Copy link
Copy Markdown
Member

@iSazonov I think you made the right call. Adding the second optional parameter would worsen the readability. I think the current two overloads look good.

@adityapatwardhan

Copy link
Copy Markdown
Member

@iSazonov @daxian-dbw can you update your review

@iSazonov

iSazonov commented Oct 9, 2017

Copy link
Copy Markdown
Collaborator

@daxian-dbw Is uint depth parameter on best place? What about before last?

@adityapatwardhan adityapatwardhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adityapatwardhan

Copy link
Copy Markdown
Member

@daxian-dbw Can you update your review?

@adityapatwardhan adityapatwardhan merged commit c98fe39 into PowerShell:master Oct 23, 2017
@adityapatwardhan

Copy link
Copy Markdown
Member

@Windos Thanks for your contribution!

@vors vors removed their request for review October 24, 2017 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.