Title: Hidden-only class loses ToString() formatting after Get-Member inspection · Issue #25832 · PowerShell/PowerShell · GitHub
Open Graph Title: Hidden-only class loses ToString() formatting after Get-Member inspection · Issue #25832 · PowerShell/PowerShell
X Title: Hidden-only class loses ToString() formatting after Get-Member inspection · Issue #25832 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/25832
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Hidden-only class loses ToString() formatting after Get-Member inspection","articleBody":"### Prerequisites\n\n- [x] Write a descriptive title.\n- [x] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\n- [x] Search the existing issues.\n- [x] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\n- [x] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\n\n### Steps to reproduce\n\nIf you define a class with only hidden properties and an overload to the ToString() method, displaying the object falls back to the ToString() method, as expected.\n\nBut a call to Get-Member on such an object, forces a full ETS refresh: the formatter now believes the type has visible members and switches to the list renderer, resulting in blank lines (since actually all members are hidden) instead of the expected ToString().\n\nI found this issue was first noticed in issue [#17071](https://github.com/PowerShell/PowerShell/issues/17071#issue-1182603666) but I just ran into it myself when coding a new class in PowerShell. It's still occurring on PowerShell 7.5.2 .\n\n### Code snippet\n\n#### 1. Minimalistic sample class\n```Powershell\nclass CustomClass {\n hidden [string] $myString\n CustomClass([string] $newVal) { $this.myString = $newVal }\n [string] ToString() { return $this.myString }\n}\n\n$myObject = [CustomClass]\"Test\"\n\n# 1. Normal display uses ToString()\n$myObject\n\n# 2. Inspect the object\n$myObject | Get-Member\n\n# 3. Display again – blank line appears\n$myObject\n```\n\n\n### Expected behavior\n\n```console\nPS /> $myObject = [CustomClass]\"Test\"\nPS /> $myObject\nTest\nPS /> $myObject | Get-Member\n\n TypeName: CustomClass\n\nName MemberType Definition\n---- ---------- ----------\nEquals Method bool Equals(System.Object obj)\nGetHashCode Method int GetHashCode()\nGetType Method type GetType()\nToString Method string ToString()\n\nPS /> $myObject\nTest\n```\n\n### Actual behavior\n\n```console\nPS /> $myObject = [CustomClass]\"Test\"\nPS /> $myObject\nTest\nPS /> $myObject | Get-Member\n\n TypeName: CustomClass\n\nName MemberType Definition\n---- ---------- ----------\nEquals Method bool Equals(System.Object obj)\nGetHashCode Method int GetHashCode()\nGetType Method type GetType()\nToString Method string ToString()\n\nPS /> $myObject\n```\n\n### Error details\n\n```console\n\n```\n\n### Environment data\n\n```powershell\nPS /> $PSVersionTable\n\nName Value\n---- -----\nPSVersion 7.5.2\nPSEdition Core\nGitCommitId 7.5.2\nOS Darwin 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.…\nPlatform Unix\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\nPSRemotingProtocolVersion 2.3\nSerializationVersion 1.1.0.1\nWSManStackVersion 3.0\n```\n\n### Visuals\n\n_No response_","author":{"url":"https://github.com/GregoireLD","@type":"Person","name":"GregoireLD"},"datePublished":"2025-08-06T21:31:36Z","url":"https://github.com/PowerShell/PowerShell/issues/25832"}
| 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:4e00838c-0b2e-aa1b-d14b-04a44a14dc43 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B1A2:3B68C7:2735988:36AADCF:6AFD4D5D |
| html-safe-nonce | 74d72e2d0d971b49c93b38782182ece4fd2f040b0df57b26c4891d51aef9105a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUEyOjNCNjhDNzoyNzM1OTg4OjM2QUFEQ0Y6NkFGRDRENUQiLCJ2aXNpdG9yX2lkIjoiNzc3OTcxNzIwNTU2OTkxNjI1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 95b4d6a415d83a3ac29d1ce298cfb6e08340b8c1d8d4e93e4aaecae6273c6e23 |
| hovercard-subject-tag | issue:3298147430 |
| 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/25832/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d93d1747834284994d2e699dc4c9402f2deb8581b99cd6db1f1f233db8575c98/PowerShell/PowerShell/issues/25832 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d93d1747834284994d2e699dc4c9402f2deb8581b99cd6db1f1f233db8575c98/PowerShell/PowerShell/issues/25832 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | GregoireLD |
| 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