blob: aea7430097c2dc2d1354ea01845d842ac0b14686 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
using System;
using System.Reflection;
namespace Test {
[AttributeUsage (AttributeTargets.All, AllowMultiple = true)]
public class My1Attribute : Attribute
{
public My1Attribute (object o)
{
if (o != null)
throw new ApplicationException ();
}
}
public class My2Attribute : Attribute
{
public My2Attribute (string[] s)
{
if (s.Length != 0)
throw new ApplicationException ();
}
}
public class My3Attribute : Attribute
{
public My3Attribute (byte b)
{
if (b != 0xFF)
throw new ApplicationException ();
}
}
[My3(unchecked((byte)-1))]
[My1((object)null)]
[My1(null)]
[My2(new string[0])]
public class Test {
public static int Main() {
System.Reflection.MemberInfo info = typeof (Test);
object[] attributes = info.GetCustomAttributes (false);
if (attributes.Length != 4)
return 1;
for (int i = 0; i < attributes.Length; i ++) {
Console.WriteLine (attributes [i]);
}
return 0;
}
}
}
|