Merge pull request #4434 from BrzVlad/fix-unload-hang
[mono.git] / mcs / tests / dtest-error-02.cs
1 using System;
2 using Microsoft.CSharp.RuntimeBinder;
3
4 class A
5 {
6         private class N
7         {
8                 public void Foo ()
9                 {
10                 }
11
12                 public int Property { get; set; }
13                 
14                 string this [int index] {
15                         get {
16                                 return "x";
17                         }
18                 }
19         }
20         
21         public static dynamic Factory ()
22         {
23                 return new N ();
24         }
25 }
26
27 public class Test
28 {
29         public static int Main ()
30         {
31                 dynamic d = A.Factory ();
32                 
33                 try {
34                         d.Foo ();
35                         return 1;
36                 } catch (RuntimeBinderException e) {
37                         if (e.Message != "'object' does not contain a definition for 'Foo'")
38                                 return 2;
39                 }
40                 
41                 try {
42                         var x = d.Property;
43                         return 3;
44                 } catch (RuntimeBinderException e) {
45                         if (e.Message != "'object' does not contain a definition for 'Property'")
46                                 return 4;
47                 }
48
49                 try {
50                         var x = d [4];
51                         return 5;
52                 } catch (RuntimeBinderException e) {
53                         if (e.Message != "Cannot apply indexing with [] to an expression of type 'object'")
54                                 return 6;
55                 }
56
57                 return 0;
58         }
59 }