Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;

namespace System.Reflection.Runtime.CustomAttributes
Expand Down Expand Up @@ -166,13 +167,13 @@ protected static CustomAttributeTypedArgument WrapInCustomAttributeTypedArgument
}

// Handle the array case
if (value is IEnumerable enumerableValue && !(value is string))
if (value is Array arr)
{
if (!argumentType.IsArray)
throw new BadImageFormatException();
Type reportedElementType = argumentType.GetElementType()!;
ArrayBuilder<CustomAttributeTypedArgument> elementTypedArguments = default;
foreach (object elementValue in enumerableValue)
foreach (object elementValue in arr)
{
CustomAttributeTypedArgument elementTypedArgument = WrapInCustomAttributeTypedArgument(elementValue, reportedElementType);
elementTypedArguments.Add(elementTypedArgument);
Expand All @@ -181,6 +182,7 @@ protected static CustomAttributeTypedArgument WrapInCustomAttributeTypedArgument
}
else
{
Debug.Assert(value is string or (not IEnumerable));
return new CustomAttributeTypedArgument(argumentType, value);
}
}
Expand Down
Loading