Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When generating OutputType don't cast to Type[] #21605

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/System.Management.Automation/engine/parser/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,15 @@ private static Attribute NewOutputTypeAttribute(AttributeAst ast)

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]);
daxian-dbw marked this conversation as resolved.
Show resolved Hide resolved
}

result = new OutputTypeAttribute(types);
}
else
{
Expand Down
Loading