* RemotingProxy.cs: Return message check moved to RealProxy.
authorLluis Sanchez <lluis@novell.com>
Thu, 11 Sep 2003 23:41:51 +0000 (23:41 -0000)
committerLluis Sanchez <lluis@novell.com>
Thu, 11 Sep 2003 23:41:51 +0000 (23:41 -0000)
* RealProxy.cs: Added return message check and propagation of output
  parameter values.

svn path=/trunk/mcs/; revision=18041

mcs/class/corlib/System.Runtime.Remoting.Proxies/ChangeLog
mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs
mcs/class/corlib/System.Runtime.Remoting.Proxies/RemotingProxy.cs

index 9f85697f82bb0393877b968627bc6de3f0ff6995..437c9f94bab54f212f97dfa75974d04d676ee54d 100644 (file)
@@ -1,3 +1,9 @@
+2003-09-11  Lluis Sanchez Gual <lluis@ximian.com>
+
+       * RemotingProxy.cs: Return message check moved to RealProxy.
+       * RealProxy.cs: Added return message check and propagation of output
+         parameter values.
+
 2003-08-25  Lluis Sanchez Gual <lluis@ximian.com>
 
        * RemotingProxy.cs: Use CallType property to check the type of
index 969680f3a2bcc99b3f96213fd4f06e9364a3f8ce..c016a6783b926b348e4222fe9f1651fdd2394d76 100644 (file)
@@ -10,6 +10,7 @@
 //
 
 using System;
+using System.Reflection;
 using System.Runtime.Remoting;
 using System.Runtime.Remoting.Messaging;
 using System.Runtime.Remoting.Activation;
@@ -91,11 +92,15 @@ namespace System.Runtime.Remoting.Proxies
 
                        IMethodReturnMessage res_msg = (IMethodReturnMessage)rp.Invoke (msg);
 
-                       if (res_msg.LogicalCallContext != null)
-                               CallContext.SetCurrentCallContext (res_msg.LogicalCallContext);
+                       if (!(res_msg is IConstructionReturnMessage) && (res_msg.Exception == null))
+                               out_args = ProcessResponse (res_msg, mMsg);
+                       else
+                               out_args = res_msg.OutArgs;
+
+                       if (res_msg.LogicalCallContext != null && res_msg.LogicalCallContext.HasInfo)
+                               CallContext.UpdateCurrentCallContext (res_msg.LogicalCallContext);
 
                        exc = res_msg.Exception;
-                       out_args = res_msg.OutArgs;
 
                        // todo: remove throw exception from the runtime invoke
                        if (null != exc) 
@@ -134,5 +139,53 @@ namespace System.Runtime.Remoting.Proxies
                {
                        return _server;
                }
+
+               static object[] ProcessResponse (IMethodReturnMessage mrm, IMethodCallMessage call)
+               {
+                       // Check return type
+
+                       MethodInfo mi = (MethodInfo) mrm.MethodBase;
+                       if (mrm.ReturnValue != null && !mi.ReturnType.IsInstanceOfType (mrm.ReturnValue))
+                               throw new RemotingException ("Return value has an invalid type");
+
+                       // Check out parameters
+
+                       if (mrm.OutArgCount > 0)
+                       {
+                               ParameterInfo[] parameters = mi.GetParameters();
+                               int no = 0;
+                               foreach (ParameterInfo par in parameters)
+                                       if (par.ParameterType.IsByRef) no++;
+                               
+                               object[] outArgs = new object [no];
+                               int narg = 0;
+                               int nout = 0;
+       
+                               foreach (ParameterInfo par in parameters)
+                               {
+                                       if (par.IsOut && !par.ParameterType.IsByRef)
+                                       {
+                                               // Special marshalling required
+                                               
+                                               object outArg = mrm.GetOutArg (nout++);
+                                               if (outArg != null) {
+                                                       object local = call.GetArg (par.Position);
+                                                       if (local == null) throw new RemotingException ("Unexpected null value in local out parameter");
+                                                       RemotingServices.UpdateOutArgObject (par, local, outArg);
+                                               }
+                                       }
+                                       else if (par.ParameterType.IsByRef)
+                                       {
+                                               object outArg = mrm.GetOutArg (nout++);
+                                               if (outArg != null && !par.ParameterType.IsInstanceOfType (outArg))
+                                                       throw new RemotingException ("Return argument '" + par.Name + "' has an invalid type");
+                                               outArgs [narg++] = outArg;
+                                       }
+                               }
+                               return outArgs;
+                       }
+                       else
+                               return new object [0];
+               }
        }
 }
index 73efcda92093cc15f5189fc1299efec3ef493642..f8fd586211f1a964ea0436bc23574d0a7ab3deeb 100644 (file)
@@ -86,9 +86,6 @@ namespace System.Runtime.Remoting.Proxies
 
                        _objectIdentity.NotifyClientDynamicSinks (false, request, true, false);
 
-                       if (!(response is IConstructionReturnMessage))
-                               CheckResponse (response, request);
-
                        return response;
                }
 
@@ -130,29 +127,5 @@ namespace System.Runtime.Remoting.Proxies
                        _ctorCall.CopyFrom (request);
                        return ActivationServices.Activate (this, _ctorCall);
                }
-
-               void CheckResponse (IMessage response, IMessage call)
-               {
-                       IMethodReturnMessage mrm = (IMethodReturnMessage) response;
-                       if (mrm.Exception != null) return;
-
-                       // Check return type
-
-                       MethodInfo mi = (MethodInfo) mrm.MethodBase;
-                       if (mrm.ReturnValue != null && !mi.ReturnType.IsInstanceOfType (mrm.ReturnValue))
-                               throw new RemotingException ("Return value has an invalid type");
-
-                       // Check out parameters
-
-                       ParameterInfo[] parameters = mi.GetParameters();
-                       int narg = 0;
-
-                       foreach (ParameterInfo pi in parameters)
-                               if(pi.ParameterType.IsByRef) {
-                                       object pval = mrm.GetOutArg (narg++);
-                                       if (pval != null && !pi.ParameterType.IsInstanceOfType (pval))
-                                               throw new RemotingException ("Return argument has an invalid type");
-                               }
-               }
        }
 }