1 // The .NET Foundation licenses this file to you under the MIT license. 2 // See the LICENSE file in the project root for more information. 3 4 using System; 5 using System.Runtime.CompilerServices; 6 7 #pragma warning disable 169 // Field 'x' is never used 8 9 namespace System.Runtime.CompilerServices 10 { 11 [__BlockReflection] 12 public class __BlockReflectionAttribute : Attribute 13 { 14 } 15 } 16 17 namespace BlockedMetadata 18 { 19 [__BlockReflection] 20 public class BlockedType 21 { 22 } 23 24 public class AllowedType 25 { 26 } 27 28 [__BlockReflection] 29 public class BlockedGenericType<T> 30 { 31 } 32 33 public class AllowedGenericType<T> 34 { 35 } 36 37 [__BlockReflection] 38 public enum BlockedEnum 39 { 40 One, 41 Two, 42 } 43 44 public enum AllowedEnum 45 { 46 One, 47 Two, 48 } 49 50 public class AttributeHolder 51 { 52 [My(typeof(AllowedType))] 53 int AllowedNongeneric; 54 55 [My(typeof(BlockedType))] 56 int BlockedNongeneric; 57 58 [My(typeof(AllowedGenericType<AllowedType>))] 59 int AllowedGeneric; 60 61 [My(typeof(BlockedGenericType<AllowedType>))] 62 int BlockedGeneric; 63 64 [My(typeof(AllowedGenericType<BlockedType>))] 65 int BlockedGenericInstantiation; 66 67 [My(typeof(AllowedGenericType<BlockedType[]>))] 68 int BlockedArrayGenericInstantiation; 69 70 [My(AllowedEnum.One)] 71 int AllowedEnumType; 72 73 [My(BlockedEnum.One)] 74 int BlockedEnumType; 75 76 [Blocked] 77 int BlockedAttribute; 78 79 [My(new object[] { typeof(AllowedType) })] 80 int AllowedTypeArray; 81 82 [My(new object[] { typeof(BlockedType)})] 83 int BlockedTypeArray; 84 85 [My(new object[] { AllowedEnum.One })] 86 int AllowedEnumArray; 87 88 [My(new object[] { BlockedEnum.One})] 89 int BlockedEnumArray; 90 } 91 92 public class MyAttribute : Attribute 93 { MyAttribute(Type type)94 public MyAttribute(Type type) 95 { 96 } 97 MyAttribute(object[] o)98 public MyAttribute(object[] o) 99 { 100 } 101 MyAttribute(object o)102 public MyAttribute(object o) 103 { 104 } 105 } 106 107 [__BlockReflection] 108 public class BlockedAttribute : Attribute 109 { 110 } 111 } 112