Skip to content

Write-Output -NoEnumerate should not convert items in list to PSObject #8124

Closed

Description

@TylerLeonhardt

Steps to reproduce

→ [int[]] $before = @(1,2,3,4)

→ $before.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Int32[]                                  System.Array

→ $after = Write-Output $before -NoEnumerate

→ $after.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     PSObject[]                               System.Array

Expected behavior

$after's type should still be Int32[] because Write-Output -NoEnumerate should not mess with the contents of the array.

Actual behavior

$after's type is PSObject[]

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0
PSEdition                      Core
GitCommitId                    6.1.0
OS                             Darwin 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:59:21 PDT 2018; root:xnu-4903.201.2~4/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. mklement0 commented on Oct 26, 2018

    @mklement0
    Contributor

    Indeed, but this has been reported before: #5955

    In fact, there's a few related issues: https://github.com/PowerShell/PowerShell/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+Write-Output+-NoEnumerate+in%3Atitle

    All of which seem to originate in this ill-fated PR: #2038, originally discussed in #2035.

  2. TylerLeonhardt commented on Oct 26, 2018

    @TylerLeonhardt
    MemberAuthor

    Sounds good. I'll resolve as dupe to #5955

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions