Skip to content

Interfaces should be included in TypeNames for PSObjects #7649

Closed

Description

Way back at the beginning of time, we (the PowerShell team) decided not to include interfaces in the list of types reported in TypeNames for a PSObject. I don't remember why we did this and can think of no good reason not to include them now. There are significant benefits if we do include them as end-users will then be able to write Type/Format extensions against interfaces e.g. write a ScriptMethod that works against IEnumerable. In particular this facillitates LINQ-like behaviours where a method can operate against an enumerable to return a new enumerable (lazy evaluation and infinite sequences). The one slight downside I can think of is that this increases the number of items in Typenames with may have a small effect on remoting due to transmitting the extra typename strings but we only do that once per object per operation so the impact appears to be negligible (at least based on my tests). There may also be a small increase in the about of memory used by objects but that's easily mitigated by unifying the type strings.

Implementation-wise, the Interface type names would appear after the concrete typenames so any existing type extensions will continue to work unchanged (i.e. not a breaking change.)

If you can think of any reasons why we shouldn't do this, please add comments to this issue.

Environment data

PSCore (1:90) >  $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.2
PSEdition                      Core
GitCommitId                    v6.1.0-preview.2
OS                             Microsoft Windows 10.0.17134
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. added
    Issue-Enhancement
    WG-Engine
    on Aug 28, 2018
  2. iSazonov commented on Aug 31, 2018

    @iSazonov
    Collaborator

    PowerShell can create tons PSObjects and even an allocation of an empty object in PSObject property (See #7435) can lead to very noticeable consequences.
    I hope that there are ways to make the internal structures of the PSObject very-very resource efficient.

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

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

  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. added
    Resolution-No Activity
    on Nov 16, 2023
  7. 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-EnhancementResolution-No ActivityWG-Engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions