linux-packaging-mono/mcs/tests/dtest-error-02.cs
Xamarin Public Jenkins (auto-signing) 966bba02bb Imported Upstream version 5.2.0.175
Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
2017-06-07 13:16:24 +00:00

60 lines
908 B
C#

using System;
using Microsoft.CSharp.RuntimeBinder;
class A
{
private class N
{
public void Foo ()
{
}
public int Property { get; set; }
string this [int index] {
get {
return "x";
}
}
}
public static dynamic Factory ()
{
return new N ();
}
}
public class Test
{
public static int Main ()
{
dynamic d = A.Factory ();
try {
d.Foo ();
return 1;
} catch (RuntimeBinderException e) {
if (e.Message != "'object' does not contain a definition for 'Foo'")
return 2;
}
try {
var x = d.Property;
return 3;
} catch (RuntimeBinderException e) {
if (e.Message != "'object' does not contain a definition for 'Property'")
return 4;
}
try {
var x = d [4];
return 5;
} catch (RuntimeBinderException e) {
if (e.Message != "Cannot apply indexing with [] to an expression of type 'object'")
return 6;
}
return 0;
}
}