未验证 提交 bf1af7ff 编写于 作者: S Stephen Toub 提交者: GitHub

Remove OfType/ToArray usage from ReflectTypeDescriptionProvider (#66949)

上级 7a6c8087
......@@ -7,7 +7,6 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Threading;
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册