public MainApp(MainApp a, Struct1 s1, Struct2 s2, Struct3 s3, Struct4 s4, Struct5 s5, Struct8 s8, Valuesa v, float f, double d, Object o, String s, Enumacek e) { String values = a.ToString() + " " + s1.ToString() + " " + s2.ToString() + " " + s3.ToString() + " " + s4.ToString() + " " + s5.ToString() + " " + s8.ToString() + " " + v.ToString() + " " + f.ToString() + " " + d.ToString() + " " + o.ToString() + " " + s.ToString() + " " + e.ToString() + " " + "."; if (values != "MainApp 9 104 225 80 57 184 17 160 105 8 65 240" + " 153 88 113 64 201 168 161 144 249 248 209 224 -23767 606228808 2874968872843236" + "865 -9016159779942285264 360942425 4248 49 -5.193024E+18 -6.58392565490175E+18 M" + "ainApp 2212973731230676456 Hali .") { Console.WriteLine("MainApp(...): unexpected values: " + values); Fail(22); } }
static float Worker( float x1, double x2, Valuesa v, double x3, double x4, double x5, double x6, double x7, double x8, double x9, double x10, double x11, double x12, double x13, double x14, double x15, double x16, double x17, float x18) { Console.WriteLine(x1.ToString() + " " + x2.ToString() + " " + v.ToString() + " " + x17.ToString() + " " + x18.ToString()); long vv = v.a+v.b+v.c+v.d; v.a=0;v.b=0;v.c=0;v.d=0; return (float)(x1+x2+x3+vv+v.e+v.f+v.g+v.h+(float)x17+(float)x18); }
static float Worker( float x1, double x2, Valuesa v, double x3, double x4, double x5, double x6, double x7, double x8, double x9, double x10, double x11, double x12, double x13, double x14, double x15, double x16, double x17, float x18) { Console.WriteLine(x1.ToString() + " " + x2.ToString() + " " + v.ToString() + " " + x17.ToString() + " " + x18.ToString()); long vv = v.a + v.b + v.c + v.d; v.a = 0; v.b = 0; v.c = 0; v.d = 0; return((float)(x1 + x2 + x3 + vv + v.e + v.f + v.g + v.h + (float)x17 + (float)x18)); }
public Struct8 Foo(ref float r, Valuesa v, ushort t, ref ushort tr) { Struct8 ret = new Struct8(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "211 13120 -1219659045 754467178707868024 40" + "85042269830528355 -1490187216 -6293 104 -6.583926E+18 34594 34594 .") { Console.WriteLine("Struct8 Foo(...): unexpected values: " + values); Fail(16); } r += (float)Randomizer(); tr += (ushort)Randomizer(); ret.Randomize(); return(ret); }
public Valuesa Foo(float v, ref double r, uint t, ref uint tr) { Valuesa ret = new Valuesa(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "-1.414468E+19 2.21297372164627E+18 40937389" + "62 4093738962 .") { Console.WriteLine("Valuesa Foo(...): unexpected values: " + values); Fail(17); } r += (double)Randomizer(); tr += (uint)Randomizer(); ret.Randomize(); return(ret); }
public Struct5 Foo(Struct8 v, ref Valuesa r, byte t, ref byte tr) { Struct5 ret = new Struct5(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "193 121 129 185 65 249 1 57 41 20808 639653" + "377 -9016159779942285264 -7525944817302140071 1480724632 6961 128 114 114 .") { Console.WriteLine("Struct5 Foo(...): unexpected values: " + values); Fail(15); } r.Randomize(); tr += (byte)Randomizer(); ret.Randomize(); return(ret); }
public Struct6 Foo(Struct5 v, ref Valuesa r, byte t, ref byte tr) { Struct6 ret = new Struct6(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "112 25 216 241 192 138 -21480 225324986 -59" + "58788304505077400 2658617120903057130 486515128 -9446 8 51 51 .") { Console.WriteLine("Struct6 Foo(...): unexpected values: " + values); Fail(21); } r.Randomize(); tr += (byte)Randomizer(); ret.Randomize(); return(ret); }
public Struct8 Foo(ref float r, Valuesa v, ushort t, ref ushort tr) { Struct8 ret = new Struct8(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "121 -16511 697284281 -978709601062956991 15" + "81927808989185017 -802663167 32057 193 -5.193024E+18 33392 33392 .") { Console.WriteLine("Struct8 Foo(...): unexpected values: " + values); Fail(16); } r += (float)Randomizer(); tr += (ushort)Randomizer(); ret.Randomize(); return(ret); }
public Valuesa Foo(float v, ref double r, uint t, ref uint tr) { Valuesa ret = new Valuesa(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "4.005809E+18 -6.58392565490175E+18 23065482" + "88 2306548288 .") { Console.WriteLine("Valuesa Foo(...): unexpected values: " + values); Fail(17); } r += (double)Randomizer(); tr += (uint)Randomizer(); ret.Randomize(); return(ret); }
public Struct5 Foo(Struct8 v, ref Valuesa r, byte t, ref byte tr) { Struct5 ret = new Struct5(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "64 210 16 130 224 50 176 226 224 -23767 606" + "228808 2874968872843236865 -9016159779942285264 360942425 4248 49 160 160 .") { Console.WriteLine("Struct5 Foo(...): unexpected values: " + values); Fail(15); } r.Randomize(); tr += (byte)Randomizer(); ret.Randomize(); return(ret); }
public Struct6 Foo(Struct5 v, ref Valuesa r, byte t, ref byte tr) { Struct6 ret = new Struct6(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "112 25 216 241 192 138 -21480 225324986 -59" + "58788304505077400 2658617120903057130 486515128 -9446 8 51 51 .") { Console.WriteLine("Struct6 Foo(...): unexpected values: " + values); Fail(21); } r.Randomize(); tr += (byte)Randomizer(); ret.Randomize(); return ret; }
public Struct5 Foo(Struct8 v, ref Valuesa r, byte t, ref byte tr) { Struct5 ret = new Struct5(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "193 121 129 185 65 249 1 57 41 20808 639653" + "377 -9016159779942285264 -7525944817302140071 1480724632 6961 128 114 114 .") { Console.WriteLine("Struct5 Foo(...): unexpected values: " + values); Fail(15); } r.Randomize(); tr += (byte)Randomizer(); ret.Randomize(); return ret; }
public Valuesa Foo(float v, ref double r, uint t, ref uint tr) { Valuesa ret = new Valuesa(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "-1.414468E+19 2.21297372164627E+18 40937389" + "62 4093738962 .") { Console.WriteLine("Valuesa Foo(...): unexpected values: " + values); Fail(17); } r += (double)Randomizer(); tr += (uint)Randomizer(); ret.Randomize(); return ret; }
public Struct8 Foo(ref float r, Valuesa v, ushort t, ref ushort tr) { Struct8 ret = new Struct8(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "121 -16511 697284281 -978709601062956991 15" + "81927808989185017 -802663167 32057 193 -5.193024E+18 33392 33392 .") { Console.WriteLine("Struct8 Foo(...): unexpected values: " + values); Fail(16); } r += (float)Randomizer(); tr += (ushort)Randomizer(); ret.Randomize(); return ret; }
static public void Main() { int[,] ia = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }; if (ia[2, 3] != 12) { Console.WriteLine("Unexpected ia[2,3]: " + ia[2, 3]); Environment.Exit(2); } ia[1, 2] = 100; Check(__makeref(ia[1, 2]), 100); try { ia[3, 2] = 0; Console.WriteLine("IndexOutOfRangeException expected"); Environment.Exit(2); } catch (IndexOutOfRangeException) { } ia = null; try { ia[3, 2] = 0; Console.WriteLine("NullReferenceException expected"); Environment.Exit(2); } catch (NullReferenceException) { } byte[,,] ba = { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } }; if (ba[1, 0, 1] != 6) { Console.WriteLine("Unexpected ba[1,0,1]: " + ba[1, 0, 1]); Environment.Exit(2); } ba[1, 0, 1] = 101; Check(__makeref(ba[1, 0, 1]), (byte)101); short[,,] sa = { { { -1111, -2222 }, { -3333, -4444 } }, { { -5555, -6666 }, { -7777, -8888 } } }; if (sa[1, 1, 1] != -8888) { Console.WriteLine("Unexpected sa[1,1,1]: " + sa[1, 1, 1]); Environment.Exit(3); } sa[0, 1, 0] = -1002; Check(__makeref(sa[0, 1, 0]), (short)-1002); long[,] la = { { 111111111111L, 222222222222L }, { 333333333333L, 444444444444L } }; if (la[1, 1] != 444444444444L) { Console.WriteLine("Unexpected la[1,1]: " + la[1, 1]); Environment.Exit(4); } la[1, 0] = 444444444444L; Check(__makeref(la[1, 0]), (long)444444444444L); float[,] fa = { { 1.0F, 2.0F, 3.0F }, { 4.0F, 5.0F, 6.0F }, { 4.0F, 5.0F, 6.0F } }; if (fa[1, 2] != 6.0F) { Console.WriteLine("Unexpected fa[1,2]: " + fa[1, 2]); Environment.Exit(5); } fa[2, 1] = Single.PositiveInfinity; Check(__makeref(fa[2, 1]), Single.PositiveInfinity); double[,] da = { { 1.0, 2.0, 3.0, 4.0 }, { 5.0, 6.0, 7.0, 8.0 }, { 9.0, 10.0, 11.0, 12.0 } }; if (da[2, 2] != 11.0) { Console.WriteLine("Unexpected da[2,2]: " + da[2, 2]); Environment.Exit(6); } da[2, 3] = 1234.5; Check(__makeref(da[2, 3]), 1234.5); String[,,,,,,,,,] stra = new String[2, 2, 2, 2, 2, 2, 2, 2, 2, 2]; stra[0, 1, 0, 1, 0, 1, 0, 1, 0, 1] = "Hello"; if (stra[0, 1, 0, 1, 0, 1, 0, 1, 0, 1] != "Hello") { Console.WriteLine("Unexpected stra[...]: " + stra[0, 1, 0, 1, 0, 1, 0, 1, 0, 1]); Environment.Exit(7); } Check(__makeref(stra[0, 1, 0, 1, 0, 1, 0, 1, 0, 1]), "Hello"); try { Object[,,,,,,,,,] oba = stra; oba[1, 0, 1, 0, 1, 0, 1, 0, 1, 0] = null; oba[1, 0, 1, 0, 1, 0, 1, 0, 1, 0] = new Object(); Console.WriteLine("ArrayTypeMismatchException expected"); Environment.Exit(8); } catch (ArrayTypeMismatchException) { } Struct2 s2; Struct2[,] s2a = new Struct2[5, 6]; s2.x = -1234; s2a[2, 3] = s2; s2 = s2a[2, 3]; if (s2.x != -1234) { Console.WriteLine("Unexpected s2a[2,3]: " + s2a[2, 3].x); Environment.Exit(9); } Check(__makeref(s2a[2, 3]), s2); Valuesa v; v.a = 11111111; v.b = 1111111111111111; v.c = new Object(); v.d = "Hello"; v.e = 2222222222222222; Valuesa[,,,] va = new Valuesa[1, 2, 3, 4]; va[0, 1, 2, 3] = v; v = va[0, 1, 2, 3]; if (v.a != 11111111 || v.b != 1111111111111111 || v.d != "Hello" || v.e != 2222222222222222) { Console.WriteLine("Unexpected va[...]"); Environment.Exit(10); } Check(__makeref(va[0, 1, 2, 3]), v); Console.WriteLine("Passed"); }
static public void RunTests(MainApp This) { String values; Struct1 s1 = new Struct1(); Struct2 s2 = new Struct2(); Struct3 s3 = new Struct3(); Struct4 s4 = new Struct4(); Struct5 s5 = new Struct5(); Struct6 s6 = new Struct6(); Struct8 s8 = new Struct8(); Valuesa v = new Valuesa(); float f; double d; Object o; String s; Enumacek e; sbyte p1; byte p2; short p3; ushort p4; int p5; uint p6; long p7; ulong p8; s1.Randomize(); s2.Randomize(); s3.Randomize(); s4.Randomize(); s5.Randomize(); s6.Randomize(); s8.Randomize(); v.Randomize(); f = (float)Randomizer(); d = (float)Randomizer(); o = This; s = Randomizer().ToString(); e = Enumacek.Hali; p1 = (sbyte)Randomizer(); p2 = (byte)Randomizer(); p3 = (short)Randomizer(); p4 = (ushort)Randomizer(); p5 = (int)Randomizer(); p6 = (uint)Randomizer(); p7 = (long)Randomizer(); p8 = (ulong)Randomizer(); // set all fields This._s1 = s1; This._s2 = s2; This._s3 = s3; This._s4 = s4; This._s5 = s5; This._s6 = s6; This._s8 = s8; This._v = v; This._f = f; This._d = d; This._o = o; This._s = s; This._e = e; This._p1 = p1; This._p2 = p2; This._p3 = p3; This._p4 = p4; This._p5 = p5; This._p6 = p6; This._p7 = p7; This._p8 = p8; values = This.ToString(); if (values != "9 104 225 80 57 184 17 160 105 8 65 240 153 88 113 931407168" + " 201 168 161 144 249 248 209 224 41 20808 639653377 -9016159779942285264" + " -7525944817302140071 1480724632 6961 128 -6.583926E+18 2.21297372164627E+18" + " MainApp -5893266573950244255 Hali -48 185 -16072 17297 -994209504 2046869481" + " 1703311890815005320 1413371402307118785 .") { Console.WriteLine("SetFields: unexpected values: " + values); Fail(101); } Console.WriteLine("Field setters succeeded"); // invoke the methods p1 = This.Foo(p1); p2 = This.Foo(p2); p3 = This.Foo(p3); p4 = This.Foo(p4); p5 = This.Foo(p5); p6 = This.Foo(p6); p7 = This.Foo(p7); p8 = This.Foo(p8); // verify the values of all fields values = p1.ToString() + " " + p2.ToString() + " " + p3.ToString() + " " + p4.ToString() + " " + p5.ToString() + " " + p6.ToString() + " " + p7.ToString() + " " + p8.ToString() + " " + "."; if (values != "-96 114 -32144 34594 -19884190" + "08 4093738962 3406623781630010640 2826742804614237570 .") { Console.WriteLine("Locals after primitive Invoke: unexpected values: " + values); Fail(102); } s1 = This.Foo(s2, ref s3, p1, ref p1); s2 = This.Foo(ref s4, s3, p3, ref p3); s3 = This.Foo(s4, ref s5, p5, ref p5); s4 = This.Foo(ref s8, s5, p7, ref p7); s5 = This.Foo(s8, ref v, p2, ref p2); s6 = This.Foo(s5, ref v, p2, ref p2); s8 = This.Foo(ref f, v, p4, ref p4); v = This.Foo(f, ref d, p6, ref p6); f = This.Foo(ref s1, d, p8, ref p8); d = This.Foo(ref s2, s1, s, ref s); // verify the values of all fields values = This.ToString(); if (values != "9 104 225 80 57 184 17 160 105 8 65 240 " + "153 88 113 931407168 201 168 161 144 249 248 209 224 41 20808 639653377 -9016159" + "779942285264 -7525944817302140071 1480724632 6961 128 -6.583926E+18 2.2129737216" + "4627E+18 MainApp -5893266573950244255 Hali -48 185 -16072 17297 -994209504 20468" + "69481 1703311890815005320 1413371402307118785 .") { Console.WriteLine("Fields after Invoke: unexpected values: " + values); Fail(103); } // verify the values of all locals values = s1.ToString() + " " + s2.ToString() + " " + s3.ToString() + " " + s4.ToString() + " " + s5.ToString() + " " + s6.ToString() + " " + s8.ToString() + " " + v.ToString() + " " + f.ToString() + " " + d.ToString() + " " + o.GetType().ToString() + " " + s.ToString() + " " + e.ToString() + " " + p1.ToString() + " " + p2.ToString() + " " + p3.ToString() + " " + p4.ToString() + " " + p5.ToString() + " " + p6.ToString() + " " + p7.ToString() + " " + p8.ToString() + " " + "."; if (values != "170 233 145 161 144 249 49 128 137 232 1" + "12 25 216 241 192 263746504 217 24 177 0 9 104 225 80 17 7072 -1278944919 567925" + "9233286952200 964207834727950401 -272742416 14745 88 -7.848656E+18 3.16790391993" + "929E+18 MainApp -5893266573950244255 Hali -16 220 21112 49618 -153164056 1655108" + "490 -374121548284004952 17419808404417595330 .") { Console.WriteLine("Locals after Invoke: unexpected values: " + values); Fail(104); } Console.WriteLine("Method invokes succeeded"); // get all fields s1 = This._s1; s2 = This._s2; s3 = This._s3; s4 = This._s4; s5 = This._s5; s6 = This._s6; s8 = This._s8; v = This._v; f = This._f; d = This._d; o = This._o; s = This._s; e = This._e; p1 = This._p1; p2 = This._p2; p3 = This._p3; p4 = This._p4; p5 = This._p5; p6 = This._p6; p7 = This._p7; p8 = This._p8; // verify the values of all locals values = s1.ToString() + " " + s2.ToString() + " " + s3.ToString() + " " + s4.ToString() + " " + s5.ToString() + " " + s6.ToString() + " " + s8.ToString() + " " + v.ToString() + " " + f.ToString() + " " + d.ToString() + " " + o.GetType().ToString() + " " + s.ToString() + " " + e.ToString() + " " + p1.ToString() + " " + p2.ToString() + " " + p3.ToString() + " " + p4.ToString() + " " + p5.ToString() + " " + p6.ToString() + " " + p7.ToString() + " " + p8.ToString() + " " + "."; if (values != "9 104 225 80 57 184 17 160 105 8 65 240 153 88 113" + " 931407168 201 168 161 144 249 248 209 224 41 20808 639653377 -90161597799422852" + "64 -7525944817302140071 1480724632 6961 128 -6.583926E+18 2.21297372164627E+18 M" + "ainApp -5893266573950244255 Hali -48 185 -16072 17297 -994209504 2046869481 1703" + "311890815005320 1413371402307118785 .") { Console.WriteLine("GetFields: unexpected values: " + values); Fail(105); } Console.WriteLine("Field getters succeeded"); This.Foo(This, "O", "S", (float)Randomizer(), (double)Randomizer(), (float)Randomizer(), (double)Randomizer(), (float)Randomizer(), (double)Randomizer(), (long)Randomizer(), (long)Randomizer(), (long)Randomizer(), (long)Randomizer(), (long)Randomizer(), (long)Randomizer(), (sbyte)Randomizer(), (byte)Randomizer(), (short)Randomizer(), (ushort)Randomizer(), (int)Randomizer(), (uint)Randomizer(), (long)Randomizer(), (ulong)Randomizer(), (float)Randomizer(), (double)Randomizer(), (float)Randomizer(), (double)Randomizer(), (float)Randomizer(), (double)Randomizer()); }
public Struct5 Foo(Struct8 v, ref Valuesa r, byte t, ref byte tr) { Struct5 ret = new Struct5(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "64 210 16 130 224 50 176 226 224 -23767 606" + "228808 2874968872843236865 -9016159779942285264 360942425 4248 49 160 160 .") { Console.WriteLine("Struct5 Foo(...): unexpected values: " + values); Fail(15); } r.Randomize(); tr += (byte)Randomizer(); ret.Randomize(); return ret; }
public Struct8 Foo(ref float r, Valuesa v, ushort t, ref ushort tr) { Struct8 ret = new Struct8(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "211 13120 -1219659045 754467178707868024 40" + "85042269830528355 -1490187216 -6293 104 -6.583926E+18 34594 34594 .") { Console.WriteLine("Struct8 Foo(...): unexpected values: " + values); Fail(16); } r += (float)Randomizer(); tr += (ushort)Randomizer(); ret.Randomize(); return ret; }
public Valuesa Foo(float v, ref double r, uint t, ref uint tr) { Valuesa ret = new Valuesa(); String values = v.ToString() + " " + r.ToString() + " " + t.ToString() + " " + tr.ToString() + " " + "."; if (values != "4.005809E+18 -6.58392565490175E+18 23065482" + "88 2306548288 .") { Console.WriteLine("Valuesa Foo(...): unexpected values: " + values); Fail(17); } r += (double)Randomizer(); tr += (uint)Randomizer(); ret.Randomize(); return ret; }
public void RunTests() { String values; Struct1 s1 = new Struct1(); Struct2 s2 = new Struct2(); Struct3 s3 = new Struct3(); Struct4 s4 = new Struct4(); Struct5 s5 = new Struct5(); Struct8 s8 = new Struct8(); Valuesa v = new Valuesa(); float f; double d; Object o; String s; Enumacek e; s1.Randomize(); s2.Randomize(); s3.Randomize(); s4.Randomize(); s5.Randomize(); s8.Randomize(); v.Randomize(); f = (float)Randomizer(); d = (float)Randomizer(); o = this; s = Randomizer().ToString(); e = Enumacek.Hali; Object s1_ = (Object)s1; Object s2_ = (Object)s2; Object s3_ = (Object)s3; Object s4_ = (Object)s4; Object s5_ = (Object)s5; Object s8_ = (Object)s8; Object v_ = (Object)v; Object f_ = (Object)f; Object d_ = (Object)d; Object o_ = (Object)o; Object s_ = (Object)s; Object e_ = (Object)e; Object p1_ = (sbyte)Randomizer(); Object p2_ = (byte)Randomizer(); Object p3_ = (short)Randomizer(); Object p4_ = (ushort)Randomizer(); Object p5_ = (int)Randomizer(); Object p6_ = (uint)Randomizer(); Object p7_ = (long)Randomizer(); Object p8_ = (ulong)Randomizer(); // set all fields GetType().InvokeMember("_s1", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s1_ }, null, null, null); GetType().InvokeMember("_s2", BindingFlags.Static | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s2_ }, null, null, null); GetType().InvokeMember("_s3", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s3_ }, null, null, null); GetType().InvokeMember("_s4", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s4_ }, null, null, null); GetType().InvokeMember("_s5", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s5_ }, null, null, null); GetType().InvokeMember("_s8", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s8_ }, null, null, null); GetType().InvokeMember("_v", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { v_ }, null, null, null); GetType().InvokeMember("_f", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { f_ }, null, null, null); GetType().InvokeMember("_d", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { d_ }, null, null, null); GetType().InvokeMember("_o", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { o_ }, null, null, null); GetType().InvokeMember("_s", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s_ }, null, null, null); GetType().InvokeMember("_e", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { e_ }, null, null, null); GetType().InvokeMember("_p1", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p1_ }, null, null, null); GetType().InvokeMember("_p2", BindingFlags.Static | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p2_ }, null, null, null); GetType().InvokeMember("_p3", BindingFlags.Static | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p3_ }, null, null, null); GetType().InvokeMember("_p4", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p4_ }, null, null, null); GetType().InvokeMember("_p5", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p5_ }, null, null, null); GetType().InvokeMember("_p6", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p6_ }, null, null, null); GetType().InvokeMember("_p7", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p7_ }, null, null, null); GetType().InvokeMember("_p8", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p8_ }, null, null, null); // verify the values of all fields values = _s1.ToString() + " " + _s2.ToString() + " " + _s3.ToString() + " " + _s4.ToString() + " " + _s5.ToString() + " " + _s8.ToString() + " " + _v.ToString() + " " + _f.ToString() + " " + _d.ToString() + " " + _o.ToString() + " " + _s.ToString() + " " + _e.ToString() + " " + _p1.ToString() + " " + _p2.ToString() + " " + _p3.ToString() + " " + _p4.ToString() + " " + _p5.ToString() + " " + _p6.ToString() + " " + _p7.ToString() + " " + _p8.ToString() + " " + "."; if (values != "9 104 225 80 57 184 17 160 105 8 65 240 153 88 113 64" + " 201 168 161 144 249 248 209 224 -23767 606228808 2874968872843236865 -901615977" + "9942285264 360942425 4248 49 -5.193024E+18 -6.58392565490175E+18 MainApp 2212973" + "731230676456 Hali 97 208 -9799 49464 1739539345 3300757792 -6517938239175606295 " + "1703311890815005320 .") { Console.WriteLine("SetFields: unexpected values: " + values); Fail(101); } Console.WriteLine("Field setters succeeded"); // invoke the methods p1_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p1_ }, null, null, null); p2_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p2_ }, null, null, null); p3_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p3_ }, null, null, null); p4_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p4_ }, null, null, null); p5_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p5_ }, null, null, null); p6_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p6_ }, null, null, null); p7_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p7_ }, null, null, null); p8_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p8_ }, null, null, null); // verify the values of all fields values = p1_.ToString() + " " + p2_.ToString() + " " + p3_.ToString() + " " + p4_.ToString() + " " + p5_.ToString() + " " + p6_.ToString() + " " + p7_.ToString() + " " + p8_.ToString() + " " + "."; if (values != "-62 160 -19598 33392 -81588860" + "6 2306548288 5410867595358339026 3406623781630010640 .") { Console.WriteLine("Locals after primitive Invoke: unexpected values: " + values); Fail(102); } s1_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { s2_, s3_, p1_, p1_ }, null, null, null); s2_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { s4_, s3_, p3_, p3_ }, null, null, null); s3_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { s4_, s5_, p5_, p5_ }, null, null, null); s4_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { s8_, s5_, p7_, p7_ }, null, null, null); s5_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { s8_, v_, p2_, p2_ }, null, null, null); s8_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { f_, v_, p4_, p4_ }, null, null, null); v_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { f_, d_, p6_, p6_ }, null, null, null); f_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { s1_, d_, p8_, p8_ }, null, null, null); d_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { s2_, s1_, s_, s_ }, null, null, null); // verify the values of all fields values = _s1.ToString() + " " + _s2.ToString() + " " + _s3.ToString() + " " + _s4.ToString() + " " + _s5.ToString() + " " + _s8.ToString() + " " + _v.ToString() + " " + _f.ToString() + " " + _d.ToString() + " " + _o.ToString() + " " + _s.ToString() + " " + _e.ToString() + " " + _p1.ToString() + " " + _p2.ToString() + " " + _p3.ToString() + " " + _p4.ToString() + " " + _p5.ToString() + " " + _p6.ToString() + " " + _p7.ToString() + " " + _p8.ToString() + " " + "."; if (values != "9 104 225 80 57 184 17 160 105 8 65 240 " + "153 88 113 64 201 168 161 144 249 248 209 224 -23767 606228808 28749688728432368" + "65 -9016159779942285264 360942425 4248 49 -5.193024E+18 -6.58392565490175E+18 Ma" + "inApp 2212973731230676456 Hali 97 208 -9799 49464 1739539345 3300757792 -6517938" + "239175606295 1703311890815005320 .") { Console.WriteLine("Fields after Invoke: unexpected values: " + values); Fail(103); } // verify the values of all locals values = s1_.ToString() + " " + s2_.ToString() + " " + s3_.ToString() + " " + s4_.ToString() + " " + s5_.ToString() + " " + s8_.ToString() + " " + v_.ToString() + " " + f_.ToString() + " " + d_.ToString() + " " + o_.ToString() + " " + s_.ToString() + " " + e_.ToString() + " " + p1_.ToString() + " " + p2_.ToString() + " " + p3_.ToString() + " " + p4_.ToString() + " " + p5_.ToString() + " " + p6_.ToString() + " " + p7_.ToString() + " " + p8_.ToString() + " " + "."; if (values != "226 161 153 217 24 177 105 8 65 240 248 " + "209 224 41 72 89 152 49 128 137 232 97 208 145 9760 68383465 -100628058569588952" + "8 -1283321389773510207 -27688336 8985 216 -7.769602E+18 -3.84749538525879E+18 Ma" + "inApp 2212973731230676456 Hali -102 153 -29822 14240 1493680594 2427897976 59408" + "3122152577906 15205575963204995536 .") { Console.WriteLine("Locals after Invoke: unexpected values: " + values); Fail(104); } Console.WriteLine("Method invokes succeeded"); // get all fields s1_ = GetType().InvokeMember("_s1", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); s2_ = GetType().InvokeMember("_s2", BindingFlags.Static | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); s3_ = GetType().InvokeMember("_s3", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); s4_ = GetType().InvokeMember("_s4", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); s5_ = GetType().InvokeMember("_s5", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); s8_ = GetType().InvokeMember("_s8", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); v_ = GetType().InvokeMember("_v", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); f_ = GetType().InvokeMember("_f", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); d_ = GetType().InvokeMember("_d", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); o_ = GetType().InvokeMember("_o", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); s_ = GetType().InvokeMember("_s", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); e_ = GetType().InvokeMember("_e", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p1_ = GetType().InvokeMember("_p1", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p2_ = GetType().InvokeMember("_p2", BindingFlags.Static | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p3_ = GetType().InvokeMember("_p3", BindingFlags.Static | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p4_ = GetType().InvokeMember("_p4", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p5_ = GetType().InvokeMember("_p5", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p6_ = GetType().InvokeMember("_p6", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p7_ = GetType().InvokeMember("_p7", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p8_ = GetType().InvokeMember("_p8", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); // verify the values of all locals values = s1_.ToString() + " " + s2_.ToString() + " " + s3_.ToString() + " " + s4_.ToString() + " " + s5_.ToString() + " " + s8_.ToString() + " " + v_.ToString() + " " + f_.ToString() + " " + d_.ToString() + " " + o_.ToString() + " " + s_.ToString() + " " + e_.ToString() + " " + p1_.ToString() + " " + p2_.ToString() + " " + p3_.ToString() + " " + p4_.ToString() + " " + p5_.ToString() + " " + p6_.ToString() + " " + p7_.ToString() + " " + p8_.ToString() + " " + "."; if (values != "9 104 225 80 57 184 17 160 105 8 65 240 153 88 113" + " 64 201 168 161 144 249 248 209 224 -23767 606228808 2874968872843236865 -901615" + "9779942285264 360942425 4248 49 -5.193024E+18 -6.58392565490175E+18 MainApp 2212" + "973731230676456 Hali 97 208 -9799 49464 1739539345 3300757792 -65179382391756062" + "95 1703311890815005320 .") { Console.WriteLine("GetFields: unexpected values: " + values); Fail(105); } Console.WriteLine("Field getters succeeded"); // invoke the method with complex signature GetType().InvokeMember("Foo", BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod, null, null, new Object[] { this, "O", "S", (float)Randomizer(), (double)Randomizer(), (float)Randomizer(), (double)Randomizer(), (float)Randomizer(), (double)Randomizer(), (long)Randomizer(), (long)Randomizer(), (long)Randomizer(), (long)Randomizer(), (long)Randomizer(), (long)Randomizer(), (sbyte)Randomizer(), (byte)Randomizer(), (short)Randomizer(), (ushort)Randomizer(), (int)Randomizer(), (uint)Randomizer(), (long)Randomizer(), (ulong)Randomizer(), (float)Randomizer(), (double)Randomizer(), (float)Randomizer(), (double)Randomizer(), (float)Randomizer(), (double)Randomizer() }, null, null, null); Console.WriteLine("Complex invoke succeeded"); // invoke the constructor with complex signature GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance, null, null, new Object[] { this, s1_, s2_, s3_, s4_, s5_, s8_, v_, f_, d_, o_, s_, e_, }, null, null, null); Console.WriteLine("Constructor invoke succeeded"); }
public void RunTests() { String values; Struct1 s1 = new Struct1(); Struct2 s2 = new Struct2(); Struct3 s3 = new Struct3(); Struct4 s4 = new Struct4(); Struct5 s5 = new Struct5(); Struct8 s8 = new Struct8(); Valuesa v = new Valuesa(); float f; double d; Object o; String s; Enumacek e; s1.Randomize(); s2.Randomize(); s3.Randomize(); s4.Randomize(); s5.Randomize(); s8.Randomize(); v.Randomize(); f = (float)Randomizer(); d = (float)Randomizer(); o = this; s = Randomizer().ToString(); e = Enumacek.Hali; Object s1_ = (Object)s1; Object s2_ = (Object)s2; Object s3_ = (Object)s3; Object s4_ = (Object)s4; Object s5_ = (Object)s5; Object s8_ = (Object)s8; Object v_ = (Object)v; Object f_ = (Object)f; Object d_ = (Object)d; Object o_ = (Object)o; Object s_ = (Object)s; Object e_ = (Object)e; Object p1_ = (sbyte)Randomizer(); Object p2_ = (byte)Randomizer(); Object p3_ = (short)Randomizer(); Object p4_ = (ushort)Randomizer(); Object p5_ = (int)Randomizer(); Object p6_ = (uint)Randomizer(); Object p7_ = (long)Randomizer(); Object p8_ = (ulong)Randomizer(); // set all fields GetType().InvokeMember("_s1", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s1_ }, null, null, null); GetType().InvokeMember("_s2", BindingFlags.Static | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s2_ }, null, null, null); GetType().InvokeMember("_s3", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s3_ }, null, null, null); GetType().InvokeMember("_s4", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s4_ }, null, null, null); GetType().InvokeMember("_s5", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s5_ }, null, null, null); GetType().InvokeMember("_s8", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s8_ }, null, null, null); GetType().InvokeMember("_v", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { v_ }, null, null, null); GetType().InvokeMember("_f", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { f_ }, null, null, null); GetType().InvokeMember("_d", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { d_ }, null, null, null); GetType().InvokeMember("_o", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { o_ }, null, null, null); GetType().InvokeMember("_s", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { s_ }, null, null, null); GetType().InvokeMember("_e", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { e_ }, null, null, null); GetType().InvokeMember("_p1", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p1_ }, null, null, null); GetType().InvokeMember("_p2", BindingFlags.Static | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p2_ }, null, null, null); GetType().InvokeMember("_p3", BindingFlags.Static | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p3_ }, null, null, null); GetType().InvokeMember("_p4", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p4_ }, null, null, null); GetType().InvokeMember("_p5", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p5_ }, null, null, null); GetType().InvokeMember("_p6", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p6_ }, null, null, null); GetType().InvokeMember("_p7", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p7_ }, null, null, null); GetType().InvokeMember("_p8", BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetField, null, this, new Object[] { p8_ }, null, null, null); // verify the values of all fields values = _s1.ToString() + " " + _s2.ToString() + " " + _s3.ToString() + " " + _s4.ToString() + " " + _s5.ToString() + " " + _s8.ToString() + " " + _v.ToString() + " " + _f.ToString() + " " + _d.ToString() + " " + _o.ToString() + " " + _s.ToString() + " " + _e.ToString() + " " + _p1.ToString() + " " + _p2.ToString() + " " + _p3.ToString() + " " + _p4.ToString() + " " + _p5.ToString() + " " + _p6.ToString() + " " + _p7.ToString() + " " + _p8.ToString() + " " + "."; if (values != "9 104 225 80 57 184 17 160 105 8 65 240 153 88 113 64" + " 201 168 161 144 249 248 209 224 -23767 606228808 2874968872843236865 -901615977" + "9942285264 360942425 4248 49 -5.193024E+18 -6.58392565490175E+18 MainApp 2212973" + "731230676456 Hali 97 208 -9799 49464 1739539345 3300757792 -6517938239175606295 " + "1703311890815005320 .") { Console.WriteLine("SetFields: unexpected values: " + values); Fail(101); } Console.WriteLine("Field setters succeeded"); // invoke the methods p1_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p1_ }, null, null, null); p2_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p2_ }, null, null, null); p3_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p3_ }, null, null, null); p4_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p4_ }, null, null, null); p5_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p5_ }, null, null, null); p6_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p6_ }, null, null, null); p7_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p7_ }, null, null, null); p8_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, new Object[] { p8_ }, null, null, null); // verify the values of all fields values = p1_.ToString() + " " + p2_.ToString() + " " + p3_.ToString() + " " + p4_.ToString() + " " + p5_.ToString() + " " + p6_.ToString() + " " + p7_.ToString() + " " + p8_.ToString() + " " + "."; if (values != "-62 160 -19598 33392 -81588860" + "6 2306548288 5410867595358339026 3406623781630010640 .") { Console.WriteLine("Locals after primitive Invoke: unexpected values: " + values); Fail(102); } Object[] args; args = new Object[] { s2_, s3_, p1_, p1_ }; s1_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, args, null, null, null); s3_ = args[1]; p1_ = args[3]; args = new Object[] { s4_, s3_, p3_, p3_ }; s2_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, args, null, null, null); s4_ = args[0]; p3_ = args[3]; args = new Object[] { s4_, s5_, p5_, p5_ }; s3_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, args, null, null, null); s5_ = args[1]; p5_ = args[3]; args = new Object[] { s8_, s5_, p7_, p7_ }; s4_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, args, null, null, null); s8_ = args[0]; p7_ = args[3]; args = new Object[] { s8_, v_, p2_, p2_ }; s5_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, args, null, null, null); v_ = args[1]; p2_ = args[3]; args = new Object[] { f_, v_, p4_, p4_ }; s8_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, args, null, null, null); f_ = args[0]; p4_ = args[3]; args = new Object[] { f_, d_, p6_, p6_ }; v_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, args, null, null, null); d_ = args[1]; p6_ = args[3]; args = new Object[] { s1_, d_, p8_, p8_ }; f_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, args, null, null, null); s1_ = args[0]; p8_ = args[3]; args = new Object[] { s2_, s1_, s_, s_ }; d_ = GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, this, args, null, null, null); s2_ = args[0]; // verify the values of all fields values = _s1.ToString() + " " + _s2.ToString() + " " + _s3.ToString() + " " + _s4.ToString() + " " + _s5.ToString() + " " + _s8.ToString() + " " + _v.ToString() + " " + _f.ToString() + " " + _d.ToString() + " " + _o.ToString() + " " + _s.ToString() + " " + _e.ToString() + " " + _p1.ToString() + " " + _p2.ToString() + " " + _p3.ToString() + " " + _p4.ToString() + " " + _p5.ToString() + " " + _p6.ToString() + " " + _p7.ToString() + " " + _p8.ToString() + " " + "."; if (values != "9 104 225 80 57 184 17 160 105 8 65 240 " + "153 88 113 64 201 168 161 144 249 248 209 224 -23767 606228808 28749688728432368" + "65 -9016159779942285264 360942425 4248 49 -5.193024E+18 -6.58392565490175E+18 Ma" + "inApp 2212973731230676456 Hali 97 208 -9799 49464 1739539345 3300757792 -6517938" + "239175606295 1703311890815005320 .") { Console.WriteLine("Fields after Invoke: unexpected values: " + values); Fail(103); } // verify the values of all locals values = s1_.ToString() + " " + s2_.ToString() + " " + s3_.ToString() + " " + s4_.ToString() + " " + s5_.ToString() + " " + s8_.ToString() + " " + v_.ToString() + " " + f_.ToString() + " " + d_.ToString() + " " + o_.ToString() + " " + s_.ToString() + " " + e_.ToString() + " " + p1_.ToString() + " " + p2_.ToString() + " " + p3_.ToString() + " " + p4_.ToString() + " " + p5_.ToString() + " " + p6_.ToString() + " " + p7_.ToString() + " " + p8_.ToString() + " " + "."; if (values != "226 161 153 217 24 177 105 8 65 240 248 " + "209 224 41 72 89 152 49 128 137 232 97 208 145 9760 68383465 -100628058569588952" + "8 -1283321389773510207 -27688336 8985 216 -7.769602E+18 -3.84749538525879E+18 Ma" + "inApp 2212973731230676456 Hali -102 153 -29822 14240 1493680594 2427897976 59408" + "3122152577906 15205575963204995536 .") { Console.WriteLine("Locals after Invoke: unexpected values: " + values); Fail(104); } Console.WriteLine("Method invokes succeeded"); // get all fields s1_ = GetType().InvokeMember("_s1", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); s2_ = GetType().InvokeMember("_s2", BindingFlags.Static | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); s3_ = GetType().InvokeMember("_s3", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); s4_ = GetType().InvokeMember("_s4", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); s5_ = GetType().InvokeMember("_s5", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); s8_ = GetType().InvokeMember("_s8", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); v_ = GetType().InvokeMember("_v", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); f_ = GetType().InvokeMember("_f", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); d_ = GetType().InvokeMember("_d", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); o_ = GetType().InvokeMember("_o", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); s_ = GetType().InvokeMember("_s", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); e_ = GetType().InvokeMember("_e", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p1_ = GetType().InvokeMember("_p1", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p2_ = GetType().InvokeMember("_p2", BindingFlags.Static | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p3_ = GetType().InvokeMember("_p3", BindingFlags.Static | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p4_ = GetType().InvokeMember("_p4", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p5_ = GetType().InvokeMember("_p5", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p6_ = GetType().InvokeMember("_p6", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p7_ = GetType().InvokeMember("_p7", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); p8_ = GetType().InvokeMember("_p8", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField, null, this, null, null, null, null); // verify the values of all locals values = s1_.ToString() + " " + s2_.ToString() + " " + s3_.ToString() + " " + s4_.ToString() + " " + s5_.ToString() + " " + s8_.ToString() + " " + v_.ToString() + " " + f_.ToString() + " " + d_.ToString() + " " + o_.ToString() + " " + s_.ToString() + " " + e_.ToString() + " " + p1_.ToString() + " " + p2_.ToString() + " " + p3_.ToString() + " " + p4_.ToString() + " " + p5_.ToString() + " " + p6_.ToString() + " " + p7_.ToString() + " " + p8_.ToString() + " " + "."; if (values != "9 104 225 80 57 184 17 160 105 8 65 240 153 88 113" + " 64 201 168 161 144 249 248 209 224 -23767 606228808 2874968872843236865 -901615" + "9779942285264 360942425 4248 49 -5.193024E+18 -6.58392565490175E+18 MainApp 2212" + "973731230676456 Hali 97 208 -9799 49464 1739539345 3300757792 -65179382391756062" + "95 1703311890815005320 .") { Console.WriteLine("GetFields: unexpected values: " + values); Fail(105); } Console.WriteLine("Field getters succeeded"); // invoke the method with complex signature GetType().InvokeMember("Foo", BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod, null, null, new Object[] { this, "O", "S", (float)Randomizer(), (double)Randomizer(), (float)Randomizer(), (double)Randomizer(), (float)Randomizer(), (double)Randomizer(), (long)Randomizer(), (long)Randomizer(), (long)Randomizer(), (long)Randomizer(), (long)Randomizer(), (long)Randomizer(), (sbyte)Randomizer(), (byte)Randomizer(), (short)Randomizer(), (ushort)Randomizer(), (int)Randomizer(), (uint)Randomizer(), (long)Randomizer(), (ulong)Randomizer(), (float)Randomizer(), (double)Randomizer(), (float)Randomizer(), (double)Randomizer(), (float)Randomizer(), (double)Randomizer() }, null, null, null); Console.WriteLine("Complex invoke succeeded"); // invoke the constructor with complex signature GetType().InvokeMember("Foo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance, null, null, new Object[] { this, s1_, s2_, s3_, s4_, s5_, s8_, v_, f_, d_, o_, s_, e_, }, null, null, null); Console.WriteLine("Constructor invoke succeeded"); }
static public void Main() { int[,] ia = { { 1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12} }; if (ia[2,3] != 12) { Console.WriteLine("Unexpected ia[2,3]: " + ia[2,3]); Environment.Exit(2); } ia[1,2] = 100; Check(__makeref(ia[1,2]), 100); try { ia[3,2] = 0; Console.WriteLine("IndexOutOfRangeException expected"); Environment.Exit(2); } catch (IndexOutOfRangeException) { } ia = null; try { ia[3,2] = 0; Console.WriteLine("NullReferenceException expected"); Environment.Exit(2); } catch (NullReferenceException) { } byte[,,] ba = { { { 1, 2}, {3, 4 } }, { {5,6}, {7, 8} } }; if (ba[1,0,1] != 6) { Console.WriteLine("Unexpected ba[1,0,1]: " + ba[1,0,1]); Environment.Exit(2); } ba[1,0,1] = 101; Check(__makeref(ba[1,0,1]), (byte)101); short[,,] sa = { { { -1111, -2222}, {-3333, -4444 } }, { {-5555,-6666}, {-7777, -8888} } }; if (sa[1,1,1] != -8888) { Console.WriteLine("Unexpected sa[1,1,1]: " + sa[1,1,1]); Environment.Exit(3); } sa[0,1,0] = -1002; Check(__makeref(sa[0,1,0]), (short)-1002); long[,] la = { { 111111111111L, 222222222222L}, {333333333333L, 444444444444L } }; if (la[1,1] != 444444444444L) { Console.WriteLine("Unexpected la[1,1]: " + la[1,1]); Environment.Exit(4); } la[1,0] = 444444444444L; Check(__makeref(la[1,0]), (long)444444444444L); float[,] fa = { { 1.0F, 2.0F, 3.0F}, {4.0F, 5.0F, 6.0F}, {4.0F, 5.0F, 6.0F} }; if (fa[1,2] != 6.0F) { Console.WriteLine("Unexpected fa[1,2]: " + fa[1,2]); Environment.Exit(5); } fa[2,1] = Single.PositiveInfinity; Check(__makeref(fa[2,1]), Single.PositiveInfinity); double[,] da = { { 1.0, 2.0, 3.0, 4.0}, {5.0, 6.0, 7.0, 8.0}, {9.0, 10.0, 11.0, 12.0} }; if (da[2,2] != 11.0) { Console.WriteLine("Unexpected da[2,2]: " + da[2,2]); Environment.Exit(6); } da[2,3] = 1234.5; Check(__makeref(da[2,3]), 1234.5); String[,,,,,,,,,] stra = new String[2,2,2,2,2,2,2,2,2,2]; stra[0,1,0,1,0,1,0,1,0,1] = "Hello"; if (stra[0,1,0,1,0,1,0,1,0,1] != "Hello") { Console.WriteLine("Unexpected stra[...]: " + stra[0,1,0,1,0,1,0,1,0,1]); Environment.Exit(7); } Check(__makeref(stra[0,1,0,1,0,1,0,1,0,1]), "Hello"); try { Object[,,,,,,,,,] oba = stra; oba[1,0,1,0,1,0,1,0,1,0] = null; oba[1,0,1,0,1,0,1,0,1,0] = new Object(); Console.WriteLine("ArrayTypeMismatchException expected"); Environment.Exit(8); } catch (ArrayTypeMismatchException) { } Struct2 s2; Struct2[,] s2a = new Struct2[5,6]; s2.x = -1234; s2a[2,3] = s2; s2 = s2a[2,3]; if (s2.x != -1234) { Console.WriteLine("Unexpected s2a[2,3]: " + s2a[2,3].x); Environment.Exit(9); } Check(__makeref(s2a[2,3]), s2); Valuesa v; v.a = 11111111; v.b = 1111111111111111; v.c = new Object(); v.d = "Hello"; v.e = 2222222222222222; Valuesa[,,,] va = new Valuesa[1,2,3,4]; va[0,1,2,3] = v; v = va[0,1,2,3]; if (v.a != 11111111 || v.b != 1111111111111111 || v.d != "Hello" || v.e != 2222222222222222) { Console.WriteLine("Unexpected va[...]"); Environment.Exit(10); } Check(__makeref(va[0,1,2,3]), v); Console.WriteLine("Passed"); }