Skip to content

Commit

Permalink
Remove OfType/ToArray usage from ReflectTypeDescriptionProvider (#66949)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Mar 22, 2022
1 parent 7a6c808 commit bf1af7f
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Threading;

Expand Down Expand Up @@ -1006,7 +1005,7 @@ internal static Attribute[] ReflectGetAttributes(Type type)
{
// Get the type's attributes.
//
attrs = type.GetCustomAttributes(typeof(Attribute), false).OfType<Attribute>().ToArray();
attrs = Attribute.GetCustomAttributes(type, typeof(Attribute), inherit: false);
attributeCache[type] = attrs;
}
}
Expand Down Expand Up @@ -1034,7 +1033,7 @@ internal static Attribute[] ReflectGetAttributes(MemberInfo member)
{
// Get the member's attributes.
//
attrs = member.GetCustomAttributes(typeof(Attribute), false).OfType<Attribute>().ToArray();
attrs = Attribute.GetCustomAttributes(member, typeof(Attribute), inherit: false);
attributeCache[member] = attrs;
}
}
Expand Down Expand Up @@ -1292,7 +1291,7 @@ private static PropertyDescriptor[] ReflectGetExtendedProperties(IExtenderProvid
properties = newProperties;
}

Debug.Assert(!properties.Any(dbgProp => dbgProp == null), $"Holes in property array for type {type}");
Debug.Assert(Array.TrueForAll(properties, dbgProp => dbgProp is not null), $"Holes in property array for type {type}");

propertyCache[type] = properties;
}
Expand Down

0 comments on commit bf1af7f

Please sign in to comment.