[loader] Init MonoClass:sizes.element_size lazily (Fixes #43563) (#5559)
[mono.git] / mono / tests / remoting4.cs
index 7eb6a48fbe1a056886589cd88196022a0b374c59..e26edf524907691c5e61b8599ef67fcaa0786905 100644 (file)
@@ -1,4 +1,4 @@
-using System;\r
+using System;
 using System.Threading;
 using System.Runtime.InteropServices;
 using System.Runtime.Remoting;
@@ -6,25 +6,25 @@ using System.Runtime.Remoting.Messaging;
 using System.Runtime.Remoting.Proxies;
 using System.Runtime.Remoting.Channels;
 using System.Runtime.Serialization;
-\r
-namespace RemotingTest\r
-{\r
-       class MyProxy : RealProxy \r
+
+namespace RemotingTest
+{
+       class MyProxy : RealProxy 
        {
                readonly MarshalByRefObject target;
 
-               public MyProxy (MarshalByRefObject target) : base (target.GetType()) \r
+               public MyProxy (MarshalByRefObject target) : base (target.GetType()) 
                {
                        this.target = target;
                }
 
-               public override IMessage Invoke (IMessage request) \r
+               public override IMessage Invoke (IMessage request) 
                {
                        IMethodCallMessage call = (IMethodCallMessage)request;
                        Console.WriteLine ("Invoke " + call.MethodName);
 
                        Console.Write ("ARGS(");
-                       for (int i = 0; i < call.ArgCount; i++) \r
+                       for (int i = 0; i < call.ArgCount; i++) 
                        {
                                if (i != 0)
                                        Console.Write (", ");
@@ -33,7 +33,7 @@ namespace RemotingTest
                        }
                        Console.WriteLine (")");
                        Console.Write ("INARGS(");
-                       for (int i = 0; i < call.InArgCount; i++) \r
+                       for (int i = 0; i < call.InArgCount; i++) 
                        {
                                if (i != 0)
                                        Console.Write (", ");
@@ -45,7 +45,7 @@ namespace RemotingTest
                        IMethodReturnMessage res = RemotingServices.ExecuteMessage (target, call);
 
                        Console.Write ("RESARGS(");
-                       for (int i = 0; i < res.ArgCount; i++) \r
+                       for (int i = 0; i < res.ArgCount; i++) 
                        {
                                if (i != 0)
                                        Console.Write (", ");
@@ -55,7 +55,7 @@ namespace RemotingTest
                        Console.WriteLine (")");                
                
                        Console.Write ("RESOUTARGS(");
-                       for (int i = 0; i < res.OutArgCount; i++) \r
+                       for (int i = 0; i < res.OutArgCount; i++) 
                        {
                                if (i != 0)
                                        Console.Write (", ");
@@ -68,57 +68,65 @@ namespace RemotingTest
                }
        }
 
-       class R2 \r
+       class R2 
        {
                string sTest;
-               public R2() \r
+               public R2() 
                {
                        sTest = "R2";
                }
 
-               public void Print() \r
+               public void Print() 
                {
                        Console.WriteLine(sTest);
                }
        }
 
        [Serializable]
-       class R2_MBV\r
+       class R2_MBV
        {
                string sTest;
-               public R2_MBV() \r
+               public R2_MBV() 
                {
                        sTest = "R2";
                }
 
-               public string Data\r
-               {\r
-                       get \r
+               public string Data
+               {
+                       get 
                        {
                                return sTest;
-                       }\r
+                       }
+               }
+       }
+
+       interface GenericIFace {
+               T Foo <T> ();
+       }
+
+       class R1 : MarshalByRefObject, GenericIFace
+       {
+               public R2 TestMBV() {
+                       return new R2();
+               }
+
+               public T Foo <T> () {
+                       return default (T);
                }
        }
-\r
-       class R1 : MarshalByRefObject \r
+
+       class Class1
        {
-               public R2 TestMBV() {\r
-                       return new R2();\r
-               }\r
-       }\r
-\r
-       class Class1\r
-       {\r
-               static int Main(string[] args)\r
-               {\r
-                       Console.WriteLine("test " + AppDomain.CurrentDomain.FriendlyName);\r
-                       AppDomain app2 = AppDomain.CreateDomain("2");\r
-\r
+               static int Main(string[] args)
+               {
+                       Console.WriteLine("test " + AppDomain.CurrentDomain.FriendlyName);
+                       AppDomain app2 = AppDomain.CreateDomain("2");
+
                        if (!RemotingServices.IsTransparentProxy(app2)) 
                                return 1;                               
 
-                       ObjectHandle o = AppDomain.CurrentDomain.CreateInstance(typeof(R1).Assembly.FullName, typeof(R1).FullName);\r
-                       R1 myobj = (R1) o.Unwrap();\r
+                       ObjectHandle o = AppDomain.CurrentDomain.CreateInstance(typeof(R1).Assembly.FullName, typeof(R1).FullName);
+                       R1 myobj = (R1) o.Unwrap();
                        
                        // should not be a proxy in our domain..
                        if (RemotingServices.IsTransparentProxy(myobj)) 
@@ -127,15 +135,15 @@ namespace RemotingTest
                                return 2;                               
                        }
 
-                       o = app2.CreateInstance(typeof(R1).Assembly.FullName, typeof(R1).FullName);\r
-\r
-                       Console.WriteLine("type: " + o.GetType().ToString());\r
+                       o = app2.CreateInstance(typeof(R1).Assembly.FullName, typeof(R1).FullName);
+
+                       Console.WriteLine("type: " + o.GetType().ToString());
 
-                       myobj = (R1) o.Unwrap();\r
+                       myobj = (R1) o.Unwrap();
                        if (!RemotingServices.IsTransparentProxy(myobj))
                                return 3;
-\r
-                       Console.WriteLine("unwrapped type: " + myobj.GetType().ToString());\r
+
+                       Console.WriteLine("unwrapped type: " + myobj.GetType().ToString());
 
                        R2 r2 = null;
                        bool bSerExc = false;
@@ -152,9 +160,27 @@ namespace RemotingTest
 
                        if (!bSerExc)
                                return 4;
-       \r
+
+                       // Test generic virtual interface methods on proxies
+
+                       o = app2.CreateInstance(typeof(R1).Assembly.FullName, typeof(R1).FullName);
+                       myobj = (R1) o.Unwrap();
+
+                       GenericIFace iface = (GenericIFace)myobj;
+                       if (iface.Foo <int> () != 0)
+                               return 5;
+                       if (iface.Foo <string> () != null)
+                               return 6;
+
+                       // Test type identity (#504886, comment #10 ff.)
+
+                       if (typeof (R1) != myobj.GetType ())
+                               return 7;
+       
+                       AppDomain.Unload (app2);
+
                        Console.WriteLine("test-ok");
                        return 0;
-               }\r
-       }\r
-}\r
+               }
+       }
+}