linux-packaging-mono/mcs/tests/dtest-error-02.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

60 lines
920 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 != "`A.N.Foo()' is inaccessible due to its protection level")
return 2;
}
try {
var x = d.Property;
return 3;
} catch (RuntimeBinderException e) {
if (e.Message != "`A.N.Property.get' is inaccessible due to its protection level")
return 4;
}
try {
var x = d [4];
return 5;
} catch (RuntimeBinderException e) {
if (e.Message != "`A.N.this[int]' is inaccessible due to its protection level")
return 6;
}
return 0;
}
}