Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / generic-marshalbyref.2.cs
1 using System;
2
3 static class Program
4 {
5     static int Main()
6     {
7             DocumentForm<object> browseForm = new DocumentForm<object> ();
8             if (browseForm.DoInit () != 248)
9                     return 1;
10
11         var domain = AppDomain.CreateDomain ("foo");
12         var engine = Engine.CreateRemote (domain);
13
14         if (engine.GetDomainName<object> () != "foo")
15                         return 2;
16
17             return 0;
18     }
19 }
20
21 public abstract class EntityBase
22 {
23 }
24
25 public class GenEntity<T> : EntityBase
26 {
27 }
28
29 class DocumentForm<T>
30 {
31         internal int DoInit()
32         {
33                 var g = new Grid1<GenEntity<T>>(123);
34                 var g2 = new Grid2<GenEntity<T>>(123);
35                 return g.num + g2.num;
36         }
37 }
38
39 public class Grid1<TEntity> : MarshalByRefObject
40 {
41         public int num;
42
43         public Grid1 (int i)
44         {
45                 num = i + 1;
46         }
47 }
48
49 public class Grid2<TEntity> : MarshalByRefObject where TEntity : EntityBase, new()
50 {
51         public int num;
52
53         public Grid2 (int i)
54         {
55                 num = i + 1;
56         }
57 }
58
59 public class Engine : MarshalByRefObject
60 {
61     public Engine ()
62     {
63     }
64
65     public string GetDomainName<T> ()
66     {
67         return AppDomain.CurrentDomain.FriendlyName;
68     }
69
70     public string GetDomainName ()
71     {
72         return AppDomain.CurrentDomain.FriendlyName;
73     }
74
75     public static Engine CreateRemote (AppDomain domain)
76     {
77         return (Engine) domain.CreateInstanceAndUnwrap (
78             typeof (Engine).Assembly.FullName,
79             typeof (Engine).FullName);
80     }
81 }