Title: Built-in format data contains dormant duplicates · Issue #11307 · PowerShell/PowerShell · GitHub
Open Graph Title: Built-in format data contains dormant duplicates · Issue #11307 · PowerShell/PowerShell
X Title: Built-in format data contains dormant duplicates · Issue #11307 · PowerShell/PowerShell
Description: If you use Get-FormatData -PowerShellVersion 5.1 to enumerate all built-in format-data definitions, duplicates surface. While different format-data definitions may cover different views for a given type (and format-data definitions may c...
Open Graph Description: If you use Get-FormatData -PowerShellVersion 5.1 to enumerate all built-in format-data definitions, duplicates surface. While different format-data definitions may cover different views for a given...
X Description: If you use Get-FormatData -PowerShellVersion 5.1 to enumerate all built-in format-data definitions, duplicates surface. While different format-data definitions may cover different views for a given...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/11307
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Built-in format data contains dormant duplicates","articleBody":"If you use `Get-FormatData -PowerShellVersion 5.1` to enumerate all built-in format-data definitions, duplicates surface.\r\n\r\nWhile different format-data definitions may cover different _views_ for a given type (and format-data definitions may cover multiple types), there are truly competing definitions, only one of which can be effective, as the repro steps demonstrate for type `System.Management.Automation.AliasInfo`.\r\n\r\nAll built-in format-data definitions should be examined, and the ineffective duplicates should be omitted. _Update_: See the bottom for a list of all duplicates.\r\n\r\n# Steps to reproduce\r\n\r\n```powershell\r\nGet-FormatData | ? TypeNames -Contains System.Management.Automation.AliasInfo | \r\n % FormatViewDefinition | \r\n ? Control -is System.Management.Automation.TableControl\r\n```\r\n\r\n# Expected behavior\r\n\r\nOnly _one_ table-view control definition should be printed for the given type.\r\n\r\n# Actual behavior\r\n\r\n_Two_ - competing - definitions print:\r\n\r\n```none\r\nName Control\r\n---- -------\r\nCommandInfo System.Management.Automation.TableControl\r\nAliasInfo System.Management.Automation.TableControl\r\n```\r\n\r\nOnly the former is in effect (`Name` column prints an alias' `.DisplayName` property).\r\n\r\nThe latter (there's only a `DisplayName` property) is never used.\r\n\r\n# Environment data\r\n\r\n```none\r\nPowerShell Core 7.0.0-preview.6\r\n```\r\n\r\n---\r\n\r\nQuery to find all duplicates:\r\n\r\n```powershell\r\nGet-FormatData | ForEach-Object {\r\n $fd = $_\r\n $_.formatviewdefinition | Select-Object @{n='TypeName'; e = { $fd.TypeNames } }, @{n='ControlType'; e={ $_.Control.GetType().Name } }\r\n} \r\n| Group-Object -Property TypeName, ControlType | Where-Object Count -gt 1 \r\n| Format-Table -AutoSize\r\n```\r\n\r\nIn a pristine session, this yields:\r\n\r\n```\r\nCount Name Group\r\n----- ---- -----\r\n 2 Microsoft.PowerShell.Commands.X509StoreLocation, ListControl {@{TypeName=Microsoft.PowerShell.Commands.X509StoreLocation; ControlType=ListControl}, @{TypeNam…\r\n 2 System.Management.Automation.AliasInfo, TableControl {@{TypeName=System.Management.Automation.AliasInfo; ControlType=TableControl}, @{TypeName=System…\r\n 2 System.Management.Automation.ApplicationInfo, TableControl {@{TypeName=System.Management.Automation.ApplicationInfo; ControlType=TableControl}, @{TypeName=…\r\n 2 System.Management.Automation.ExternalScriptInfo, TableControl {@{TypeName=System.Management.Automation.ExternalScriptInfo; ControlType=TableControl}, @{TypeNa…\r\n 2 System.Management.Automation.FilterInfo, TableControl {@{TypeName=System.Management.Automation.FilterInfo; ControlType=TableControl}, @{TypeName=Syste…\r\n 2 System.Management.Automation.FunctionInfo, TableControl {@{TypeName=System.Management.Automation.FunctionInfo; ControlType=TableControl}, @{TypeName=Sys…\r\n 2 System.Management.Automation.ScriptInfo, TableControl {@{TypeName=System.Management.Automation.ScriptInfo; ControlType=TableControl}, @{TypeName=Syste…\r\n 2 System.Security.Cryptography.X509Certificates.X509Certificate2, ListControl {@{TypeName=System.Security.Cryptography.X509Certificates.X509Certificate2; ControlType=ListCont…\r\n 2 System.Security.Cryptography.X509Certificates.X509Store, ListControl {@{TypeName=System.Security.Cryptography.X509Certificates.X509Store; ControlType=ListControl}, @…\r\n```","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2019-12-10T15:40:40Z","url":"https://github.com/PowerShell/PowerShell/issues/11307"}
| 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:26e94ae0-466a-6ae0-adbf-d91c03d30b2c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E9F8:1A7B13:1DD77B:2A1C05:6AFD51E4 |
| html-safe-nonce | d76156403c4a865d6b18870b37ea32e69fb7d010979c1ee31dfd0e5d473bae63 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUY4OjFBN0IxMzoxREQ3N0I6MkExQzA1OjZBRkQ1MUU0IiwidmlzaXRvcl9pZCI6IjQxNDg2NjYyNDYyNDMzNzM1NDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c1f8a96986c4eadc382a4ffebda224b8a60d7a0e5479dabdf57c89aa707f58f1 |
| hovercard-subject-tag | issue:535811364 |
| 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/11307/issue_layout |
| twitter:image | https://opengraph.githubassets.com/28ae4c1ac12702f0e51a17fd6fb0d92dac3884b4051df7ed7fb66b016804e93a/PowerShell/PowerShell/issues/11307 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/28ae4c1ac12702f0e51a17fd6fb0d92dac3884b4051df7ed7fb66b016804e93a/PowerShell/PowerShell/issues/11307 |
| og:image:alt | If you use Get-FormatData -PowerShellVersion 5.1 to enumerate all built-in format-data definitions, duplicates surface. While different format-data definitions may cover different views for a given... |
| 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