Imported Upstream version 3.12.0

Former-commit-id: cf92446697332992ec36726e78eb8703e1f259d7
This commit is contained in:
Jo Shields
2015-01-13 10:44:36 +00:00
parent 8b9b85e7f5
commit 181b81b4a4
659 changed files with 12743 additions and 16300 deletions

View File

@ -234,6 +234,9 @@ namespace System.ServiceModel.Description
foreach (var fd in od.Faults)
o.FaultContractInfos.Add (new FaultContractInfo (fd.Action, fd.DetailType));
o.BeginMethod = od.BeginMethod;
o.EndMethod = od.EndMethod;
// FIXME: at initialization time it does not seem to
// fill default formatter. It should be filled after
// applying all behaviors. (Tthat causes regression, so

View File

@ -237,7 +237,6 @@ namespace System.ServiceModel.Description
for (int i = 0; i < contractMethods.Length; ++i)
{
MethodInfo mi = contractMethods [i];
OperationContractAttribute oca = GetOperationContractAttribute (mi);
if (oca == null)
@ -253,7 +252,7 @@ namespace System.ServiceModel.Description
if (GetOperationContractAttribute (end) != null)
throw new InvalidOperationException ("Async 'End' method must not have OperationContractAttribute. It is automatically treated as the EndMethod of the corresponding 'Begin' method.");
}
OperationDescription od = GetOrCreateOperation (cd, mi, serviceMethods [i], oca, end != null ? end.ReturnType : null, isCallback, givenServiceType);
OperationDescription od = GetOrCreateOperation (cd, mi, serviceMethods [i], oca, end, isCallback, givenServiceType);
if (end != null)
od.EndMethod = end;
}
@ -286,7 +285,7 @@ namespace System.ServiceModel.Description
static OperationDescription GetOrCreateOperation (
ContractDescription cd, MethodInfo mi, MethodInfo serviceMethod,
OperationContractAttribute oca,
Type asyncReturnType,
MethodInfo endMethod,
bool isCallback,
Type givenServiceType)
{
@ -311,7 +310,8 @@ namespace System.ServiceModel.Description
od.Messages.Add (GetMessage (od, mi, oca, true, isCallback, null));
if (!od.IsOneWay) {
var md = GetMessage (od, mi, oca, false, isCallback, asyncReturnType);
var asyncReturnType = endMethod != null ? endMethod.ReturnType : null;
var md = GetMessage (od, endMethod ?? mi, oca, false, isCallback, asyncReturnType);
od.Messages.Add (md);
var mpa = mi.ReturnParameter.GetCustomAttribute<MessageParameterAttribute> (true);
if (mpa != null) {
@ -522,8 +522,12 @@ namespace System.ServiceModel.Description
int index = 0;
foreach (ParameterInfo pi in plist) {
// AsyncCallback and state are extraneous.
if (oca.AsyncPattern && pi.Position == plist.Length - 2)
break;
if (oca.AsyncPattern) {
if (isRequest && pi.Position == plist.Length - 2)
break;
if (!isRequest && pi.Position == plist.Length - 1)
break;
}
// They are ignored:
// - out parameter in request

View File

@ -281,9 +281,10 @@ namespace System.ServiceModel.Dispatcher
}
else {
int index = ParamsOffset (md.Body);
foreach (ParameterInfo pi in requestMethodParams)
foreach (ParameterInfo pi in replyMethodParams) {
if (pi.IsOut || pi.ParameterType.IsByRef)
parameters [pi.Position] = parts [index++];
}
return HasReturnValue (md.Body) ? parts [0] : null;
}
}

View File

@ -389,7 +389,7 @@ namespace System.ServiceModel
var od = cd.Operations.Find (methodName);
if (od == null)
throw new ArgumentException (String.Format ("Operation '{0}' not found in the service contract '{1}' in namespace '{2}'", methodName, cd.Name, cd.Namespace));
return Inner.Process (od.SyncMethod, methodName, args);
return Inner.Process (od.SyncMethod, methodName, args, OperationContext.Current);
}
protected IAsyncResult BeginInvoke (string methodName, object [] args, AsyncCallback callback, object state)

View File

@ -108,8 +108,7 @@ namespace System.ServiceModel
// sync invocation
pl = new object [inmsg.MethodBase.GetParameters ().Length];
Array.Copy (inmsg.Args, pl, inmsg.ArgCount);
channel.Context = OperationContext.Current;
ret = channel.Process (inmsg.MethodBase, od.Name, pl);
ret = channel.Process (inmsg.MethodBase, od.Name, pl, OperationContext.Current);
method = od.SyncMethod;
} else if (inmsg.MethodBase.Equals (od.BeginMethod)) {
// async invocation

View File

@ -46,9 +46,7 @@ namespace System.ServiceModel.MonoInternal
{
ContractDescription Contract { get; }
OperationContext Context { set; }
object Process (MethodBase method, string operationName, object [] parameters);
object Process (MethodBase method, string operationName, object [] parameters, OperationContext context);
IAsyncResult BeginProcess (MethodBase method, string operationName, object [] parameters, AsyncCallback callback, object asyncState);
@ -69,12 +67,11 @@ namespace System.ServiceModel.MonoInternal
TimeSpan default_open_timeout, default_close_timeout;
IChannel channel;
IChannelFactory factory;
OperationContext context;
#region delegates
readonly ProcessDelegate _processDelegate;
delegate object ProcessDelegate (MethodBase method, string operationName, object [] parameters);
delegate object ProcessDelegate (MethodBase method, string operationName, bool isAsync, ref object [] parameters, OperationContext context);
readonly RequestDelegate requestDelegate;
@ -149,10 +146,6 @@ namespace System.ServiceModel.MonoInternal
get { return channel as IDuplexChannel; }
}
public OperationContext Context {
set { context = value; }
}
#region IClientChannel
bool did_interactive_initialization;
@ -445,42 +438,48 @@ namespace System.ServiceModel.MonoInternal
public IAsyncResult BeginProcess (MethodBase method, string operationName, object [] parameters, AsyncCallback callback, object asyncState)
{
if (context != null)
throw new InvalidOperationException ("another operation is in progress");
context = OperationContext.Current;
try {
return _processDelegate.BeginInvoke (method, operationName, parameters, callback, asyncState);
} catch {
context = null;
throw;
}
var p = parameters;
var retval = _processDelegate.BeginInvoke (method, operationName, true, ref p, OperationContext.Current, callback, asyncState);
if (p != parameters)
throw new InvalidOperationException ();
return retval;
}
public object EndProcess (MethodBase method, string operationName, object [] parameters, IAsyncResult result)
{
try {
if (result == null)
throw new ArgumentNullException ("result");
if (parameters == null)
throw new ArgumentNullException ("parameters");
// FIXME: the method arguments should be verified to be
// identical to the arguments in the corresponding begin method.
return _processDelegate.EndInvoke (result);
} finally {
context = null;
}
if (result == null)
throw new ArgumentNullException ("result");
if (parameters == null)
throw new ArgumentNullException ("parameters");
object[] p = parameters;
var retval = _processDelegate.EndInvoke (ref p, result);
if (p == parameters)
return retval;
if (p.Length != parameters.Length)
throw new InvalidOperationException ();
Array.Copy (p, parameters, p.Length);
return retval;
}
public object Process (MethodBase method, string operationName, object [] parameters)
public object Process (MethodBase method, string operationName, object [] parameters, OperationContext context)
{
var p = parameters;
var retval = Process (method, operationName, false, ref p, context);
if (p != parameters)
throw new InvalidOperationException ();
return retval;
}
object Process (MethodBase method, string operationName, bool isAsync, ref object [] parameters, OperationContext context)
{
var previousContext = OperationContext.Current;
try {
// Inherit the context from the calling thread
if (this.context != null)
OperationContext.Current = this.context;
OperationContext.Current = context;
return DoProcess (method, operationName, parameters);
return DoProcess (method, operationName, isAsync, ref parameters, context);
} catch (Exception ex) {
throw;
} finally {
@ -489,7 +488,7 @@ namespace System.ServiceModel.MonoInternal
}
}
object DoProcess (MethodBase method, string operationName, object [] parameters)
object DoProcess (MethodBase method, string operationName, bool isAsync, ref object [] parameters, OperationContext context)
{
if (AllowInitializationUI)
DisplayInitializationUI ();
@ -499,9 +498,9 @@ namespace System.ServiceModel.MonoInternal
Open ();
if (!od.IsOneWay)
return Request (od, parameters);
return Request (od, isAsync, ref parameters, context);
else {
Output (od, parameters);
Output (od, parameters, context);
return null;
}
}
@ -519,17 +518,17 @@ namespace System.ServiceModel.MonoInternal
return od;
}
void Output (OperationDescription od, object [] parameters)
void Output (OperationDescription od, object [] parameters, OperationContext context)
{
ClientOperation op = runtime.Operations [od.Name];
Send (CreateRequest (op, parameters), OperationTimeout);
Send (CreateRequest (op, parameters, context), OperationTimeout);
}
object Request (OperationDescription od, object [] parameters)
object Request (OperationDescription od, bool isAsync, ref object [] parameters, OperationContext context)
{
ClientOperation op = runtime.Operations [od.Name];
object [] inspections = new object [runtime.MessageInspectors.Count];
Message req = CreateRequest (op, parameters);
Message req = CreateRequest (op, parameters, context);
for (int i = 0; i < inspections.Length; i++)
inspections [i] = runtime.MessageInspectors [i].BeforeSendRequest (ref req, this);
@ -566,10 +565,15 @@ namespace System.ServiceModel.MonoInternal
for (int i = 0; i < inspections.Length; i++)
runtime.MessageInspectors [i].AfterReceiveReply (ref res, inspections [i]);
if (op.DeserializeReply)
return op.Formatter.DeserializeReply (res, parameters);
else
if (!op.DeserializeReply)
return res;
if (isAsync && od.EndMethod != null) {
var endParams = od.EndMethod.GetParameters ();
parameters = new object [endParams.Length - 1];
}
return op.Formatter.DeserializeReply (res, parameters);
}
#region Message-based Request() and Send()
@ -621,7 +625,7 @@ namespace System.ServiceModel.MonoInternal
}
#endregion
Message CreateRequest (ClientOperation op, object [] parameters)
Message CreateRequest (ClientOperation op, object [] parameters, OperationContext context)
{
MessageVersion version = message_version;
if (version == null)

View File

@ -114,9 +114,9 @@ namespace System.ServiceModel.MonoInternal
return client.EndProcess (method, operationName, parameters, result);
}
public object Process (MethodBase method, string operationName, object [] parameters)
public object Process (MethodBase method, string operationName, object [] parameters, OperationContext context)
{
return client.Process (method, operationName, parameters);
return client.Process (method, operationName, parameters, context);
}
}

View File

@ -35,7 +35,7 @@ using System.ServiceModel.Channels;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Mono.Moonlight.UnitTesting;
namespace MoonTest.ServiceModel {
namespace MonoTests.System.ServiceModel.Channels {
[TestClass]
public class CommunicationObjectSyncTest {