Exemple #1
0
	static int Main ()
	{
		var s = new S1 ();
		if (s.Value != 17)
			return 1;

		var s2 = new S2 ();
		if (s2.Value != 23)
			return 2;

		var s3 = new S3 ();
		if (s3.Value != 5)
			return 3;

		var s4 = new S4 (5);
		if (s4.Value != 11)
			return 4;

		var s5 = new S5 (2);
		if (s5.Value != 9)
			return 5;

		Console.WriteLine ("ok");
		return 0;
	}
Exemple #2
0
 public static bool ValidateS5(S5 str1, S5 str2, string methodName)
 {
     if (str1.s4.age != str2.s4.age || str1.s4.name != str2.s4.name)
     {
         Console.WriteLine("\tFAILED! " + methodName + "did not recieve result as expected.");
         Console.WriteLine("\tThe Actual s4 field is...");
         Console.WriteLine("\t{0}.s4.age = {1}", str1.ToString(), str1.s4.age);
         Console.WriteLine("\t{0}.s4.name = {1}", str1.ToString(), str1.s4.name);
         Console.WriteLine("\tThe Expected s4 field is...");
         Console.WriteLine("\t{0}.s4.age = {1}", str2.ToString(), str2.s4.age);
         Console.WriteLine("\t{0}.s4.name = {1}", str2.ToString(), str2.s4.name);
         return false;
     }
     if (str1.ef != str2.ef)
     {
         Console.WriteLine("\tFAILED! " + methodName + "did not recieve result as expected.");
         Console.WriteLine("\tThe Actual ef field is...");
         Console.WriteLine("\t{0}.ef = {1}", str1.ToString(), str1.ef);
         Console.WriteLine("\tThe Expected s4 field is...");
         Console.WriteLine("\t{0}.ef = {1}", str2.ToString(), str2.ef);
         return false;
     }
     Console.WriteLine("\tPASSED!");
     return true;
 }
Exemple #3
0
    public static S5 NewS5(int age, string name,Enum1 ef)
    {
        S4 s4 = new S4();
        s4.age = age;
        s4.name = name;

        S5 s5 = new S5();
        s5.s4 = s4;
        s5.ef = ef;

        return s5;
    }
Exemple #4
0
 public static void PrintS5(S5 str1, string name)
 {
     Console.WriteLine("\t{0}.s4.age = {1}", str1.s4.age);
     Console.WriteLine("\t{0}.s4.name = {1}", str1.s4.name);
     Console.WriteLine("\t{0}.ef = {1}", str1.ef.ToString());
 }
 static extern bool MarshalStructAsParam_AsSeqByRef8(ref S5 str1);
 static extern bool MarshalStructAsParam_AsSeqByRefOut8(out S5 str1);
 public static extern S5 InvokeCallback5R(MyCallback5 callback, S5 s);
 static extern bool MarshalStructAsParam_AsSeqByVal8(S5 str1);
Exemple #9
0
 public static extern S5 InvokeCallback5R(MyCallback5 callback, S5 s);
 public static extern void InvokeCallback5(MyCallback5 callback, S5 s);
Exemple #11
0
 public static extern void InvokeCallback5(MyCallback5 callback, S5 s);
/* These tests are not working on non Windows CoreCLR.  Enable this when https://github.com/dotnet/runtime/issues/4680 is resolved.
 *
 *      [DllImport("jitstructtests_lib")]
 *      public static extern S28 InvokeCallback28R(MyCallback28 callback, S28 s);
 *
 *      [DllImport("jitstructtests_lib")]
 *      public static extern S29 InvokeCallback29R(MyCallback29 callback, S29 s);
 * Enable this when https://github.com/dotnet/runtime/issues/4680 is resolved. */
        static public int Main1()
        {
            Program3 p  = new Program3();
            S1       s1 = new S1();

            s1.x = 1;
            s1.y = 2;
            s1.z = 3;
            s1.w = 4;

            try
            {
                InvokeCallback1((par) =>
                {
                    Console.WriteLine("S1: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s1);

                S2 s2;
                s2.x = 1;
                s2.y = 2;
                s2.z = 3;
                InvokeCallback2((par) =>
                {
                    Console.WriteLine("S2: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s2);

                S3 s3;
                s3.x = 1;
                s3.y = 2;
                s3.z = 3;
                InvokeCallback3((par) =>
                {
                    Console.WriteLine("S3: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s3);

                S4 s4;
                s4.x = 1;
                s4.y = 2;
                InvokeCallback4((par) =>
                {
                    Console.WriteLine("S4: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s4);

                S5 s5;
                s5.x = 1;
                s5.y = 2;
                InvokeCallback5((par) =>
                {
                    Console.WriteLine("S5: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s5);

                S6 s6;
                s6.x = 1;
                s6.y = 2;
                s6.z = 3;
                s6.w = 4;
                InvokeCallback6((par) =>
                {
                    Console.WriteLine("S6: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s6);

                S7 s7;
                s7.x = 1;
                s7.y = 2;
                s7.z = 3;
                InvokeCallback7((par) =>
                {
                    Console.WriteLine("S7: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s7);

                S8 s8;
                s8.x = 1;
                s8.y = 2;
                InvokeCallback8((par) =>
                {
                    Console.WriteLine("S8: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s8);

                S9 s9;
                s9.x = 1;
                s9.y = 2;
                s9.z = 3;
                s9.w = 4;
                InvokeCallback9((par) =>
                {
                    Console.WriteLine("S9: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s9);

                S10 s10;
                s10.a = 1;
                s10.b = 2;
                s10.c = 3;
                s10.d = 4;
                s10.e = 5;
                s10.f = 6;
                s10.g = 7;
                s10.h = 8;
                InvokeCallback10((par) =>
                {
                    Console.WriteLine("S10: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", par.a, par.b, par.c, par.d, par.e, par.f, par.g, par.h);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 ||
                        par.e != 5 || par.f != 6 || par.g != 7 || par.h != 8)
                    {
                        throw new System.Exception();
                    }
                }, s10);

                S11 s11;
                s11.a = 1;
                s11.b = 2;
                s11.c = 3;
                s11.d = 4;
                s11.e = 5;
                InvokeCallback11((par) =>
                {
                    Console.WriteLine("S11: {0}, {1}, {2}, {3}, {4}", par.a, par.b, par.c, par.d, par.e);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 || par.e != 5)
                    {
                        throw new System.Exception();
                    }
                }, s11);

                S12 s12;
                s12.a = 1;
                s12.b = 2;
                s12.c = 3;
                s12.d = 4;
                s12.e = 5;
                s12.f = 6;
                s12.g = 7;
                s12.h = 8;
                s12.i = 9;
                InvokeCallback12((par) =>
                {
                    Console.WriteLine("S12: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", par.a, par.b, par.c, par.d, par.e, par.f, par.g, par.h, par.i);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 ||
                        par.e != 5 || par.f != 6 || par.g != 7 || par.h != 8 || par.i != 9)
                    {
                        throw new System.Exception();
                    }
                }, s12);

                S13 s13;
                s13.hasValue = 1;
                s13.x        = 2;
                InvokeCallback13((par) =>
                {
                    Console.WriteLine("S13: {0}, {1}", par.hasValue, par.x);
                    if (par.hasValue != 1 || par.x != 2)
                    {
                        throw new System.Exception();
                    }
                }, s13);

                S14 s14;
                s14.x = 1;
                s14.y = 2;
                InvokeCallback14((par) =>
                {
                    Console.WriteLine("S14: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s14);

                S15 s15;
                s15.a = 1;
                s15.b = 2;
                s15.c = 3;
                s15.d = 4;
                s15.e = 5;
                s15.f = 6;
                s15.g = 7;
                s15.h = 8;
                s15.i = 9;
                InvokeCallback15((par) =>
                {
                    Console.WriteLine("S15: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", par.a, par.b, par.c, par.d, par.e, par.f, par.g, par.h, par.i);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 ||
                        par.e != 5 || par.f != 6 || par.g != 7 || par.h != 8 || par.i != 9)
                    {
                        throw new System.Exception();
                    }
                }, s15);

                S16 s16;
                s16.x = 1;
                s16.y = 2;
                InvokeCallback16((par) =>
                {
                    Console.WriteLine("S16: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s16);

                S17 s17;
                s17.x = 1;
                s17.y = 2;
                InvokeCallback17((par) =>
                {
                    Console.WriteLine("S17: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s17);

                S18 s18;
                s18.x = 1;
                s18.y = 2;
                s18.z = 3;
                InvokeCallback18((par) =>
                {
                    Console.WriteLine("S18: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s18);

                S19 s19;
                s19.x = 1;
                s19.y = 2;
                s19.z = 3;
                s19.w = 4;
                InvokeCallback19((par) =>
                {
                    Console.WriteLine("S19: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s19);

                S20 s20;
                s20.x = 1;
                s20.y = 2;
                s20.z = 3;
                s20.w = 4;
                InvokeCallback20((par) =>
                {
                    Console.WriteLine("S20: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s20);

                /* These tests are not working on non Windows CoreCLR.  Enable this when https://github.com/dotnet/runtime/issues/4680 is resolved.
                 * TestClass testClass = new TestClass();
                 * S28 s28;
                 * s28.x = null;
                 * s28.y = 1;
                 *
                 * InvokeCallback28((par) => {
                 *  Console.WriteLine("S28: {0}, {1}", par.x == null ? "Null" : "Not null", par.y);
                 *  if (par.x != null || par.y != 1)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s28);
                 *
                 * s28.x = testClass;
                 * s28.y = 5;
                 *
                 * InvokeCallback28((par) => {
                 *  Console.WriteLine("S28: {0}, {1}", par.x == null ? "Null" : "Not null", par.y);
                 *  if (par.x != testClass || par.y != 5)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s28);
                 *
                 * S29 s29;
                 * s29.x = 1;
                 * s29.y = null;
                 *
                 * InvokeCallback29((par) => {
                 *  Console.WriteLine("S29: {0}, {1}", par.x, par.y == null ? "Null" : "Not null");
                 *  if (par.x != 1 || par.y != null)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s29);
                 *
                 * s29.x = 5;
                 * s29.y = testClass;
                 *
                 * InvokeCallback29((par) => {
                 *  Console.WriteLine("S29: {0}, {1}", par.x, par.y == null ? "Null" : "Not null");
                 *  if (par.x != 5 || par.y != testClass)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s29);
                 * Enable this when https://github.com/dotnet/runtime/issues/4680 is resolved. */
                S30 s30;
                s30.x = 1;
                s30.y = 2;

                S30 s30_2;
                s30_2.x = 3;
                s30_2.y = 4;

                S30 s30_3;
                s30_3.x = 5;
                s30_3.y = 6;

                // Program p = new Program();
                InvokeCallback30(p.Test30, s30, s30_2, s30_3);
                S1 s1r = InvokeCallback1R((par) =>
                {
                    Console.WriteLine("S1: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s1);
                Console.WriteLine("S1R: {0}, {1}, {2}, {3}", s1r.x, s1r.y, s1r.z, s1r.w);
                if (s1r.x != 1 || s1r.y != 2 || s1r.z != 3 || s1r.w != 4)
                {
                    throw new System.Exception();
                }

                S2 s2r = InvokeCallback2R((par) =>
                {
                    Console.WriteLine("S2: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s2);
                Console.WriteLine("S2R: {0}, {1}, {2}", s2r.x, s2r.y, s2r.z);
                if (s2r.x != 1 || s2r.y != 2 || s2r.z != 3)
                {
                    throw new System.Exception();
                }

                S3 s3r = InvokeCallback3R((par) =>
                {
                    Console.WriteLine("S3: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s3);
                Console.WriteLine("S3R: {0}, {1}, {2}", s3r.x, s3r.y, s3r.z);
                if (s3r.x != 1 || s3r.y != 2 || s3r.z != 3)
                {
                    throw new System.Exception();
                }

                S4 s4r = InvokeCallback4R((par) =>
                {
                    Console.WriteLine("S4: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s4);
                Console.WriteLine("S4R: {0}, {1}", s4r.x, s4r.y);
                if (s4r.x != 1 || s4r.y != 2)
                {
                    throw new System.Exception();
                }

                S5 s5r = InvokeCallback5R((par) =>
                {
                    Console.WriteLine("S5: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s5);
                Console.WriteLine("S5R: {0}, {1}", s5r.x, s5r.y);
                if (s5r.x != 1 || s5r.y != 2)
                {
                    throw new System.Exception();
                }

                S6 s6r = InvokeCallback6R((par) =>
                {
                    Console.WriteLine("S6: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s6);
                Console.WriteLine("S6R: {0}, {1}, {2}, {3}", s6r.x, s6r.y, s6r.z, s6r.w);
                if (s6r.x != 1 || s6r.y != 2 || s6r.z != 3 || s6r.w != 4)
                {
                    throw new System.Exception();
                }

                S7 s7r = InvokeCallback7R((par) =>
                {
                    Console.WriteLine("S7: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s7);
                Console.WriteLine("S7R: {0}, {1}, {2}", s7r.x, s7r.y, s7r.z);
                if (s7r.x != 1 || s7r.y != 2 || s7r.z != 3)
                {
                    throw new System.Exception();
                }

                S8 s8r = InvokeCallback8R((par) =>
                {
                    Console.WriteLine("S8: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s8);
                Console.WriteLine("S8R: {0}, {1}", s8r.x, s8r.y);
                if (s8r.x != 1 || s8r.y != 2)
                {
                    throw new System.Exception();
                }

                S9 s9r = InvokeCallback9R((par) =>
                {
                    Console.WriteLine("S9: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s9);
                Console.WriteLine("S9R: {0}, {1}, {2}, {3}", s9r.x, s9r.y, s9r.z, s9r.w);
                if (s9r.x != 1 || s9r.y != 2 || s9r.z != 3 || s9r.w != 4)
                {
                    throw new System.Exception();
                }

                S10 s10r = InvokeCallback10R((par) =>
                {
                    Console.WriteLine("S10: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", par.a, par.b, par.c, par.d, par.e, par.f, par.g, par.h);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 ||
                        par.e != 5 || par.f != 6 || par.g != 7 || par.h != 8)
                    {
                        throw new System.Exception();
                    }
                }, s10);
                Console.WriteLine("S10R: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", s10r.a, s10r.b, s10r.c, s10r.d, s10r.e, s10r.f, s10r.g, s10r.h);
                if (s10r.a != 1 || s10r.b != 2 || s10r.c != 3 || s10r.d != 4 ||
                    s10r.e != 5 || s10r.f != 6 || s10r.g != 7 || s10r.h != 8)
                {
                    throw new System.Exception();
                }

                S11 s11r = InvokeCallback11R((par) =>
                {
                    Console.WriteLine("S11: {0}, {1}, {2}, {3}, {4}", par.a, par.b, par.c, par.d, par.e);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 || par.e != 5)
                    {
                        throw new System.Exception();
                    }
                }, s11);
                Console.WriteLine("S11R: {0}, {1}, {2}, {3}, {4}", s11r.a, s11r.b, s11r.c, s11r.d, s11r.e);
                if (s11r.a != 1 || s11r.b != 2 || s11r.c != 3 || s11r.d != 4 || s11r.e != 5)
                {
                    throw new System.Exception();
                }

                S12 s12r = InvokeCallback12R((par) =>
                {
                    Console.WriteLine("S12: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", par.a, par.b, par.c, par.d, par.e, par.f, par.g, par.h, par.i);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 ||
                        par.e != 5 || par.f != 6 || par.g != 7 || par.h != 8 || par.i != 9)
                    {
                        throw new System.Exception();
                    }
                }, s12);
                Console.WriteLine("S12R: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", s12r.a, s12r.b, s12r.c, s12r.d, s12r.e, s12r.f, s12r.g, s12r.h, s12r.i);
                if (s12r.a != 1 || s12r.b != 2 || s12r.c != 3 || s12r.d != 4 ||
                    s12r.e != 5 || s12r.f != 6 || s12r.g != 7 || s12r.h != 8 || s12r.i != 9)
                {
                    throw new System.Exception();
                }

                S13 s13r = InvokeCallback13R((par) =>
                {
                    Console.WriteLine("S13: {0}, {1}", par.hasValue, par.x);
                    if (par.hasValue != 1 || par.x != 2)
                    {
                        throw new System.Exception();
                    }
                }, s13);
                Console.WriteLine("S13R: {0}, {1}", s13r.hasValue, s13r.x);
                if (s13r.hasValue != 1 || s13r.x != 2)
                {
                    throw new System.Exception();
                }

                S14 s14r = InvokeCallback14R((par) =>
                {
                    Console.WriteLine("S14: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s14);
                Console.WriteLine("S14R: {0}, {1}", s14r.x, s14r.y);
                if (s14r.x != 1 || s14r.y != 2)
                {
                    throw new System.Exception();
                }

                S15 s15r = InvokeCallback15R((par) =>
                {
                    Console.WriteLine("S15: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", par.a, par.b, par.c, par.d, par.e, par.f, par.g, par.h, par.i);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 ||
                        par.e != 5 || par.f != 6 || par.g != 7 || par.h != 8 || par.i != 9)
                    {
                        throw new System.Exception();
                    }
                }, s15);
                Console.WriteLine("S15R: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", s15r.a, s15r.b, s15r.c, s15r.d, s15r.e, s15r.f, s15r.g, s15r.h, s15r.i);
                if (s15r.a != 1 || s15r.b != 2 || s15r.c != 3 || s15r.d != 4 ||
                    s15r.e != 5 || s15r.f != 6 || s15r.g != 7 || s15r.h != 8 || s15r.i != 9)
                {
                    throw new System.Exception();
                }

                S16 s16r = InvokeCallback16R((par) =>
                {
                    Console.WriteLine("S16: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s16);
                Console.WriteLine("S16R: {0}, {1}", s16r.x, s16r.y);
                if (s16r.x != 1 || s16r.y != 2)
                {
                    throw new System.Exception();
                }

                S17 s17r = InvokeCallback17R((par) =>
                {
                    Console.WriteLine("S17: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s17);
                Console.WriteLine("S17R: {0}, {1}", s17r.x, s17r.y);
                if (s17r.x != 1 || s17r.y != 2)
                {
                    throw new System.Exception();
                }

                S18 s18r = InvokeCallback18R((par) =>
                {
                    Console.WriteLine("S18: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s18);
                Console.WriteLine("S18R: {0}, {1}, {2}", s18r.x, s18r.y, s18r.z);
                if (s18r.x != 1 || s18r.y != 2 || s18r.z != 3)
                {
                    throw new System.Exception();
                }

                S19 s19r = InvokeCallback19R((par) =>
                {
                    Console.WriteLine("S19: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s19);
                Console.WriteLine("S19R: {0}, {1}, {2}, {3}", s19r.x, s19r.y, s19r.z, s19r.w);
                if (s19r.x != 1 || s19r.y != 2 || s19r.z != 3 || s19r.w != 4)
                {
                    throw new System.Exception();
                }

                S20 s20r = InvokeCallback20R((par) =>
                {
                    Console.WriteLine("S20: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s20);
                Console.WriteLine("S20R: {0}, {1}, {2}, {3}", s20r.x, s20r.y, s20r.z, s20r.w);
                if (s20r.x != 1 || s20r.y != 2 || s20r.z != 3 || s20r.w != 4)
                {
                    throw new System.Exception();
                }

                /* These tests are not working on non Windows CoreCLR.  Enable this when https://github.com/dotnet/runtime/issues/4680 is resolved.
                 * s28.x = null;
                 * S28 s28r = InvokeCallback28R((par) => {
                 *  Console.WriteLine("S28: {0}, {1}", par.x == null ? "Null" : "Not null", par.y);
                 *  if (par.x == null || par.y != 5)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s28);
                 * Console.WriteLine("S28R: {0}, {1}", s28r.x == null ? "Null" : "Not null", s28r.y);
                 * if (s28r.x == null || s28r.y != 5)
                 * {
                 *  throw new System.Exception();
                 * }
                 *
                 * s28.x = testClass;
                 * s28.y = 5;
                 *
                 * s28r = InvokeCallback28R((par) => {
                 *  Console.WriteLine("S28: {0}, {1}", par.x == null ? "Null" : "Not null", par.y);
                 *  if (par.x != testClass || par.y != 5)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s28);
                 * Console.WriteLine("S28R: {0}, {1}", s28r.x == null ? "Null" : "Not null", s28r.y);
                 * if (s28r.x != testClass || s28r.y != 5)
                 * {
                 *  throw new System.Exception();
                 * }
                 *
                 * s29.y = null;
                 * S29 s29r = InvokeCallback29R((par) => {
                 *  Console.WriteLine("S29: {0}, {1}", par.x, par.y == null ? "Null" : "Not null");
                 *  if (par.x != 5 || par.y == null)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s29);
                 * Console.WriteLine("S29R: {0}, {1}", s29r.x, s29r.y == null ? "Null" : "Not null");
                 * if (s29r.x != 5 || s29r.y == null)
                 * {
                 *  throw new System.Exception();
                 * }
                 *
                 * s29.x = 5;
                 * s29.y = testClass;
                 * s29r = InvokeCallback29R((par) => {
                 *  Console.WriteLine("S29: {0}, {1}", par.x, par.y == null ? "Null" : "Not null");
                 *  if (par.x != 5 || par.y != testClass)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s29);
                 * Console.WriteLine("S29R: {0}, {1}", s29r.x, s29r.y == null ? "Null" : "Not null");
                 * if (s29r.x != 5 || s29r.y != testClass)
                 * {
                 *  throw new System.Exception();
                 * }
                 * Enable this when https://github.com/dotnet/runtime/issues/4680 is resolved. */
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(-1);
            }
            return(100);
        }
Exemple #13
0
        public void CanOverrideGetHashCode()
        {
            var s1 = new S5(42);

            Assert.AreEqual(43, s1.GetHashCode());
        }
Exemple #14
0
 public static void PrintS5(S5 str1, string name)
 {
     Console.WriteLine("\t{0}.s4.age = {1}", str1.s4.age);
     Console.WriteLine("\t{0}.s4.name = {1}", str1.s4.name);
     Console.WriteLine("\t{0}.ef = {1}", str1.ef.ToString());
 }
Exemple #15
0
 [MethodImpl(MethodImplOptions.NoInlining)] static void TestS5_2(ref S5 s)
 {
     var _ = s.a2;
 }