Void event should not have Result of type void.
authorAtsushi Eno <atsushi@ximian.com>
Thu, 21 Oct 2010 10:44:20 +0000 (19:44 +0900)
committerAtsushi Eno <atsushi@ximian.com>
Thu, 21 Oct 2010 10:44:20 +0000 (19:44 +0900)
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceContractGenerator.cs

index ef24544793ce179c23df88c79195868797200f23..8230c609fb9aea6034c2327bde91a604a00997fe 100644 (file)
@@ -627,12 +627,16 @@ namespace System.ServiceModel.Description
 
                        argsType.Members.Add (new CodeMemberField (typeof (object []), "results"));
 
-                       var resultProp = new CodeMemberProperty {
-                               Name = "Result",
-                               Type = endMethod != null ? endMethod.ReturnType : method.ReturnType,
-                               Attributes = MemberAttributes.Public | MemberAttributes.Final };
-                       resultProp.GetStatements.Add (new CodeMethodReturnStatement (new CodeCastExpression (resultProp.Type, new CodeArrayIndexerExpression (resultsField, new CodePrimitiveExpression (0)))));
-                       argsType.Members.Add (resultProp);
+                       var resultType = endMethod != null ? endMethod.ReturnType : method.ReturnType;
+
+                       if (resultType.BaseType != "System.Void") {
+                               var resultProp = new CodeMemberProperty {
+                                       Name = "Result",
+                                       Type = resultType,
+                                       Attributes = MemberAttributes.Public | MemberAttributes.Final };
+                               resultProp.GetStatements.Add (new CodeMethodReturnStatement (new CodeCastExpression (resultProp.Type, new CodeArrayIndexerExpression (resultsField, new CodePrimitiveExpression (0)))));
+                               argsType.Members.Add (resultProp);
+                       }
 
                        // event field
                        var handlerType = new CodeTypeReference (typeof (EventHandler<>));