Merge pull request #757 from mlintner/master
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Description / ContractDescriptionGenerator.cs
index afd5ac2ac84c9ba565a0db9348b176f9c306b23c..80238d41ff89bf3ee89270260cc6cbfb82a4f12d 100644 (file)
@@ -274,7 +274,6 @@ namespace System.ServiceModel.Description
                        
                        for (int i = 0; i < contractMethods.Length; ++i)
                        {
-
                                MethodInfo mi = contractMethods [i];
                                OperationContractAttribute oca = GetOperationContractAttribute (mi);
                                if (oca == null)
@@ -290,7 +289,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;
                        }
@@ -323,7 +322,7 @@ namespace System.ServiceModel.Description
                static OperationDescription GetOrCreateOperation (
                        ContractDescription cd, MethodInfo mi, MethodInfo serviceMethod,
                        OperationContractAttribute oca,
-                       Type asyncReturnType,
+                       MethodInfo endMethod,
                        bool isCallback,
                        Type givenServiceType)
                {
@@ -348,7 +347,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) {
@@ -559,8 +559,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