mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix generating OutputType when running in Constrained Language Mode (#21605)
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user