diff options
author | Atsushi Kanamori <AtsushiKan@users.noreply.github.com> | 2017-07-18 01:05:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-18 01:05:58 +0300 |
commit | c78142b8df1be3aff94a7fb3ee0e9283ba1029ab (patch) | |
tree | b568667c62731c2553302f56d10e80d55d0ec6da /src/System.Private.Reflection.Core | |
parent | 238bd67f62b58281fcb170c01f95516044eb7611 (diff) |
Fix an assert on Type.GetTypeFromCLSID().CustomAttributes (#4175)
(If you've noticed a trend of me getting less tolerant
of unsealed overrides on Reflection types, it's because
of stuff like this.)
Diffstat (limited to 'src/System.Private.Reflection.Core')
3 files changed, 28 insertions, 16 deletions
diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeClsIdTypeInfo.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeClsIdTypeInfo.cs index b09238548..6cc8532dc 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeClsIdTypeInfo.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeClsIdTypeInfo.cs @@ -9,6 +9,7 @@ using System.Reflection.Runtime.General; using System.Reflection.Runtime.MethodInfos; using System.Runtime.InteropServices; +using Internal.Reflection.Tracing; using Internal.Reflection.Core.Execution; namespace System.Reflection.Runtime.TypeInfos @@ -36,6 +37,19 @@ namespace System.Reflection.Runtime.TypeInfos public sealed override StructLayoutAttribute StructLayoutAttribute => BaseType.StructLayoutAttribute; public sealed override string ToString() => BaseType.ToString(); + public sealed override IEnumerable<CustomAttributeData> CustomAttributes + { + get + { +#if ENABLE_REFLECTION_TRACE + if (ReflectionTrace.Enabled) + ReflectionTrace.TypeInfo_CustomAttributes(this); +#endif + + return Empty<CustomAttributeData>.Enumerable; + } + } + public sealed override bool HasSameMetadataDefinitionAs(MemberInfo other) { if (other == null) diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeHasElementTypeInfo.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeHasElementTypeInfo.cs index e60ec6313..e01f8f584 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeHasElementTypeInfo.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeHasElementTypeInfo.cs @@ -73,6 +73,19 @@ namespace System.Reflection.Runtime.TypeInfos } } + public sealed override IEnumerable<CustomAttributeData> CustomAttributes + { + get + { +#if ENABLE_REFLECTION_TRACE + if (ReflectionTrace.Enabled) + ReflectionTrace.TypeInfo_CustomAttributes(this); +#endif + + return Empty<CustomAttributeData>.Enumerable; + } + } + public sealed override bool ContainsGenericParameters { get diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.cs index 7eae18886..6d816e0a5 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.cs @@ -110,22 +110,7 @@ namespace System.Reflection.Runtime.TypeInfos public abstract override bool ContainsGenericParameters { get; } - // - // Left unsealed so that RuntimeNamedTypeInfo and RuntimeConstructedGenericTypeInfo and RuntimeGenericParameterTypeInfo can override. - // - public override IEnumerable<CustomAttributeData> CustomAttributes - { - get - { -#if ENABLE_REFLECTION_TRACE - if (ReflectionTrace.Enabled) - ReflectionTrace.TypeInfo_CustomAttributes(this); -#endif - - Debug.Assert(IsArray || IsByRef || IsPointer); - return Empty<CustomAttributeData>.Enumerable; - } - } + public abstract override IEnumerable<CustomAttributeData> CustomAttributes { get; } // // Left unsealed as generic parameter types must override. |