From f99ba2e2b8fbf03be5058ad23e8cdce9c4a09da6 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Fri, 11 Mar 2022 13:12:20 -0800 Subject: Revert "Avoid Attribute.GetCustomAttributes() returning null for open generic type (#65237)" (#66508) This reverts commit 20294957616061616e672b43f1d962460b7f4234. --- .../GenericAttribute/GenericAttributeMetadata.cs | 2 -- .../reflection/GenericAttribute/GenericAttributeTests.cs | 14 +++----------- 2 files changed, 3 insertions(+), 13 deletions(-) (limited to 'src/tests/reflection') diff --git a/src/tests/reflection/GenericAttribute/GenericAttributeMetadata.cs b/src/tests/reflection/GenericAttribute/GenericAttributeMetadata.cs index 3bea1e62194..d0ef6353f4a 100644 --- a/src/tests/reflection/GenericAttribute/GenericAttributeMetadata.cs +++ b/src/tests/reflection/GenericAttribute/GenericAttributeMetadata.cs @@ -17,8 +17,6 @@ using System.Runtime.CompilerServices; [assembly: MultiAttribute()] [assembly: MultiAttribute(true)] -[module: SingleAttribute()] - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false)] public class SingleAttribute : Attribute { diff --git a/src/tests/reflection/GenericAttribute/GenericAttributeTests.cs b/src/tests/reflection/GenericAttribute/GenericAttributeTests.cs index b1dcd6bbbe3..e7661d2d5ae 100644 --- a/src/tests/reflection/GenericAttribute/GenericAttributeTests.cs +++ b/src/tests/reflection/GenericAttribute/GenericAttributeTests.cs @@ -18,16 +18,8 @@ class Program Assert(((ICustomAttributeProvider)assembly).IsDefined(typeof(SingleAttribute), true)); Assert(CustomAttributeExtensions.IsDefined(assembly, typeof(SingleAttribute))); Assert(((ICustomAttributeProvider)assembly).IsDefined(typeof(SingleAttribute), true)); - Assert(!CustomAttributeExtensions.GetCustomAttributes(assembly, typeof(SingleAttribute<>)).GetEnumerator().MoveNext()); - Assert(!CustomAttributeExtensions.GetCustomAttributes(assembly, typeof(SingleAttribute<>)).GetEnumerator().MoveNext()); -*/ - // Module module = programTypeInfo.Module; - // AssertAny(CustomAttributeExtensions.GetCustomAttributes(module), a => a is SingleAttribute); - // Assert(CustomAttributeExtensions.GetCustomAttributes(module, typeof(SingleAttribute)).GetEnumerator().MoveNext()); - // Assert(CustomAttributeExtensions.GetCustomAttributes(module, typeof(SingleAttribute)).GetEnumerator().MoveNext()); - // Assert(!CustomAttributeExtensions.GetCustomAttributes(module, typeof(SingleAttribute<>)).GetEnumerator().MoveNext()); - // Assert(!CustomAttributeExtensions.GetCustomAttributes(module, typeof(SingleAttribute<>)).GetEnumerator().MoveNext()); +*/ TypeInfo programTypeInfo = typeof(Class).GetTypeInfo(); Assert(CustomAttributeExtensions.GetCustomAttribute>(programTypeInfo) != null); @@ -160,8 +152,8 @@ class Program AssertAny(b10, a => (a as MultiAttribute)?.Value == typeof(Class)); AssertAny(b10, a => (a as MultiAttribute)?.Value == typeof(Class.Derive)); - Assert(!CustomAttributeExtensions.GetCustomAttributes(programTypeInfo, typeof(MultiAttribute<>), false).GetEnumerator().MoveNext()); - Assert(!CustomAttributeExtensions.GetCustomAttributes(programTypeInfo, typeof(MultiAttribute<>), true).GetEnumerator().MoveNext()); + Assert(CustomAttributeExtensions.GetCustomAttributes(programTypeInfo, typeof(MultiAttribute<>), false) == null); + Assert(CustomAttributeExtensions.GetCustomAttributes(programTypeInfo, typeof(MultiAttribute<>), true) == null); Assert(!((ICustomAttributeProvider)programTypeInfo).GetCustomAttributes(typeof(MultiAttribute<>), true).GetEnumerator().MoveNext()); // Test coverage for CustomAttributeData api surface -- cgit v1.2.3