Add assert when dllmap is disabled and fix support build in netcore mode
[mono-project.git] / mono / tests / reinit.cs
blob8c5bde036b89cb87a4855de1c5e5db52a34f9c2e
1 using System;
2 using System.Reflection;
4 class T {
5 int v;
6 int a;
7 public T () {
8 v = 1;
9 // note: a not modified
11 static int Main () {
12 Type t = typeof (T);
13 T obj = new T ();
14 MethodBase m1;
15 Console.WriteLine ("after ctor a is {0}", obj.a);
16 Console.WriteLine ("after ctor v is {0}", obj.v);
17 obj.a = 2;
18 obj.v = 5;
19 Console.WriteLine ("a is {0}", obj.a);
20 Console.WriteLine ("v is {0}", obj.v);
22 m1 = t.GetConstructor (Type.EmptyTypes);
23 m1.Invoke (obj, null);
24 Console.WriteLine ("after reinit a is {0}", obj.a);
25 Console.WriteLine ("after reinit v is {0}", obj.v);
26 /* value not preserved */
27 if (obj.a != 2)
28 return 1;
29 /* value not reinitialized */
30 if (obj.v != 1)
31 return 2;
33 return 0;