KEMBAR78
Convert `-ChildPath` parameter to `string[]` for `Join-Path` cmdlet by ArmaanMcleod · Pull Request #24677 · PowerShell/PowerShell · GitHub
Skip to content

Conversation

@ArmaanMcleod
Copy link
Contributor

@ArmaanMcleod ArmaanMcleod commented Dec 15, 2024

PR Summary

Converted -ChildPath parameter to string[] for Join-Path cmdlet.

PR Context

Fixes #21367

Allows user to give an array of child paths with -ChildPath. This avoids the extra usage with -AdditionalChildPath which can be ignored and makes usage of Join-Path easier.

This was discussed to be bucket 3 breaking change.

Example

> Join-Path -Path 'one' -ChildPath 'two', 'three'
one\two\three

PR Checklist

@iSazonov
Copy link
Collaborator

@ArmaanMcleod Since it is a breaking change I suggest to wrap this in an experimental feature (you can find examples in our code). Then I can review and merge since it is already approved by WG.

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Review - Needed The PR is being reviewed label Mar 10, 2025
@ArmaanMcleod
Copy link
Contributor Author

@iSazonov Interesting. I thought since it was accepted as bucket 3 breaking change it would not need an experimental feature. I did not see that requirement in the issue.

In any case would be good to move this along so I will create an experimental feature for this.

What should the experimental feature be called?

@iSazonov
Copy link
Collaborator

Although it's a bracket 3, it's still a breaking change. The experimental feature allows us to minimize risks and get feedback faster.
Name could be PSJoinPathChildArray. You can see examples with Get-ExperimentalFeature cndlet.

@ArmaanMcleod
Copy link
Contributor Author

@iSazonov This one actually doesn't make much sense to enable experimental feature, since we are changing the type of ChildPath from string to string[]. We can't have a parameter type change be wrapped in experimental feature.

@iSazonov
Copy link
Collaborator

iSazonov commented Mar 15, 2025

We can't have a parameter type change be wrapped in experimental feature.

We have ExperimentalAttribute. See https://github.com/daxian-dbw/PowerShell/blob/d12230f1888ea0226df0e4e0e2e0de2f9e8c0a1e/test/powershell/engine/ExperimentalFeature/assets/ExpTest/ExpTest.cs

GitHub
PowerShell for every system. Contribute to daxian-dbw/PowerShell development by creating an account on GitHub.

@ArmaanMcleod
Copy link
Contributor Author

ArmaanMcleod commented Mar 15, 2025

@iSazonov Thats really interesting. However even if you do:

[Experimental(ExperimentalFeature.PSJoinPathChildArray, ExperimentAction.Show)]
public string[] ChildPath { get; set; }

How do you also make the previous parameter:

public string ChildPath { get; set; }

Also show when the experimental feature is disabled? in C# we can't have two properties have the same name but different type. Maybe I am misunderstanding how this works...

@iSazonov iSazonov added CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log PowerShell-Docs needed The PR was reviewed and a PowerShell Docs update is needed labels Mar 15, 2025
@iSazonov
Copy link
Collaborator

in C# we can't have two properties have the same name but different type.

Yes, it would be too tricky wrap in experimental feature. Let's leave as is.

}
@{
Path = 'one'
ChildPath = [string]::Empty
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need one more test for empty collection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should already be covered here:

@{
Path = 'one'
ChildPath = @()
ExpectedResult = "one${sepChar}"
}

@iSazonov iSazonov self-assigned this Mar 15, 2025
@iSazonov iSazonov requested a review from SteveL-MSFT March 15, 2025 11:35
@iSazonov

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

@iSazonov iSazonov merged commit 48c34fc into PowerShell:master Mar 18, 2025
38 of 40 checks passed
@microsoft-github-policy-service
Copy link
Contributor

microsoft-github-policy-service bot commented Mar 18, 2025

📣 Hey @ArmaanMcleod, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log PowerShell-Docs needed The PR was reviewed and a PowerShell Docs update is needed

Projects

Development

Successfully merging this pull request may close these issues.

Make Join-Path parameter -ChildPath accept an array

2 participants