Skip to content

Built-in format data contains dormant duplicates #11307

Closed

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.TableControl

Expected 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 -AutoSize

In 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

  1. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Dec 10, 2019
  2. SteveL-MSFT commented on Dec 10, 2019

    @SteveL-MSFT
    Member

    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.

  3. mklement0 commented on Dec 10, 2019

    @mklement0
    ContributorAuthor

    Steve Lee (@SteveL-MSFT): It isn't just AliasInfo: 10 type-view combinations are currently affected - please see the updated OP.

  4. added
    Issue-BugIssue has been identified as a bug in the product
    and removed
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Jan 15, 2021
  5. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    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.

  6. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    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.

  7. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    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.

  8. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions