Title: Inconsistent stringification of [pscustomobject] instances - calling .ToString() on custom objects yields the empty string · Issue #6163 · PowerShell/PowerShell · GitHub
Open Graph Title: Inconsistent stringification of [pscustomobject] instances - calling .ToString() on custom objects yields the empty string · Issue #6163 · PowerShell/PowerShell
X Title: Inconsistent stringification of [pscustomobject] instances - calling .ToString() on custom objects yields the empty string · Issue #6163 · PowerShell/PowerShell
Description: 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 str...
Open Graph Description: 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 .To...
X Description: 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 .To...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/6163
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inconsistent stringification of [pscustomobject] instances - calling .ToString() on custom objects yields the empty string","articleBody":"In the context of _implicit_ stringification as part of _expandable strings_, `[System.Management.Automation.PSCustomObject]` instances expand to a hashtable-_like_ representation.\r\n\r\nBy contrast, calling `.ToString()` _explicitly_ yields the _empty string_; only `.psobject.ToString()` results in the same representation as when string-expanding.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\n$co = [pscustomobject] @{ one = 'for the road' }\r\n\"string-expanded: [$co]\"\r\n\".psobject.ToString: [{0}]\" -f $co.psobject.ToString()\r\n\".ToString: [{0}]\" -f $co.ToString()\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\n```none\r\nstring-expanded: [@{one=for the road}]\r\n.psobject.ToString: [@{one=for the road}]\r\n.ToString: [@{one=for the road}]\r\n```\r\n\r\nAll three approaches should result in the same stringification.\r\n\r\nActual behavior\r\n---------------\r\n\r\n```none\r\nstring-expanded: [@{one=for the road}]\r\n.psobject.ToString: [@{one=for the road}]\r\n.ToString: []\r\n```\r\n\r\nNote how `$co.ToString()` returned the empty string.\r\n\r\nEnvironment data\r\n----------------\r\n\r\n```powershell\r\nPowerShell Core v6.0.1\r\nWindows PowerShell v5.1\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2018-02-15T15:23:10Z","url":"https://github.com/PowerShell/PowerShell/issues/6163"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6936e147-3da0-27be-98f7-a7b4c7931c90 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E56A:24D490:234436:305CE5:6AFD5200 |
| html-safe-nonce | ca6787a3bd5c31880a33ae6f06f14715a6fd61b6bc34f51abfc6da4131cafb75 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNTZBOjI0RDQ5MDoyMzQ0MzY6MzA1Q0U1OjZBRkQ1MjAwIiwidmlzaXRvcl9pZCI6IjE0NTY4MzE5ODM1MTc1MjAzODQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 36846d82d4ddb9b41ba0eab68dce6a0c99be50693bfa1c23a1f6bae03dd9268c |
| hovercard-subject-tag | issue:297484874 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/6163/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7b3686966b2ce57e139f888b0a02aee0c7f3622fc2099c9eb69caab5fed2d4a8/PowerShell/PowerShell/issues/6163 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7b3686966b2ce57e139f888b0a02aee0c7f3622fc2099c9eb69caab5fed2d4a8/PowerShell/PowerShell/issues/6163 |
| og:image:alt | 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 .To... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width