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
Prevent Select-Object with ExpandProperty from updating source PSObjects #21328
base: master
Are you sure you want to change the base?
Prevent Select-Object with ExpandProperty from updating source PSObjects #21328
Conversation
Always copy the source object instead of referencing it. This ensures that the source object is never implicitly updated by the Select-Object command. PowerShell#21308
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
Thank you for tackling this, @BinaryWizard904. Let me summarize the net effects of this PR:
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
When using
Select-Object
to select from aPSObject
with both-Property
and-ExpandedProperty
arguments specified, the source object will be copied instead of referenced.This PR addresses issue #21308. It ensures that when a
PSObject
is selected from with both the-ExpandProperty
and-Property
arguments specified, the source object will not be updated. While technically preventing the source object from being modified is a breaking change, it breaks things in a manner previously approved by the @Powershell/powershell-committee. This PR is needed because the previous attempt at fixing this only works for non-PSObject inputs.In particular, for operations matching the aforementioned restrictions, this PR does the following: Within the
ProcessExpandParameter
method, theexpandedObject
is now set to a copy of the resultingPSObject
instead of a reference.Additionally, Pester tests have been added.
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.