-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
Note:
-
I don't know whether / what other libraries are affected, or whether Newtonsoft.Json is an unusual one.
-
The bug surfaces only if the input JSON text contains an array.
-
The bug is a regression from Windows PowerShell, where it doesn't surface.
-
The error is ultimately the same as in Working directly with certain .NET types, such as Newtonsoft.Json's, is broken: implicit stringification #10652:
Target type System.Collections.IEnumerator is not a value type or a non-abstract class. (Parameter 'targetType')- note how the type name is an interface, not a class.
Steps to reproduce
# Parse JSON text into a [JObject] instance.
# Note: To surface the bug, the text must contain an ARRAY
$obj = [Newtonsoft.Json.JsonConvert]::DeserializeObject('{ "foo": [ "bar" ] }')
# Apply default output formatting, which fails due to the bug:
{ $obj | Out-String } | Should -Not -ThrowExpected behavior
The test should succeed.
Actual behavior
The test fails, because the implicit output formatting threw an exception.
Target type System.Collections.IEnumerator is not a value type or a non-abstract class.
(Parameter 'targetType')
PowerShell Core 7.0.0-preview.4
Metadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime