-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Open
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Hi, A single hashtable object can be cast to System.Array of custom objects
using namespace System.Collections.Generic
class Foo {
[int]$A
}
# OK
[Foo[]]@{ A = 1 }
# OK
[List[Foo]]@(@{ A = 2 })
# OK
[List[Foo]][Foo]@{ A = 3 }But can’t cast to List<T>
# Error
[List[Foo]]@{ A = 4 }Is this a bug?
Expected behavior
PS> [List[Foo]]@{ A = 4 }
A
-
4Actual behavior
PS> [List[Foo]]@{ A = 4 }
InvalidArgument: ……Error details
No response
Environment data
PS> $PSVersionTable
Name
Value
--—-
- ----
PSVersion
7.4.6
PSEdition
Core
GitCommitId
7.4.6
OS
Ubuntu 20.04.6 LTS
Platform
Unix
PSCompatibleVersions
{1.0, 2.0,
3.0, 4.0...}
PSRemotingProtocolVersion
2.3
SerializationVersion
1.1.0.1
WSManStackVersion
3.0Visuals
mklement0
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group

