Skip to content

Conversation

@Windos
Copy link
Contributor

@Windos Windos commented Oct 3, 2017

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
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
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
Copy link
Collaborator

iSazonov commented Oct 4, 2017

@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
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
Copy link
Collaborator

iSazonov commented Oct 5, 2017

@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
Copy link
Contributor Author

Windos commented Oct 6, 2017

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

@daxian-dbw
Copy link
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
Member

@iSazonov @daxian-dbw can you update your review

@iSazonov
Copy link
Collaborator

iSazonov commented Oct 9, 2017

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

Copy link
Member

@adityapatwardhan adityapatwardhan left a comment

Choose a reason for hiding this comment

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

LGTM

@adityapatwardhan
Copy link
Member

@daxian-dbw Can you update your review?

@adityapatwardhan adityapatwardhan merged commit c98fe39 into PowerShell:master Oct 23, 2017
@adityapatwardhan
Copy link
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