2010-06-17 Geoff Norton <gnorton@novell.com>
[mono.git] / mono / tests / reflection.cs
blob2fc292b7f6990b8ca88eba0230737e0bea0684a1
1 using System.Reflection;
2 using System.Collections;
3 using System;
5 namespace Test {
6 internal class CM : IComparer {
7 public int Compare (object x, object y) {
8 return ((MethodInfo)x).Name.CompareTo (((MethodInfo)y).Name);
11 public class T {
12 public static int Main(string[] args) {
13 string[] names = {
14 "Equals", "Equals",
15 "GetHashCode", "GetType",
16 "ReferenceEquals", "ToString"
18 int i;
19 string name = "System.Object";
20 if (args.Length > 0)
21 name = args [0];
22 Type t = Type.GetType (name, true);
23 MethodInfo[] ms = t.GetMethods();
25 Array.Sort (ms, new CM());
26 foreach (MethodInfo m in ms) {
27 Console.WriteLine (m.ReturnType.Name + " " + m.Name);
29 if (name == "System.Object") {
30 for (i=0; i < names.Length; ++i)
31 if (names [i] != ms [i].Name)
32 return i + 1;
34 return 0;