* RealProxy.cs: Fixed support for [out] parameters in async calls.
authorLluis Sanchez <lluis@novell.com>
Tue, 7 Oct 2003 14:39:08 +0000 (14:39 -0000)
committerLluis Sanchez <lluis@novell.com>
Tue, 7 Oct 2003 14:39:08 +0000 (14:39 -0000)
svn path=/trunk/mcs/; revision=18707

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

index 437c9f94bab54f212f97dfa75974d04d676ee54d..2d8e5e3941fcda17982207365e6351616d1d29fd 100644 (file)
@@ -1,3 +1,7 @@
+2003-10-07  Lluis Sanchez Gual  <lluis@ximian.com>
+
+       * RealProxy.cs: Fixed support for [out] parameters in async calls.
+
 2003-09-11  Lluis Sanchez Gual <lluis@ximian.com>
 
        * RemotingProxy.cs: Return message check moved to RealProxy.
index c016a6783b926b348e4222fe9f1651fdd2394d76..d0424d886a062e716a2aa9ece1a37b94c9cde129 100644 (file)
@@ -89,22 +89,34 @@ namespace System.Runtime.Remoting.Proxies
                {
                        MonoMethodMessage mMsg = (MonoMethodMessage) msg;
                        mMsg.LogicalCallContext = CallContext.CreateLogicalCallContext();
+                       
+                       if (mMsg.CallType == CallType.BeginInvoke) 
+                               mMsg.AsyncResult.CallMessage = mMsg;    // TODO: do this in the runtime
 
                        IMethodReturnMessage res_msg = (IMethodReturnMessage)rp.Invoke (msg);
 
-                       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;
 
                        // todo: remove throw exception from the runtime invoke
-                       if (null != exc) 
+                       if (null != exc) {
+                               out_args = res_msg.OutArgs;
                                throw exc.FixRemotingException();
+                       }
+                       else if (res_msg is IConstructionReturnMessage || mMsg.CallType == CallType.BeginInvoke) {
+                               out_args = res_msg.OutArgs;
+                       }
+                       else if (mMsg.CallType == CallType.Sync) {
+                               out_args = ProcessResponse (res_msg, mMsg);
+                       }
+                       else if (mMsg.CallType == CallType.EndInvoke) {
+                               out_args = ProcessResponse (res_msg, mMsg.AsyncResult.CallMessage);
+                       }
+                       else {
+                               out_args = res_msg.OutArgs;
+                       }
 
                        return res_msg.ReturnValue;
                }
@@ -144,7 +156,7 @@ namespace System.Runtime.Remoting.Proxies
                {
                        // Check return type
 
-                       MethodInfo mi = (MethodInfo) mrm.MethodBase;
+                       MethodInfo mi = (MethodInfo) call.MethodBase;
                        if (mrm.ReturnValue != null && !mi.ReturnType.IsInstanceOfType (mrm.ReturnValue))
                                throw new RemotingException ("Return value has an invalid type");
 
@@ -170,7 +182,7 @@ namespace System.Runtime.Remoting.Proxies
                                                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");
+                                                       if (local == null) throw new RemotingException ("Unexpected null value in local out parameter '" + par.Position + " " + par.Name + "'");
                                                        RemotingServices.UpdateOutArgObject (par, local, outArg);
                                                }
                                        }
@@ -178,7 +190,9 @@ namespace System.Runtime.Remoting.Proxies
                                        {
                                                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;
                                        }
                                }