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

Remove OfType/ToArray usage from ReflectTypeDescriptionProvider #66949

Merged
merged 1 commit into from
Mar 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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