2010-05-31 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / test-39.cs
blob72035a58c90286088b12e98c6f0a3a5a65912e37
1 using System;
2 [AttributeUsage (AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
3 public class SimpleAttribute : Attribute {
5 string name = null;
7 public string MyNamedArg;
9 private string secret;
11 public SimpleAttribute (string name)
13 this.name = name;
16 public string AnotherArg {
17 get {
18 return secret;
20 set {
21 secret = value;
25 public long LongValue {
26 get {
27 return 0;
29 set { }
32 public long[] ArrayValue {
33 get {
34 return new long[0];
36 set { }
39 public object D;
42 [Simple ("Interface test")]
43 public interface IFoo {
44 void MethodOne (int x, int y);
45 bool MethodTwo (float x, float y);
48 [Simple ("Fifth", D=new double[] { -1 })]
49 class Blah2
53 [Simple ("Fifth", D=new double[0])]
54 class Blah3
58 [Simple ("Dummy", MyNamedArg = "Dude!")]
59 [Simple ("Vids", MyNamedArg = "Raj", AnotherArg = "Foo")]
60 [Simple ("Trip", LongValue=0)]
61 [Simple ("Fourth", ArrayValue=new long[] { 0 })]
62 public class Blah {
64 public static int Main ()
66 object o = (((SimpleAttribute)typeof(Blah2).GetCustomAttributes (typeof (SimpleAttribute), false)[0]).D);
67 if (o.ToString () != "System.Double[]")
68 return 1;
70 if (((double[])o)[0].GetType () != typeof (double))
71 return 2;
73 o = (((SimpleAttribute)typeof(Blah3).GetCustomAttributes (typeof (SimpleAttribute), false)[0]).D);
74 if (o.ToString () != "System.Double[]")
75 return 3;
77 Console.WriteLine ("OK");
78 return 0;