Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / reflection-enum.cs
1 using System.Reflection;
2 using System;
3
4 namespace Test {
5         public class T {
6                 public static int Main(string[] args) {
7                         string defaultn = "System.Reflection.ParameterAttributes";
8                         string name = defaultn;
9                         int verbose = 0;
10                         foreach (string arg in args) {
11                                 if (arg == "-v")
12                                         verbose = 1;
13                                 else
14                                         name = arg;
15                         }
16                         Type t = Type.GetType (name);
17                         Array values = Enum.GetValues (t);
18                         string[] names = Enum.GetNames (t);
19                         int i;
20                 
21                         if (verbose != 0) {
22                                 Console.WriteLine ("Enum "+t.Name);
23                                 for (i = 0; i < names.Length; ++i) {
24                                         Console.WriteLine ("{0} = {1} (ToString: {2})", names [i], ((int)values.GetValue(i)).ToString(), values.GetValue(i));
25                                 }
26                         }
27                         if (name == defaultn) {
28                                 string[] truenames = {"None", "In", "Out", "Lcid", "Retval",
29                                         "Optional", "HasDefault", "HasFieldMarshal",
30                                         "Reserved3", "Reserved4", "ReservedMask"};
31                                 int[] truevalues = {0, 1, 2, 4, 8, 16, 4096, 8192,
32                                         16384, 32768, 61440};
33
34                                 for (i = 0; i < names.Length; ++i) {
35                                         if (names [i] != truenames [i])
36                                                 return 1 + i;
37                                         if ((int)values.GetValue (i) != truevalues [i])
38                                                 return 1 + names.Length + i;
39                                 }
40                         }
41                         return 0;
42                 }
43         }
44 }