[interp] Remove unreachable code (#12411)
[mono-project.git] / mono / tests / delegate12.cs
blob4f47c78a79ae6c1dfc0bcf5fd39b2d60d5be5b9e
1 using System;
3 class MainClass
5 public static int Main(string[] args)
7 DerivedClass o = new DerivedClass();
9 Func<string> del1 = GetDel1 (o);
10 Func<string> del2 = GetDel2 (o);
13 Console.WriteLine("Action\n======\nReflected type: {0}\nDeclaring type: {1}\nAttributes: {2}\nResult: {3}",
14 del1.Method.ReflectedType, del1.Method.DeclaringType, del1.Method.Attributes, del1 ());
16 Console.WriteLine ();
18 Console.WriteLine("Delegate\n========\nReflected type: {0}\nDeclaring type: {1}\nAttributes: {2}\nResult: {3}",
19 del2.Method.ReflectedType, del2.Method.DeclaringType, del2.Method.Attributes, del2 ());
21 if (del1.Method.ReflectedType != typeof (DerivedClass))
22 return 10;
23 if (del1.Method.DeclaringType != typeof (DerivedClass))
24 return 11;
25 if (del1 () != "Derived method")
26 return 12;
28 if (del2.Method.ReflectedType != typeof (DerivedClass))
29 return 20;
30 if (del2.Method.DeclaringType != typeof (DerivedClass))
31 return 21;
32 if (del2 () != "Derived method")
33 return 22;
35 if (!del1.Equals (del2))
36 return 30;
37 if (!del2.Equals (del1))
38 return 31;
40 return 0;
43 static Func<string> GetDel1 (DerivedClass o)
45 return o.GetMethod();
48 static Func<string> GetDel2 (DerivedClass o)
50 return (Func<string>) Delegate.CreateDelegate(typeof(Func<string>), o, o.GetMethod().Method);
54 class BaseClass
56 public Func<string> GetMethod()
58 return MyMethod;
61 public virtual string MyMethod()
63 return "Base method";
67 class DerivedClass : BaseClass
69 public override string MyMethod()
71 return "Derived method";