-
Notifications
You must be signed in to change notification settings - Fork 8.2k
The switch parameters for Split-Path should be mandatory #12991
Copy link
Copy link
Closed
Labels
First-Time-IssueEasy issues first time contributors can work on to learn about this projectEasy issues first time contributors can work on to learn about this projectIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module
Description
This is related to the recent change made in PR #12960
I was reviewing this PR to understand the change needed in the documentation. I also looked at the source code and find that the pattern used by the parameters is confusing. The switch parameters are all optional but are used to define the unique ParameterSet. So, they are mandatory for that parameter set.
PS C:\temp\test> syntax Split-Path | ft -w
Cmdlet ParameterSetName Parameters
------ ---------------- ----------
Split-Path ParentSet [-Path] <string[]> [-Parent] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path LeafSet [-Path] <string[]> [-Leaf] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path LeafBaseSet [-Path] <string[]> [-LeafBase] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path ExtensionSet [-Path] <string[]> [-Extension] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path QualifierSet [-Path] <string[]> [-Qualifier] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path NoQualifierSet [-Path] <string[]> [-NoQualifier] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path IsAbsoluteSet [-Path] <string[]> [-Resolve] [-IsAbsolute] [-Credential <pscredential>] [<CommonParameters>]
Split-Path LiteralPathSet -LiteralPath <string[]> [-Resolve] [-Credential <pscredential>] [<CommonParameters>]I think the parameters should be changed to Mandatory = true. Are there any risks created by that change?
As a secondary question, what is the use-case scenario for allowing ValueFromPipelineByPropertyName on those switch parameters? Seems like a strange use case and hard to document.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
First-Time-IssueEasy issues first time contributors can work on to learn about this projectEasy issues first time contributors can work on to learn about this projectIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module