public static int MainMethod() { dynamic x = new B(); try { x.Foo(); // Unexpected NullReferenceException } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { if (ErrorVerifier.Verify(ErrorMessageId.CantInferMethTypeArgs, e.Message, "B.Foo<T>()")) { return(0); } } return(1); }
public static int MainMethod() { dynamic dy = new MemberClass(); try { MyEnum?[] result = dy.Property_MyEnumNullArr ?? new MyEnum?[1]; //private, should have exception } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { if (ErrorVerifier.Verify(ErrorMessageId.InaccessibleGetter, e.Message, "MemberClass.Property_MyEnumNullArr")) { return(0); } } return(1); }
public static int MainMethod() { dynamic y = new A(); try { var x = y(); } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex) { bool ret = ErrorVerifier.Verify(RuntimeErrorId.BindInvokeFailedNonDelegate, ex.Message); if (ret) { return(0); } } return(1); }
int I.Foo(dynamic o) { bool ret = true; try { o.Bar(); //This should fail at runtime } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex) { ret = ErrorVerifier.Verify(ErrorMessageId.NoSuchMember, ex.Message, "object", "Bar"); if (ret) { return(0); //it means we did the right thing } } return(1); }
public static int MainMethod(string[] args) { int x = 3; dynamic d = x.Foo(); try { d.AnotherFoo(); //This will throw at runtime } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { if (ErrorVerifier.Verify(ErrorMessageId.NoSuchMember, e.Message, "int", "AnotherFoo")) { return(0); } } return(1); }
public static int MainMethod() { dynamic p = new Parent(); try { p.Foo(3, "test"); } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { bool ret = ErrorVerifier.Verify(ErrorMessageId.BadArgTypes, e.Message, "Parent.Foo(string, int?)"); if (ret) { return(0); } } return(1); }
public static int MainMethod() { dynamic dy = new MemberClass(); dynamic t = new Test(); try { dynamic result = dy.Method_ReturnsUNegConstraint <Test>(t); } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { if (ErrorVerifier.Verify(ErrorMessageId.GenericConstraintNotSatisfiedRefType, e.Message, "MemberClass.Method_ReturnsUNegConstraint<U>(U)", "C", "U", "Test")) { return(0); } } return(1); }
public static int MainMethod(string[] args) { MyClass mc = new MyClass(); try { //This should not compile if the return type of Foo is not dynamic mc.Foo().Bar(); } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { if (ErrorVerifier.Verify(ErrorMessageId.NoSuchMember, e.Message, "object", "Bar")) { return(0); } } return(1); }
public static int MainMethod() { Test t = new Test(); try { t.TestProperty = null; //protected, should have exception return(1); } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { if (ErrorVerifier.Verify(ErrorMessageId.InaccessibleSetter, e.Message, "MemberClass.Property_boolNull")) { return(0); } } return(1); }
private static int TestMethod <T>() { dynamic dy = new MemberClass(); dy.Property_shortArr = new short[2]; try { short[] result = dy.Property_shortArr; // protected } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { if (ErrorVerifier.Verify(ErrorMessageId.InaccessibleGetter, e.Message, "MemberClass.Property_shortArr")) { return(0); } } return(1); }
public static int MainMethod() { string x = "string"; dynamic y = 7; try { C.M(x, y); } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { if (ErrorVerifier.Verify(ErrorMessageId.CantInferMethTypeArgs, e.Message, "C.M<T>(T, T)")) { return(0); } } return(1); }
public static int MainMethod(string[] args) { Foo f = new Foo(); dynamic d = "foo"; try { f.Method(d); } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { if (ErrorVerifier.Verify(ErrorMessageId.BadArgTypes, e.Message, "Foo.Method(params int[])")) { return(0); } } return(1); }
public static int MainMethod() { dynamic p = new Derived(); try { p.Foo(); } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { bool ret = ErrorVerifier.Verify(ErrorMessageId.BadArgCount, e.Message, "Foo", "0"); if (ret) { return(0); } } return(1); }
public static int MainMethod(string[] ars) { Test t = new Test(); dynamic d = t; try { d.field += new MyDel(Method); } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { if (ErrorVerifier.Verify(ErrorMessageId.BadBinaryOps, e.Message, "+=", "int", "Test.MyDel")) { return(0); } } return(1); }
public static int MainMethod() { dynamic tf = new Derived(); try { tf.Foo(Invalid: 2); } 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() { dynamic p = new Parent(); try { p.Foo(); } 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() { int result = 0; dynamic v11 = new Variance<uint>(); try { result++; iVariance<uint?> v12 = v11; } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException ex) { bool ret = ErrorVerifier.Verify(ErrorMessageId.NoImplicitConvCast, ex.Message, "Variance<uint>", "iVariance<uint?>"); if (ret) { result--; } } Variance<uint> v21 = new Variance<uint>(); try { result++; dynamic v22 = (iVariance<uint?>)v21; } catch (System.InvalidCastException) { result--; } dynamic v31 = new Variance<uint>(); try { result++; dynamic v32 = (iVariance<uint?>)v31; } catch (System.InvalidCastException) { result--; } return result; }
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() { dynamic f2 = (Foo2)Bar2; even += Bar; try { even += f2; } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { bool ret = ErrorVerifier.Verify(ErrorMessageId.NoImplicitConv, e.Message, "Foo2", "Foo"); if (ret) { return(0); } } return(1); }
public static int MainMethod() { dynamic c = new C(); int result = 0; try { c.E += null; result += 1; } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { if (ErrorVerifier.Verify(ErrorMessageId.AmbigBinaryOps, e.Message, "+=", "<null>", "<null>")) { return(1); } } return(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) { 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); }
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); }
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[] 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); }
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); }
public static int MainMethod() { Derived p = null; dynamic tf = p; try { int result = (int)tf; } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { bool ret = ErrorVerifier.Verify(ErrorMessageId.ValueCantBeNull, e.Message, "int"); 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) { // string s = "Test"; try { using (dynamic d = new MyClass()) { //<-this should work?! } } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) { if (ErrorVerifier.Verify(ErrorMessageId.NoImplicitConvCast, e.Message, "Test.MyClass", "System.IDisposable")) { return(0); } } return(1); }