for (int i = 0; i < contractMethods.Length; ++i)
{
-
MethodInfo mi = contractMethods [i];
OperationContractAttribute oca = GetOperationContractAttribute (mi);
if (oca == null)
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;
}
static OperationDescription GetOrCreateOperation (
ContractDescription cd, MethodInfo mi, MethodInfo serviceMethod,
OperationContractAttribute oca,
- Type asyncReturnType,
+ MethodInfo endMethod,
bool isCallback,
Type givenServiceType)
{
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) {
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