Repository navigation
Built-in format data contains dormant duplicates #11307
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 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.
All 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.
Steps to reproduce
Get-FormatData | ? TypeNames -Contains System.Management.Automation.AliasInfo |
% FormatViewDefinition |
? Control -is System.Management.Automation.TableControlExpected behavior
Only one table-view control definition should be printed for the given type.
Actual behavior
Two - competing - definitions print:
Name Control
---- -------
CommandInfo System.Management.Automation.TableControl
AliasInfo System.Management.Automation.TableControl
Only the former is in effect (Name column prints an alias' .DisplayName property).
The latter (there's only a DisplayName property) is never used.
Environment data
PowerShell Core 7.0.0-preview.6
Query to find all duplicates:
Get-FormatData | ForEach-Object {
$fd = $_
$_.formatviewdefinition | Select-Object @{n='TypeName'; e = { $fd.TypeNames } }, @{n='ControlType'; e={ $_.Control.GetType().Name } }
}
| Group-Object -Property TypeName, ControlType | Where-Object Count -gt 1
| Format-Table -AutoSizeIn a pristine session, this yields:
Count Name Group
----- ---- -----
2 Microsoft.PowerShell.Commands.X509StoreLocation, ListControl {@{TypeName=Microsoft.PowerShell.Commands.X509StoreLocation; ControlType=ListControl}, @{TypeNam…
2 System.Management.Automation.AliasInfo, TableControl {@{TypeName=System.Management.Automation.AliasInfo; ControlType=TableControl}, @{TypeName=System…
2 System.Management.Automation.ApplicationInfo, TableControl {@{TypeName=System.Management.Automation.ApplicationInfo; ControlType=TableControl}, @{TypeName=…
2 System.Management.Automation.ExternalScriptInfo, TableControl {@{TypeName=System.Management.Automation.ExternalScriptInfo; ControlType=TableControl}, @{TypeNa…
2 System.Management.Automation.FilterInfo, TableControl {@{TypeName=System.Management.Automation.FilterInfo; ControlType=TableControl}, @{TypeName=Syste…
2 System.Management.Automation.FunctionInfo, TableControl {@{TypeName=System.Management.Automation.FunctionInfo; ControlType=TableControl}, @{TypeName=Sys…
2 System.Management.Automation.ScriptInfo, TableControl {@{TypeName=System.Management.Automation.ScriptInfo; ControlType=TableControl}, @{TypeName=Syste…
2 System.Security.Cryptography.X509Certificates.X509Certificate2, ListControl {@{TypeName=System.Security.Cryptography.X509Certificates.X509Certificate2; ControlType=ListCont…
2 System.Security.Cryptography.X509Certificates.X509Store, ListControl {@{TypeName=System.Security.Cryptography.X509Certificates.X509Store; ControlType=ListControl}, @…
Activity
SteveL-MSFT commentedon Dec 10, 2019
In the aliasinfo case, they are actually two views. However, the AliasInfo view is a subset of the CommandInfo view and so we should remove the AliasInfo view as it doesn't provide any value.
mklement0 commentedon Dec 10, 2019
Steve Lee (@SteveL-MSFT): It isn't just AliasInfo: 10 type-view combinations are currently affected - please see the updated OP.
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.