Fix generating OutputType when running in Constrained Language Mode (#21605)

This commit is contained in:
Patrick Meinecke
2024-05-06 12:08:08 -07:00
committed by GitHub
parent 0fee36393f
commit 467538ff9b
@@ -1565,7 +1565,15 @@ namespace System.Management.Automation.Language
if (args[0] is Type)
{
result = new OutputTypeAttribute(LanguagePrimitives.ConvertTo<Type[]>(args));
// We avoid `ConvertTo<Type[]>(args)` here as CLM would throw due to `Type[]`
// being a "non-core" type. NOTE: This doesn't apply to `string[]`.
Type[] types = new Type[args.Length];
for (int i = 0; i < args.Length; i++)
{
types[i] = LanguagePrimitives.ConvertTo<Type>(args[i]);
}
result = new OutputTypeAttribute(types);
}
else
{