Skip to content

Why is ([System.Collections.ObjectModel.Collection[psobject]]1)[0] a string? #7154

@alx9r

Description

@alx9r

I've been using this conversion to pass objects to PowerShell.Invoke() like this:

PowerShell.Invoke([System.Collections.ObjectModel.Collection[psobject]]$obj)

I'm puzzled by this conversion from [int32] to [string].

Steps to reproduce

([System.Collections.ObjectModel.Collection[psobject]]1)[0].GetType().Name

Expected behavior

I expected 1 to remain an [int32].

int32

Actual behavior

1 is converted to a [string]

string

Environment data

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-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