Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Write-Output -NoEnumerate outputs PSObject[] rather than Object[] and generally doesn't respect the input collection type #5955

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

Related: #5122

  • Write-Output -NoEnumerate, when given a collection, always returns a PSObject[] rather than a regular object[]] array, which is unexpected.

  • Additionally, this means that if a different collection type such as [System.Collections.ArrayList] was passed, it is not preserved.

    • Write-Output's documentation, which currently only states, "prevents Write-Output from enumerating output", which sounds like the input collection - whatever its type - is simply passed through - a sensible expectation that Windows PowerShell versions up to v5.1 indeed honor.

I suspect this regression is a consequence of the ill-fated #2038 PR that arose out of issue #2035.

Steps to reproduce

(Write-Output -NoEnumerate 1, 2).GetType().Name
(Write-Output -NoEnumerate ([System.Collections.ArrayList] (1, 2))).GetType().Name

Expected behavior

Object[]
ArrayList

This is how it still works in Windows PowerShell v5.1

Actual behavior

PSObject[]
PSObject[]

As stated, this affects PS Core only.

Environment data

PowerShell Core v6.0.0 on macOS 10.13.2
PowerShell Core v6.0.0 on Ubuntu 16.04.3 LTS
PowerShell Core v6.0.0 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.