blob: 58578fe3b50ab5351a159c1babe4262593ee6f06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
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;
}
}
|