Ejemplo n.º 1
0
    public static int test_0_dyncall_nullable()
    {
        int?v;

        v = 42;
        NullableMethods.GetHasValue(v);
        bool b = (bool)typeof(NullableMethods).GetMethod("GetHasValue").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { v });

        if (!b)
        {
            return(1);
        }
        v = null;
        b = (bool)typeof(NullableMethods).GetMethod("GetHasValue").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { v });
        if (b)
        {
            return(2);
        }

        v = 42;
        NullableMethods.GetValue(v);
        var res = (int)typeof(NullableMethods).GetMethod("GetValue").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { v });

        if (res != 42)
        {
            return(3);
        }
        return(0);
    }
Ejemplo n.º 2
0
    public static int test_0_dyncall_nullable()
    {
        int?v;

        v = 42;
        NullableMethods.GetHasValue(v);
        bool b = (bool)typeof(NullableMethods).GetMethod("GetHasValue").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { v });

        if (!b)
        {
            return(1);
        }
        v = null;
        b = (bool)typeof(NullableMethods).GetMethod("GetHasValue").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { v });
        if (b)
        {
            return(2);
        }

        v = 42;
        NullableMethods.GetValue(v);
        var res = (int)typeof(NullableMethods).GetMethod("GetValue").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { v });

        if (res != 42)
        {
            return(3);
        }

        NullableMethods.Get(42);
        var res2 = (int?)typeof(NullableMethods).GetMethod("Get").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { 42 });

        if (res2 != 42)
        {
            return(4);
        }
        res2 = (int?)typeof(NullableMethods).GetMethod("GetNull").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { });
        if (res2.HasValue)
        {
            return(5);
        }

        NullableMethods.NullableMany(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8);
        res2 = (int?)typeof(NullableMethods).GetMethod("NullableMany").Invoke(null, new object [] { 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L });
        if (res2 != 36)
        {
            return(6);
        }
        return(0);
    }