You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inconsistent stringification of [pscustomobject] instances - calling .ToString() on custom objects yields the empty string #6163
In the context of implicit stringification as part of expandable strings, [System.Management.Automation.PSCustomObject] instances expand to a hashtable-like representation.
By contrast, calling .ToString()explicitly yields the empty string; only .psobject.ToString() results in the same representation as when string-expanding.
changed the title [-]Inconsistent stringification of [pscustomobject] instances[/-][+]Inconsistent stringification of [pscustomobject] instances - calling .ToString() on custom objects[/+]on Nov 6, 2018
If property two is instead made to contain another[pscustomobject] instance, the bug surfaces:
PS> [pscustomobject] @{ prop= [pscustomobject] @{ one=1; two= [pscustomobject] @{ three=3 } } }
prop
----@{one=1; two=} # !! .two appears EMPTY now, even though it isn't.
In the context of visually inspecting nested [pscustomobject] instances converted from JSON (see linked post), this gives the mistaken impression that data is missing.
changed the title [-]Inconsistent stringification of [pscustomobject] instances - calling .ToString() on custom objects[/-][+]Inconsistent stringification of [pscustomobject] instances - calling .ToString() on custom objects yields the empty string[/+]on Feb 7, 2020
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 23, 2023
Activity
[-]Inconsistent stringification of [pscustomobject] instances[/-][+]Inconsistent stringification of [pscustomobject] instances - calling .ToString() on custom objects[/+]mklement0 commentedon Dec 20, 2019
Just came across a real-world case where this bug can be quite confusing in this Stack Overflow question:
The default output formatting for property values that contain
[pscustomobject]s is a hashtable-like representation:If property
twois instead made to contain another[pscustomobject]instance, the bug surfaces:In the context of visually inspecting nested
[pscustomobject]instances converted from JSON (see linked post), this gives the mistaken impression that data is missing.[-]Inconsistent stringification of [pscustomobject] instances - calling .ToString() on custom objects[/-][+]Inconsistent stringification of [pscustomobject] instances - calling .ToString() on custom objects yields the empty string[/+]microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.