Exemplo n.º 1
0
        public async Task WhenALoggerWritesToTheSinkItStoresTheCorrectTypesForStructure()
        {
            var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
            var tableClient    = storageAccount.CreateCloudTableClient();
            var table          = tableClient.GetTableReference("LogEventEntity");

            await table.DeleteIfExistsAsync();

            var logger = new LoggerConfiguration()
                         .WriteTo.AzureTableStorageWithProperties(storageAccount)
                         .CreateLogger();

            var struct1 = new Struct1
            {
                IntVal    = 10,
                StringVal = "ABCDE"
            };

            var struct2 = new Struct2
            {
                DateTimeVal = new DateTime(2014, 12, 3, 17, 37, 12),
                DoubleVal   = Math.PI
            };

            var struct0 = new Struct0
            {
                Struct1Val = struct1,
                Struct2Val = struct2
            };

            logger.Information("{@Struct0}", struct0);
            var result = (await TableQueryTakeDynamicAsync(table, takeCount: 1)).First();

            Assert.Equal("Struct0 { Struct1Val: Struct1 { IntVal: 10, StringVal: \"ABCDE\" }, Struct2Val: Struct2 { DateTimeVal: 12/03/2014 17:37:12, DoubleVal: 3.14159265358979 } }", result.Properties["Struct0"].StringValue);
        }
Exemplo n.º 2
0
    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);
        }
    }
Exemplo n.º 3
0
        void simconnect_OnRecvSimobjectData(SimConnect sender, SIMCONNECT_RECV_SIMOBJECT_DATA data)
        {
            switch ((DATA_REQUESTS)data.dwRequestID)
            {
            case DATA_REQUESTS.REQUEST_1:
                Struct1 s1 = (Struct1)data.dwData[0];

                if (!simrunning)
                {
                    sw.Start();
                    simrunning = true;
                }

                s1.time = sw.ElapsedMilliseconds;

                log.Add(s1);

                if (log.Count % 100 == 0)
                {
                    Struct1 current = log.Last();
                    displayStats(current);
                }
                break;

            case DATA_REQUESTS.REQUEST_2:
                Struct2 s2 = (Struct2)data.dwData[0];
                s2.time = log.Count == 0 ? 0 : log.Last().time;
                log2.Add(s2);
                break;

            default:
                displayText("Unknown request ID: " + data.dwRequestID);
                break;
            }
        }
Exemplo n.º 4
0
        void displayStats2(Struct2 s2)
        {
            resetText();

            displayText("Title: " + s2.title);
            displayText("Ambient density:" + s2.ambient_density);
            displayText("Ambient temperature: " + s2.ambient_temperature);
            displayText("Ambient pressure: " + s2.ambient_pressure);
            displayText("Sea level pressure: " + s2.sea_level_pressure);
            displayText("Gear position: " + s2.gear_position);
            displayText("Current fuel: " + s2.fuel_current);

            double avg   = 0;
            double count = 0;

            for (int i = log2.Count - 1; i > 0 && i > log2.Count - 5; i--)
            {
                avg += log2[i - 1].fuel_current - log2[i].fuel_current;
                count++;
            }

            avg /= count;

            displayText("Calculated fuel flow: " + avg * 60 * 60);
            displayText("Minutes until out of fuel: " + (s2.fuel_current / (avg * 60)));
        }
Exemplo n.º 5
0
 public static void EditStruct(ref Struct2 structToEdit)
 {
     structToEdit = new Struct2()
     {
         C = 30, D = 40
     };
 }
Exemplo n.º 6
0
    static void Main(string[] args)
    {
        IStruct s1 = new Struct1();
        IStruct s2 = new Struct2();

        EditStruct(ref s1);
        EditStruct(ref s2);
    }
Exemplo n.º 7
0
        static void Main()
        {
            var cc = Contact.Create();

            Contact c = new Contact();

            c.Name("Hello C#");
            var name = c.Name();

            c.RegisterOnNameChange((string str) => {
                int a = 0;
            });

            c.Callback2((Contact c2) => {
                var name1 = c.Name();
                var name2 = c2.Name();
                var id2   = c2.Id();
                int a     = 0;
            });

            var s = new Session();

            s.AddContact(c);
            s.AddContact(c);
            s.AddContact(c);

            s.IntTest1(true, 2, 3, 4, 5, 6, 7);
            s.IntTest2(2, 3, 4, 5, 6, 7);
            var b = s.AutoTest();

            c.SendContacts(new Contact[] { c, c });
            var aa2 = c.TestArray(new int[] { 5, 6 });
            var aa3 = c.TestArray2(new float[] { 5.5F, 6.5F });

            //var contacts = s.Contacts();

            var m  = new Model();
            var p1 = new Struct2();

            p1.strings  = new string[] { "hello1", "hello2" };
            p1.callback = (string str) => {
                return(str + " from C#");
            };
            p1.f1 = new Struct1 {
                a = 55, b = "hello", buffer = new uint[] { 33, 44 }
            };

            var p2 = m.TestStruct(p1);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Exemplo n.º 8
0
    static void Main(string[] args)
    {
        var x = new Struct1()
        {
            A = 0, B = -10
        };
        var y = new Struct2()
        {
            C = 0, D = -10
        };

        MyFunction(ref x);
        MyFunction(ref y);
    }
Exemplo n.º 9
0
    static int test_0_arm64_dyncall_hfa_float()
    {
        double arg1 = 1.0f;
        var    s    = new Struct2();

        s.a = 1.0f;
        s.b = 2.0f;
        var s_res = (Struct2)typeof(Foo <Struct2>).GetMethod("Get_T").Invoke(null, new object [] { arg1, s });

        if (s_res.a != 1.0f || s_res.b != 2.0f)
        {
            return(1);
        }
        return(0);
    }
Exemplo n.º 10
0
    public static void MyMethod(WhatToDo what)
    {
        switch (what)
        {
        case WhatToDo.Something:
            Struct1 param1 = new Struct1();
            MygenericMethod(param1);
            break;

        case WhatToDo.SomethingElse:
            Struct2 param2 = new Struct2();
            MygenericMethod(param2);
            break;
        }
    }
Exemplo n.º 11
0
        private static HardDiskInfo smethod_1(byte byte_0)
        {
            Struct0 struct2 = new Struct0();
            Struct2 struct3 = new Struct2();
            Struct4 struct4 = new Struct4();
            uint    num     = 0;
            IntPtr  ptr     = CreateFile(@"\\.\Smartvsd", 0, 0, IntPtr.Zero, 1, 0, IntPtr.Zero);

            if (ptr == IntPtr.Zero)
            {
                throw new Exception("Open   smartvsd.vxd   failed.");
            }
            if (DeviceIoControl(ptr, 0x74080, IntPtr.Zero, 0, ref struct2, (uint)Marshal.SizeOf(struct2), ref num, IntPtr.Zero) == 0)
            {
                CloseHandle(ptr);
                throw new Exception("DeviceIoControl   failed:DFP_GET_VERSION");
            }
            if ((struct2.uint_0 & 1) == 0)
            {
                CloseHandle(ptr);
                throw new Exception("Error:   IDE   identify   command   not   supported.");
            }
            if ((byte_0 & 1) != 0)
            {
                struct3.struct1_0.byte_5 = 0xb0;
            }
            else
            {
                struct3.struct1_0.byte_5 = 160;
            }
            if ((struct2.uint_0 & (((int)0x10) >> byte_0)) != 0)
            {
                CloseHandle(ptr);
                throw new Exception($"Drive   {byte_0 + 1}   is   a   ATAPI   device,   we   don't   detect   it");
            }
            struct3.struct1_0.byte_6 = 0xec;
            struct3.byte_0           = byte_0;
            struct3.struct1_0.byte_1 = 1;
            struct3.struct1_0.byte_2 = 1;
            struct3.uint_0           = 0x200;
            if (DeviceIoControl_1(ptr, 0x7c088, ref struct3, (uint)Marshal.SizeOf(struct3), ref struct4, (uint)Marshal.SizeOf(struct4), ref num, IntPtr.Zero) == 0)
            {
                CloseHandle(ptr);
                throw new Exception("DeviceIoControl   failed:   DFP_RECEIVE_DRIVE_DATA");
            }
            CloseHandle(ptr);
            return(smethod_3(struct4.struct5_0));
        }
Exemplo n.º 12
0
        public static bool Read(IReader reader, ref Struct2 val, string name = null)
        {
            if (!reader.StructBegin(Struct2.HASH_CODE, name))
            {
                return(false);
            }

            Read(reader, ref val.a, "a");
            Read(reader, ref val.b, "b");
            Read(reader, ref val.c, "c");
            Read(reader, ref val.d, "d");
            Read(reader, ref val.s, "s");
            Read(reader, ref val.s1, "s1");
            DoRead(reader, ref val.s2, "s2", Read);
            DoRead(reader, ref val.s3, "s3", Read);

            return(reader.StructEnd());
        }
Exemplo n.º 13
0
        public static bool Write(IWriter writer, Struct2 val, string name = null)
        {
            if (!writer.StructBegin(Struct2.HASH_CODE, name))
            {
                return(false);
            }

            Write(writer, val.a, "a");
            Write(writer, val.b, "b");
            Write(writer, val.c, "c");
            Write(writer, val.d, "d");
            Write(writer, val.s, "s");
            Write(writer, val.s1, "s1");
            DoWrite(writer, val.s2, "s2", Write);
            DoWrite(writer, val.s3, "s3", Write);

            return(writer.StructEnd());
        }
Exemplo n.º 14
0
    static int test_0_arm64_dyncall_gsharedvt_out_hfa_float()
    {
        /* gsharedvt out trampoline with double hfa argument */
        double arg1 = 1.0f;

        var s = new Struct2();

        s.a = 1.0f;
        s.b = 2.0f;
        // Call Foo2.Get_T directly, so its gets an instance
        Foo2 <Struct2> .Get_T(arg1, s);

        Type t = typeof(Foo3 <>).MakeGenericType(new Type [] { typeof(Struct2) });
        // Call Foo3.Get_T, this will call the gsharedvt instance, which will call the non-gsharedvt instance
        var s_res = (Struct2)t.GetMethod("Get_T").Invoke(null, new object [] { arg1, s });

        if (s_res.a != 1.0f || s_res.b != 2.0f)
        {
            return(1);
        }
        return(0);
    }
Exemplo n.º 15
0
    public Struct1 Foo(Struct2 v, ref Struct3 r, sbyte t, ref sbyte tr)
    {
        Struct1 ret = new Struct1();

        String values =
            v.ToString() + " " +
            r.ToString() + " " +
            t.ToString() + " " +
            tr.ToString() + " " +
            ".";

        if (values != "104 225 80 57 184 -96 -96 .")
        {
            Console.WriteLine("Struct1 Foo(...): unexpected values: " + values);
            Fail(11);
        }

        r.Randomize();
        tr += (sbyte)Randomizer();
        ret.Randomize();
        return(ret);
    }
Exemplo n.º 16
0
    public Struct2 Foo(ref Struct4 r, Struct3 v, short t, ref short tr)
    {
        Struct2 ret = new Struct2();

        String values =
            v.ToString() + " " +
            r.ToString() + " " +
            t.ToString() + " " +
            tr.ToString() + " " +
            ".";

        if (values != "89 161 153 17 160 105 8 -32144 -32144 .")
        {
            Console.WriteLine("Struct2 Foo(...): unexpected values: " + values);
            Fail(12);
        }

        r.Randomize();
        tr += (short)Randomizer();
        ret.Randomize();
        return(ret);
    }
Exemplo n.º 17
0
    public double Foo(ref Struct2 r, Struct1 v, String t, ref String tr)
    {
        double ret;

        String values =
            v.ToString() + " " +
            r.ToString() + " " +
            t.ToString() + " " +
            tr.ToString() + " " +
            ".";

        if (values != "170 65 240 -5893266573950244255 -58932665739" +
            "50244255 .")
        {
            Console.WriteLine("double Foo(...): unexpected values: " + values);
            Fail(19);
        }

        r.Randomize();
        /* tr += */ Randomizer().ToString();
        ret = (double)Randomizer();
        return(ret);
    }
Exemplo n.º 18
0
    public double Foo(ref Struct2 r, Struct1 v, String t, ref String tr)
    {
        double ret;

        String values =
            v.ToString() + " " +
            r.ToString() + " " +
            t.ToString() + " " +
            tr.ToString() + " " +
            ".";

        if (values != "226 121 120 2212973731230676456 221297373123" +
            "0676456 .")
        {
            Console.WriteLine("double Foo(...): unexpected values: " + values);
            Fail(19);
        }

        r.Randomize();
        tr += Randomizer().ToString();
        ret = (double)Randomizer();
        return(ret);
    }
    public Struct2 Foo(ref Struct4 r, Struct3 v, short t, ref short tr) {
        Struct2 ret = new Struct2();

        String values =
            v.ToString() + " " +
            r.ToString() + " " +
            t.ToString() + " " +
            tr.ToString() + " " +
            ".";

        if (values != "17 169 209 17 160 105 8 -19598 -19598 .")
        {
            Console.WriteLine("Struct2 Foo(...): unexpected values: " + values);
            Fail(12);
        }

        r.Randomize();
        tr += (short)Randomizer();
        ret.Randomize();
        return ret;
    }
    public Struct1 Foo(Struct2 v, ref Struct3 r, sbyte t, ref sbyte tr) {
        Struct1 ret = new Struct1();

        String values =
            v.ToString() + " " +
            r.ToString() + " " +
            t.ToString() + " " +
            tr.ToString() + " " +
            ".";

        if (values != "104 225 80 57 184 -62 -62 .")
        {
            Console.WriteLine("Struct1 Foo(...): unexpected values: " + values);
            Fail(11);
        }

        r.Randomize();
        tr += (sbyte)Randomizer();
        ret.Randomize();
        return ret;
    }
Exemplo n.º 21
0
 static extern Struct2 StructTest2(Struct2 s, ref Struct2 _s);
Exemplo n.º 22
0
    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());
    }
Exemplo n.º 23
0
 private static extern bool AdjustTokenPrivileges(IntPtr intptr_0, bool bool_0, ref Struct2 struct2_0, int int_9, IntPtr intptr_1, IntPtr intptr_2);
    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");
    }
Exemplo n.º 25
0
 public bool Equals(Struct2 other)
 {
     return((y == other.y) && (x == other.x) && (d == other.d));
 }
Exemplo n.º 26
0
 public Struct1(UInt32 u1, Struct2 stk1, string s1, double d1, Struct2 stk2, Int32 i1, UInt16 q1, Struct2 stk3, bool b1)
 {
     u = u1; st1 = stk1; s = s1; d = d1; st2 = stk2; i = i1; q = q1; st3 = stk3; b = b1;
 }
Exemplo n.º 27
0
    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");
    }
Exemplo n.º 28
0
 public void testEmptyStruct2(Logger l) {
     l.Function = "testEmptyStruct2";
     Struct2 s = new Struct2();
     l.assure(s.p1 == false);
     l.assure(s.p2 == 0);
     l.assure(s.p3 == 0);
     l.assure(s.p4 == 0);
     l.assure(s.p5 == 0);
     l.assure(s.p6 == 0);
     l.assure(s.p7 == 0L);
     l.assure(s.p8 == 0L);
     l.assure(s.p9 == 0.0f);
     l.assure(s.p10 == 0.0);
     l.assure(s.p11 == '\u0000');
     l.assure(s.p12.Equals(""));
     l.assure(s.p13.Equals(typeof(void)));
     l.assure(s.p14.Equals(Any.VOID));
     l.assure(s.p15 == Enum2.VALUE0);
     l.assure(s.p16.member1 == 0);
     l.assure(s.p17 == null);
     l.assure(s.p18 == null);
     l.assure(s.t1 == false);
     l.assure(s.t2 == 0);
     l.assure(s.t3 == 0);
     l.assure(s.t4 == 0);
     l.assure(s.t5 == 0);
     l.assure(s.t6 == 0);
     l.assure(s.t7 == 0L);
     l.assure(s.t8 == 0L);
     l.assure(s.t9 == 0.0f);
     l.assure(s.t10 == 0.0);
     l.assure(s.t11 == '\u0000');
     l.assure(s.t12.Equals(""));
     l.assure(s.t13.Equals(typeof(void)));
     l.assure(s.t14.Equals(Any.VOID));
     l.assure(s.t15 == Enum2.VALUE0);
     l.assure(s.t16.member1 == 0);
     l.assure(s.t17 == null);
     l.assure(s.t18 == null);
     l.assure(s.a1.Length == 0);
     l.assure(s.a2.Length == 0);
     l.assure(s.a3.Length == 0);
     l.assure(s.a4.Length == 0);
     l.assure(s.a5.Length == 0);
     l.assure(s.a6.Length == 0);
     l.assure(s.a7.Length == 0);
     l.assure(s.a8.Length == 0);
     l.assure(s.a9.Length == 0);
     l.assure(s.a10.Length == 0);
     l.assure(s.a11.Length == 0);
     l.assure(s.a12.Length == 0);
     l.assure(s.a13.Length == 0);
     l.assure(s.a14.Length == 0);
     l.assure(s.a15.Length == 0);
     l.assure(s.a16.Length == 0);
     l.assure(s.a17.Length == 0);
     l.assure(s.a18.Length == 0);
     l.assure(s.aa1.Length == 0);
     l.assure(s.aa2.Length == 0);
     l.assure(s.aa3.Length == 0);
     l.assure(s.aa4.Length == 0);
     l.assure(s.aa5.Length == 0);
     l.assure(s.aa6.Length == 0);
     l.assure(s.aa7.Length == 0);
     l.assure(s.aa8.Length == 0);
     l.assure(s.aa9.Length == 0);
     l.assure(s.aa10.Length == 0);
     l.assure(s.aa11.Length == 0);
     l.assure(s.aa12.Length == 0);
     l.assure(s.aa13.Length == 0);
     l.assure(s.aa14.Length == 0);
     l.assure(s.aa15.Length == 0);
     l.assure(s.aa16.Length == 0);
     l.assure(s.aa17.Length == 0);
     l.assure(s.aa18.Length == 0);
     l.assure(s.at1.Length == 0);
     l.assure(s.at2.Length == 0);
     l.assure(s.at3.Length == 0);
     l.assure(s.at4.Length == 0);
     l.assure(s.at5.Length == 0);
     l.assure(s.at6.Length == 0);
     l.assure(s.at7.Length == 0);
     l.assure(s.at8.Length == 0);
     l.assure(s.at9.Length == 0);
     l.assure(s.at10.Length == 0);
     l.assure(s.at11.Length == 0);
     l.assure(s.at12.Length == 0);
     l.assure(s.at13.Length == 0);
     l.assure(s.at14.Length == 0);
     l.assure(s.at15.Length == 0);
     l.assure(s.at16.Length == 0);
     l.assure(s.at17.Length == 0);
     l.assure(s.at18.Length == 0);
 }
Exemplo n.º 29
0
    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");
    }
Exemplo n.º 30
0
 public void testFullStruct2(Logger l) {
     //TODO:
     Struct2 s = new Struct2(
         true, (byte) 1, (short) 2, (ushort) 3, 4, 5, 6L, 7L, 0.8f, 0.9d, 'A',
         "BCD", typeof(ulong), new Any(22), Enum2.VALUE4,
         new Struct1(1), null, null, false, (byte) 0, (short) 0, (ushort) 0,
         0, 0, 0L, 0L, 0.0f, 0.0, '\u0000', "", typeof(void), Any.VOID,
         Enum2.VALUE0, new Struct1(), null, null,
         new bool[] { false, true }, new byte[] { (byte) 1, (byte) 2 },
         new short[0], new ushort[0], new int[0], new uint[0],
         new long[0], new ulong[0], new float[0], new double[0], new char[0],
         new String[0], new Type[0], new Any[0], new Enum2[0],
         new Struct1[] { new Struct1(1), new Struct1(2) }, new Object[0],
         new ucss.uno.XNamingService[0], new bool[0][], new byte[0][],
         new short[0][], new ushort[0][], new int[0][], new uint[0][],
         new long[0][], new ulong[0][], new float[0][], new double[0][],
         new char[0][], new String[0][], new Type[0][], new Any[0][],
         new Enum2[0][], new Struct1[0][], new Object[0][],
         new ucss.uno.XNamingService[0][], new bool[0][], new byte[0][],
         new short[0][], new ushort[0][], new int[0][], new uint[0][],
         new long[0][], new ulong[0][], new float[0][], new double[0][],
         new char[0][], new String[0][], new Type[0][], new Any[0][],
         new Enum2[0][], new Struct1[0][], new Object[0][],
         new ucss.uno.XNamingService[0][]);
     l.assure(s.p1 == true);
     l.assure(s.p2 == 1);
     l.assure(s.p3 == 2);
     l.assure(s.p4 == 3);
     l.assure(s.p5 == 4);
     l.assure(s.p6 == 5);
     l.assure(s.p7 == 6L);
     l.assure(s.p8 == 7L);
     l.assure(s.p9 == 0.8f);
     l.assure(s.p10 == 0.9);
     l.assure(s.p11 == 'A');
     l.assure(s.p12.Equals("BCD"));
     l.assure(s.p13.Equals(typeof(ulong)));
     l.assure(s.p14.Equals(new Any(22)));
     l.assure(s.p15 == Enum2.VALUE4);
     l.assure(s.p16.member1 == 1);
     l.assure(s.p17 == null);
     l.assure(s.p18 == null);
     l.assure(s.t1 == false);
     l.assure(s.t2 == 0);
     l.assure(s.t3 == 0);
     l.assure(s.t4 == 0);
     l.assure(s.t5 == 0);
     l.assure(s.t6 == 0);
     l.assure(s.t7 == 0L);
     l.assure(s.t8 == 0L);
     l.assure(s.t9 == 0.0f);
     l.assure(s.t10 == 0.0);
     l.assure(s.t11 == '\u0000');
     l.assure(s.t12.Equals(""));
     l.assure(s.t13.Equals(typeof(void)));
     l.assure(s.t14.Equals(Any.VOID));
     l.assure(s.t15 == Enum2.VALUE0);
     l.assure(s.t16.member1 == 0);
     l.assure(s.t17 == null);
     l.assure(s.t18 == null);
     l.assure(s.a1.Length == 2);
     l.assure(s.a1[0] == false);
     l.assure(s.a1[1] == true);
     l.assure(s.a2.Length == 2);
     l.assure(s.a2[0] == 1);
     l.assure(s.a2[1] == 2);
     l.assure(s.a3.Length == 0);
     l.assure(s.a4.Length == 0);
     l.assure(s.a5.Length == 0);
     l.assure(s.a6.Length == 0);
     l.assure(s.a7.Length == 0);
     l.assure(s.a8.Length == 0);
     l.assure(s.a9.Length == 0);
     l.assure(s.a10.Length == 0);
     l.assure(s.a11.Length == 0);
     l.assure(s.a12.Length == 0);
     l.assure(s.a13.Length == 0);
     l.assure(s.a14.Length == 0);
     l.assure(s.a15.Length == 0);
     l.assure(s.a16.Length == 2);
     l.assure(s.a16[0].member1 == 1);
     l.assure(s.a16[1].member1 == 2);
     l.assure(s.a17.Length == 0);
     l.assure(s.a18.Length == 0);
     l.assure(s.aa1.Length == 0);
     l.assure(s.aa2.Length == 0);
     l.assure(s.aa3.Length == 0);
     l.assure(s.aa4.Length == 0);
     l.assure(s.aa5.Length == 0);
     l.assure(s.aa6.Length == 0);
     l.assure(s.aa7.Length == 0);
     l.assure(s.aa8.Length == 0);
     l.assure(s.aa9.Length == 0);
     l.assure(s.aa10.Length == 0);
     l.assure(s.aa11.Length == 0);
     l.assure(s.aa12.Length == 0);
     l.assure(s.aa13.Length == 0);
     l.assure(s.aa14.Length == 0);
     l.assure(s.aa15.Length == 0);
     l.assure(s.aa16.Length == 0);
     l.assure(s.aa17.Length == 0);
     l.assure(s.aa18.Length == 0);
     l.assure(s.at1.Length == 0);
     l.assure(s.at2.Length == 0);
     l.assure(s.at3.Length == 0);
     l.assure(s.at4.Length == 0);
     l.assure(s.at5.Length == 0);
     l.assure(s.at6.Length == 0);
     l.assure(s.at7.Length == 0);
     l.assure(s.at8.Length == 0);
     l.assure(s.at9.Length == 0);
     l.assure(s.at10.Length == 0);
     l.assure(s.at11.Length == 0);
     l.assure(s.at12.Length == 0);
     l.assure(s.at13.Length == 0);
     l.assure(s.at14.Length == 0);
     l.assure(s.at15.Length == 0);
     l.assure(s.at16.Length == 0);
     l.assure(s.at17.Length == 0);
     l.assure(s.at18.Length == 0);
 }
    public double Foo(ref Struct2 r, Struct1 v, String t, ref String tr) {
        double ret;

        String values =
            v.ToString() + " " +
            r.ToString() + " " +
            t.ToString() + " " +
            tr.ToString() + " " +
            ".";

        if (values != "226 121 120 2212973731230676456 221297373123" +
            "0676456 .")
        {
            Console.WriteLine("double Foo(...): unexpected values: " + values);
            Fail(19);
        }

        r.Randomize();
        tr += Randomizer().ToString();
        ret = (double)Randomizer();
        return ret;
    }
    public double Foo(ref Struct2 r, Struct1 v, String t, ref String tr) {
        double ret;

        String values =
            v.ToString() + " " +
            r.ToString() + " " +
            t.ToString() + " " +
            tr.ToString() + " " +
            ".";

        if (values != "170 65 240 -5893266573950244255 -58932665739" +
            "50244255 .")
        {
            Console.WriteLine("double Foo(...): unexpected values: " + values);
            Fail(19);
        }

        r.Randomize();
        /* tr += */ Randomizer().ToString();
        ret = (double)Randomizer();
        return ret;
    }
    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 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());
    }
Exemplo n.º 36
0
 private static extern int DeviceIoControl_1(IntPtr intptr_0, uint uint_9, ref Struct2 struct2_0, uint uint_10, ref Struct4 struct4_0, uint uint_11, ref uint uint_12, [Out] IntPtr intptr_1);
		public void WhenALoggerWritesToTheSinkItStoresTheCorrectTypesForStructure()
		{
			var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
			var tableClient = storageAccount.CreateCloudTableClient();
			var table = tableClient.GetTableReference("LogEventEntity");

			table.DeleteIfExists();

			var logger = new LoggerConfiguration()
				.WriteTo.AzureTableStorageWithProperties(storageAccount)
				.CreateLogger();

			var struct1 = new Struct1
			{
				IntVal = 10,
				StringVal = "ABCDE"
			};

			var struct2 = new Struct2
			{
				DateTimeVal = new DateTime(2014, 12, 3, 17, 37, 12),
				DoubleVal = Math.PI
			};

			var struct0 = new Struct0
			{
				Struct1Val = struct1,
				Struct2Val = struct2
			};

			logger.Information("{@Struct0}", struct0);
			var result = table.ExecuteQuery(new TableQuery().Take(1)).First();

			Assert.AreEqual("Struct0 { Struct1Val: Struct1 { IntVal: 10, StringVal: \"ABCDE\" }, Struct2Val: Struct2 { DateTimeVal: 12/03/2014 17:37:12, DoubleVal: 3.14159265358979 } }", result.Properties["Struct0"].StringValue);
		}
Exemplo n.º 38
0
 static extern Struct2 StructTest2(Struct2 s, ref Struct2 _s);