Пример #1
0
        public static int MainMethod()
        {
            dynamic tf = new Derived();
            dynamic d  = 2;

            try
            {
                tf.Foo(Invalid: d);
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                bool ret = ErrorVerifier.Verify(ErrorMessageId.BadNamedArgument, e.Message, "Foo", "Invalid");
                if (ret)
                {
                    return(0);
                }
            }

            return(1);
        }
        public static int MainMethod(string[] args)
        {
            var     x = 3;
            dynamic d = x.Foo(4);

            try
            {
                //This should not compile if the return type of Foo is not dynamic
                d.Bar();
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                if (ErrorVerifier.Verify(ErrorMessageId.NoSuchMember, e.Message, "int", "Bar"))
                {
                    return(0);
                }
            }

            return(1);
        }
Пример #3
0
        public static int MainMethod(string[] args)
        {
            dynamic d   = new MyClass();
            dynamic del = null;

            try
            {
                d = d.Prop(3); //Property returning a delegate
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                bool ret = ErrorVerifier.Verify(ErrorMessageId.NoSuchMember, ex.Message, "Test.MyClass", "Prop");
                if (ret)
                {
                    return(0);
                }
            }

            return(1);
        }
Пример #4
0
        public static int MainMethod(string[] args)
        {
            MyClass mc = new MyClass();
            dynamic d  = (myDel)mc.Do;

            try
            {
                d(3, 4, 6); //We invoke the dynamic delegate
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                bool ret = ErrorVerifier.Verify(ErrorMessageId.BadDelArgCount, ex.Message, "myDel", "3");
                if (ret)
                {
                    return(0);
                }
            }

            return(1);
        }
        public static int MainMethod(string[] args)
        {
            Foo     f  = new Foo();
            dynamic d  = "foo";
            dynamic d2 = 3;

            try
            {
                f[d2, d] = 3;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                if (ErrorVerifier.Verify(ErrorMessageId.BadArgTypes, e.Message, "Foo.this[params int[]]"))
                {
                    return(0);
                }
            }

            return(1);
        }
Пример #6
0
        public static int MainMethod(string[] args)
        {
            dynamic mc = new MyClass();

            try
            {
                myDel del = mc.Do;
                del(3); //We invoke the dynamic delegate
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                bool ret = ErrorVerifier.Verify(RuntimeErrorId.BindPropertyFailedMethodGroup, ex.Message, "Do");
                if (ret)
                {
                    return(0);
                }
            }

            return(1);
        }
Пример #7
0
        public static int MainMethod(string[] ars)
        {
            Test    t = new Test();
            dynamic d = t;

            d.Field += new MyDel(t.Method); // No exception: string + delegate
            try
            {
                d.FieldInt -= new MyDel(t.Method);
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                if (ErrorVerifier.Verify(ErrorMessageId.BadBinaryOps, e.Message, "-=", "int", "Test.MyDel"))
                {
                    return(0);
                }
            }

            return(1);
        }
Пример #8
0
        public static int MainMethod(string[] ars)
        {
            Test    t = new Test();
            dynamic d = t;

            try
            {
                byte b = 10;
                d[10] += b;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                if (ErrorVerifier.Verify(ErrorMessageId.PropertyLacksGet, e.Message, "Test.this[long]"))
                {
                    return(0);
                }
            }

            return(1);
        }
Пример #9
0
        public static int MainMethod(string[] ars)
        {
            Test    t = new Test();
            dynamic d = t;

            try
            {
                byte b = 10;
                d.Field += b;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                if (ErrorVerifier.Verify(ErrorMessageId.InaccessibleSetter, e.Message, "Test.Field"))
                {
                    return(0);
                }
            }

            return(1);
        }
Пример #10
0
        public static int MainMethod(string[] ars)
        {
            Test    t = new Test();
            dynamic d = t;

            try
            {
                char c = (char)2;
                d.field *= c;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                if (ErrorVerifier.Verify(ErrorMessageId.AssgReadonly, e.Message))
                {
                    return(0);
                }
            }

            return(1);
        }
        public static int MainMethod(string[] args)
        {
            dynamic d   = new Unsafe();
            bool    ret = true;

            try
            {
                var p = d[1];
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                ret = ErrorVerifier.Verify(ErrorMessageId.UnsafeNeeded, ex.Message);
                if (ret)
                {
                    return(0);
                }
            }

            return(1);
        }
        public static int MainMethod(string[] args)
        {
            dynamic d   = new Test();
            bool    ret = true;

            try
            {
                d.Foo();
            }
            catch (RuntimeBinderException ex)
            {
                ret = ErrorVerifier.Verify(ErrorMessageId.UnsafeNeeded, ex.Message);
                if (ret)
                {
                    return(0);
                }
            }

            return(1);
        }
        public static int MainMethod(string[] args)
        {
            dynamic d = 1;
            dynamic t = default(Test);

            try
            {
                int i = t.Foo(d);
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                bool ret = ErrorVerifier.Verify(RuntimeErrorId.NullReferenceOnMemberException, ex.Message);
                if (ret)
                {
                    return(0);
                }
            }

            return(1);
        }
        public static int MainMethod(string[] args)
        {
            dynamic d = 1;
            dynamic t = new Test();

            try
            {
                dynamic i = t.Bar().Foo(d);
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                bool ret = ErrorVerifier.Verify(RuntimeErrorId.BindToVoidMethodButExpectResult, ex.Message);
                if (ret)
                {
                    return(0);
                }
            }

            return(1);
        }
Пример #15
0
        public static int MainMethod()
        {
            dynamic p = new Parent();
            dynamic d = null;

            try
            {
                p.Foo(d);
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                bool ret = ErrorVerifier.Verify(ErrorMessageId.NoSuchMember, e.Message, "Parent", "Foo");
                if (ret)
                {
                    return(0);
                }
            }

            return(1);
        }
        public static int MainMethod(string[] args)
        {
            dynamic d = 1;
            dynamic t = new Test();

            try
            {
                int i = t.Bar().Foo(d);
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                bool ret = ErrorVerifier.Verify(ErrorMessageId.NoSuchMember, ex.Message, "Test", "Bar");
                if (ret)
                {
                    return(0);
                }
            }

            return(1);
        }
Пример #17
0
        public static int MainMethod()
        {
            dynamic dy  = new MemberClass();
            MyTest  mt  = new MyTest();
            dynamic d   = mt;
            decimal dec = 0M;

            try
            {
                float result = (float)dy.Method_ReturnsFloatNegConstraint <Test, dynamic, DerivedMyTest>(null, d, d, ref dec);
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                if (!ErrorVerifier.Verify(ErrorMessageId.GenericConstraintNotSatisfiedRefType, e.Message, "MemberClass.Method_ReturnsFloatNegConstraint<T,U,V>(T, object, U, ref decimal)", "I", "U", "object"))
                {
                    return(1);
                }
            }

            return(0);
        }
Пример #18
0
        public static int MainMethod()
        {
            dynamic c = new C();

            try
            {
                c.E += c;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                // incorrect error message
                //  resolution is 'By design' so this error message should be use again
                // new error message
                if (ErrorVerifier.Verify(ErrorMessageId.NoImplicitConv, e.Message, "C", "Dele"))
                {
                    return(0);
                }
            }

            return(1);
        }
Пример #19
0
        public Test()
        {
            dynamic dy = new MemberClass();

            try
            {
                // public for struct
                short?[] result = dy.Property_shortNullArr; //protected, should have exception
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                if (ErrorVerifier.Verify(ErrorMessageId.InaccessibleGetter, e.Message, "MemberClass.Property_shortNullArr"))
                {
                    Test.Return = 0;
                }
                else
                {
                    Test.Return = 1;
                }
            }
        }
Пример #20
0
        public static int MainMethod()
        {
            bool    ret = true;
            dynamic d   = new Test();

            try
            {
                long l = d;
                ret &= false;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                ret &= ErrorVerifier.Verify(ErrorMessageId.NoImplicitConv, e.Message, "Test", "long");
            }

            dynamic d1 = new int[0];
            Test    t  = (Test)d1;

            ret &= t.Field == 10;
            return(ret ? 0 : 1);
        }
Пример #21
0
        public static int MainMethod()
        {
            dynamic v1     = new Variance <Animal>();
            int     result = 0;

            try
            {
                result = C.Bar(v1);
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                bool ret = ErrorVerifier.Verify(ErrorMessageId.AmbigCall, ex.Message, "C.Bar(iVariance<Tiger>)", "C.Bar(iVariance<Bear>)");
                if (ret)
                {
                    return(0);
                }
            }

            //System.Console.WriteLine(result);
            return(1);
        }
        public static int MainMethod()
        {
            int     x = 3;
            int     y = 2;
            dynamic p = new Parent();

            try
            {
                p.Foo(1, 2, 3, 4, x: x, y: y);
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                bool ret = ErrorVerifier.Verify(ErrorMessageId.NamedArgumentUsedInPositional, e.Message, "x");
                if (ret)
                {
                    return(0);
                }
            }

            return(1);
        }
Пример #23
0
        public static int MainMethod(string[] args)
        {
            dynamic d     = new ContraVar <Tiger>();
            int     error = 0;

            try
            {
                d.Foo();
                error++;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                if (!ErrorVerifier.Verify(ErrorMessageId.NoSuchMember, ex.Message, "ContraVar<Tiger>", "Foo"))
                {
                    error++;
                }
            }

            try
            {
                var x = Helper.Cast <IF <Animal> >(d);
                error++;
            }
            catch (InvalidCastException ex)
            {
            }

            var y = Helper.Cast <IF <Tiger> >(d);

            try
            {
                var z = ((IF <Animal>)d).Foo(new Animal());
                error++;
            }
            catch (InvalidCastException ex)
            {
            }

            return(error);
        }
        public static int MainMethod(string[] args)
        {
            dynamic d      = new C();
            int     result = 0;
            int     error  = 0;

            try
            {
                result = d.Foo();
                System.Console.WriteLine("Should have thrown out runtime exception!");
                error++;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                if (!ErrorVerifier.Verify(ErrorMessageId.NoSuchMember, ex.Message, "C", "Foo"))
                {
                    error++;
                }
            }

            return(error);
        }
Пример #25
0
        public static int MainMethod()
        {
            dynamic dy = new MemberClass();

            ulong[] array = null;
            dy.Property_ulongArr = new ulong[]
            {
                0, 1
            }

            ;
#if MS
            array = new ulong[] { (ulong)dy.Property_ulong };
 #else
            try
            {
                array = dy.Property_ulongArr;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                if (ErrorVerifier.Verify(ErrorMessageId.InaccessibleGetter, e.Message, "MemberClass.Property_ulongArr"))
                {
                    return(0);
                }
                else
                {
                    System.Console.WriteLine(e);
                    return(1);
                }
            }
#endif

            // different case actually
            if (array.Length == 2 && array[0] == 0 && array[1] == 1)
            {
                return(0);
            }
            return(1);
        }
        public static int MainMethod()
        {
            MemberClass mc = new MemberClass();
            dynamic     dy = mc;

            dy.Property_shortNull = (short)-1;
            try
            {
                lock (dy.Property_shortNull)
                {
                }
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                if (ErrorVerifier.Verify(ErrorMessageId.BadProtectedAccess, e.Message, "MemberClass.Property_shortNull", "MemberClass", "Test"))
                {
                    return(0);
                }
            }

            return(1);
        }
Пример #27
0
        public static int MainMethod(string[] args)
        {
            dynamic d      = new C();
            int     result = 0;
            int     error  = 0;

            try
            {
                result = d.Foo <int>();
                System.Console.WriteLine("Should have thrown out runtime exception!");
                error++;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                if (!ErrorVerifier.Verify(ErrorMessageId.HasNoTypeVars, ex.Message, "C.Foo()", ErrorVerifier.GetErrorElement(ErrorElementId.SK_METHOD)))
                {
                    error++;
                }
            }

            return(error);
        }
Пример #28
0
        public static int MainMethod(string[] args)
        {
            MyClass mc = new MyClass();
            dynamic d  = mc[3, 4];

            if ((int)d != 4 || MyClass.Status != 1)
            {
                return(1);
            }
            try
            {
                mc[3, d] = 5;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e)
            {
                if (ErrorVerifier.Verify(ErrorMessageId.AssgReadonlyProp, e.Message, "Test.MyClass.this[int, object]"))
                {
                    return(0);
                }
            }

            return(1);
        }
        public static int MainMethod(string[] args)
        {
            dynamic d     = new C();
            int     error = 0;

            try
            {
                d.Prop = 1;
                System.Console.WriteLine("Should have thrown out runtime exception!");
                error++;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                if (!ErrorVerifier.Verify(ErrorMessageId.NoSuchMember, ex.Message, "C", "Prop"))
                {
                    error++;
                }
            }

            var x = Helper.Cast <IF1>(d);

            return(error);
        }
        public static int MainMethod(string[] args)
        {
            dynamic d      = new C();
            int     result = 0;
            int     error  = 0;

            try
            {
                result = d.Foo();
                error++;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex)
            {
                if (!ErrorVerifier.Verify(ErrorMessageId.NoSuchMember, ex.Message, "C", "Foo"))
                {
                    error++;
                }
            }

            var x = Helper.Cast <IF3>(d);

            return(error);
        }