-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Select-Object -ExpandProperty hides ETS instance members #7937
Copy link
Copy link
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Type
Fields
Give feedbackNo fields configured for issues without a type.
Follow-up from #7768
If you use
-ExpandPropertywith a property whose value happens to be an object with instance ETS members (ETS members added with-Add-Member), these members are no longer present in the value returned.Note: The behavior only surfaces if the object is not an instance of
[psobject]- that is, if it is neither a true custom object ("property bag") nor an incidental[psobject]wrapper (see #5579).@PetSerAl discovered this problem in the context of #7768 and explains it as follows:
A fix for this issue - to no longer attach the ETS members to the incidental wrapper and instead use the resurrection tables - should also fix the problem described in #12411.
Steps to reproduce
Expected behavior
That is, the
.myPropinstance member should still be present.Actual behavior
That is, the
.myPropinstance member is no longer present.What presumably happens is that a
[psobject]wrapper is created around the output object withstoreTypeNameAndInstanceMembersLocallyset to$true, which makes PowerShell look for instance members only on the wrapper object itself, effectively eclipsing any preexisting instance members associated with the wrapped object via the resurrection tables.Environment data
PowerShell Core v6.1.0