2007-01-19 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 19 Jan 2007 07:12:11 +0000 (07:12 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 19 Jan 2007 07:12:11 +0000 (07:12 -0000)
* ServiceDescriptionImporter.cs : initialize CodeGenerator with C#.
* SoapProtocolImporter.cs : use XmlMemberMapping.GenerateTypeName()
  instead of TypeFullName for 2.0 nullable support. Fixed bug #80551.

* ServiceDescriptionImporterTest.cs : new test.
* test2.wsdl : new test support file.

* System.Web.Services_test.dll.sources:
  Added ServiceDescriptionImporterTest.cs.
* Makefile : added test2.wsdl to EXTRA_DISTFILES.

svn path=/trunk/mcs/; revision=71319

mcs/class/System.Web.Services/ChangeLog
mcs/class/System.Web.Services/Makefile
mcs/class/System.Web.Services/System.Web.Services.Description/ChangeLog
mcs/class/System.Web.Services/System.Web.Services.Description/ServiceDescriptionImporter.cs
mcs/class/System.Web.Services/System.Web.Services.Description/SoapProtocolImporter.cs
mcs/class/System.Web.Services/System.Web.Services_test.dll.sources
mcs/class/System.Web.Services/Test/System.Web.Services.Description/ChangeLog
mcs/class/System.Web.Services/Test/System.Web.Services.Description/ServiceDescriptionImporterTest.cs [new file with mode: 0644]
mcs/class/System.Web.Services/Test/System.Web.Services.Description/test2.wsdl [new file with mode: 0644]

index 463b16101292473fa8ca31494b972cafee5bf9f0..99de25980a1de918d6afff8f1c445abf8a8ec2b2 100644 (file)
@@ -1,3 +1,9 @@
+2007-01-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.Web.Services_test.dll.sources:
+         Added ServiceDescriptionImporterTest.cs.
+       * Makefile : added test2.wsdl to EXTRA_DISTFILES.
+
 2007-01-15  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * System.Web.Services_test.dll.sources: added SocketResponder.cs and
index 48f6dede31332fb48089173dee36ad73026dcee2..727000f4d63b13c78bc5b69cceee4ca1583da9bf 100644 (file)
@@ -26,6 +26,7 @@ EXTRA_DISTFILES = \
        System.Web.Services.Description/wsdl-1.1.xsd            \
        System.Web.Services.Description/wsdl-1.1-soap.xsd       \
        System.Web.Services.Description/wsdl.genxs              \
-       Test/System.Web.Services.Description/test.wsdl
+       Test/System.Web.Services.Description/test.wsdl          \
+       Test/System.Web.Services.Description/test2.wsdl
 
 include ../../build/library.make
index f6a30034663bf9bd597d5bcda02eea3ccab8e95d..f30199e684079a99dd8dcfe142a92736115ba68b 100644 (file)
@@ -1,3 +1,9 @@
+2007-01-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceDescriptionImporter.cs : initialize CodeGenerator with C#.
+       * SoapProtocolImporter.cs : use XmlMemberMapping.GenerateTypeName()
+         instead of TypeFullName for 2.0 nullable support. Fixed bug #80551.
+
 2006-12-18  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ProtocolReflector.cs, SoapProtocolReflector.cs,
index dc91c9689b851408a1cee052afe61b7ee2fe0292..5f3e19d53d5d1ee01f3830c73b876511c45896f1 100644 (file)
@@ -41,6 +41,7 @@ using System.Xml.Schema;
 using System.Collections;
 using System.Collections.Specialized;
 using System.Configuration;
+using Microsoft.CSharp;
 
 namespace System.Web.Services.Description {
        public class ServiceDescriptionImporter {
@@ -54,7 +55,7 @@ namespace System.Web.Services.Description {
                
 #if NET_2_0
                CodeGenerationOptions options;
-               CodeDomProvider codeGenerator;
+               CodeDomProvider codeGenerator = new CSharpCodeProvider ();
                ImportContext context;
 #endif
 
@@ -187,7 +188,8 @@ namespace System.Web.Services.Description {
                        foreach (WebReference reference in webReferences) 
                        {
                                ServiceDescriptionImporter importer = new ServiceDescriptionImporter ();
-                               importer.CodeGenerator = codeGenerator;
+                               if (codeGenerator != null)
+                                       importer.CodeGenerator = codeGenerator;
                                importer.CodeGenerationOptions = options.CodeGenerationOptions;
                                importer.Context = context;
                                importer.Style = options.Style;
index 9280c909411fe5720437a8ff3c67cd8129d93b5b..759a4b53621b4bad0532f3dab009660125863f9a 100644 (file)
@@ -557,7 +557,12 @@ namespace System.Web.Services.Description {
                
                CodeParameterDeclarationExpression GenerateParameter (XmlMemberMapping member, FieldDirection dir)
                {
-                       CodeParameterDeclarationExpression par = new CodeParameterDeclarationExpression (member.TypeFullName, member.MemberName);
+#if NET_2_0
+                       string type = member.GenerateTypeName (CodeGenerator);
+#else
+                       string type = member.TypeFullName;
+#endif
+                       CodeParameterDeclarationExpression par = new CodeParameterDeclarationExpression (type, member.MemberName);
                        par.Direction = dir;
                        return par;
                }
index 137a14fde7d5e60d8c32e499cedb2e962d43b051..a19a60c6c8f00d15c686bda67404e70412cf5d08 100644 (file)
@@ -19,6 +19,7 @@ System.Web.Services.Description/PortTypeCollectionTest.cs
 System.Web.Services.Description/PortTypeTest.cs
 System.Web.Services.Description/ServiceCollectionTest.cs
 System.Web.Services.Description/ServiceDescriptionFormatExtensionCollectionTest.cs
+System.Web.Services.Description/ServiceDescriptionImporterTest.cs
 System.Web.Services.Description/ServiceDescriptionTest.cs
 System.Web.Services.Description/ServiceDescriptionCollectionTest.cs
 System.Web.Services.Description/ServiceDescriptionReflectorTest.cs
index 23629a5f21c60b3f081a4b589db65e18896db6ef..4e20325f23427ab7ac3afea15e983295ded3ea0b 100644 (file)
@@ -1,3 +1,8 @@
+2007-01-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceDescriptionImporterTest.cs : new test.
+       * test2.wsdl : new test support file.
+
 2006-12-15  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ServiceDescriptionFormatExtensionCollectionTest.cs :
diff --git a/mcs/class/System.Web.Services/Test/System.Web.Services.Description/ServiceDescriptionImporterTest.cs b/mcs/class/System.Web.Services/Test/System.Web.Services.Description/ServiceDescriptionImporterTest.cs
new file mode 100644 (file)
index 0000000..4224c8b
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// ServiceDescriptionImporterTest.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+using Microsoft.CSharp;
+using System.Web.Services.Description;
+
+namespace MonoTests.System.Web.Services.Description
+{
+       [TestFixture]
+       public class ServiceDescriptionImporterTest
+       {
+#if NET_2_0
+               CodeNamespace GenerateCodeFromWsdl (ServiceDescription sd)
+               {
+                       ServiceDescriptionImporter imp =
+                               new ServiceDescriptionImporter ();
+                       imp.AddServiceDescription (sd, null, null);
+                       CodeNamespace cns = new CodeNamespace ();
+                       imp.Import (cns, null);
+                       return cns;
+               }
+
+               CodeTypeDeclaration FindTypeFrom (CodeNamespace cns, string name)
+               {
+                       foreach (CodeTypeDeclaration td in cns.Types)
+                               if (td.Name == name)
+                                       return td;
+                       return null;
+               }
+
+               CodeTypeDeclaration FindMemberFrom (CodeNamespace cns, string name)
+               {
+                       foreach (CodeTypeDeclaration td in cns.Types)
+                               if (td.Name == name)
+                                       return td;
+                       return null;
+               }
+
+               [Test]
+               public void Constructor ()
+               {
+                       ServiceDescriptionImporter imp =
+                               new ServiceDescriptionImporter ();
+                       Assert.IsTrue (imp.CodeGenerator is CSharpCodeProvider);
+               }
+
+               [Test] // wtf? no ArgumentNullException?
+               public void SetNullCodeGenerator ()
+               {
+                       ServiceDescriptionImporter imp =
+                               new ServiceDescriptionImporter ();
+                       imp.CodeGenerator = null;
+               }
+
+               [Test]
+               public void GenerateNullableTypes ()
+               {
+                       CodeNamespace cns = GenerateCodeFromWsdl (
+                               ServiceDescription.Read ("Test/System.Web.Services.Description/test2.wsdl"));
+                       CodeTypeDeclaration td = FindTypeFrom (cns, "Service");
+                       foreach (CodeTypeMember member in td.Members) {
+                               CodeMemberMethod method = member as CodeMemberMethod;
+                               if (method == null || method.Name != "Hola")
+                                       continue;
+                               Assert.AreEqual ("System.Nullable`1", method.ReturnType.BaseType, "#1");
+                               Assert.AreEqual (1, method.ReturnType.TypeArguments.Count, "#2");
+                               Assert.AreEqual ("System.Int32", method.ReturnType.TypeArguments [0].BaseType, "#3");
+                               return;
+                       }
+                       Assert.Fail ("The expected member didn't appear.");
+               }
+
+               [Test]
+               public void GenerateWebReferencesEmpty ()
+               {
+                       // yuck - This causes NRE.
+                       //ServiceDescriptionImporter.GenerateWebReferences (
+                       //      new WebReferenceCollection (), null, null, null);
+                       ServiceDescriptionImporter.GenerateWebReferences (
+                               new WebReferenceCollection (),
+                               null,
+                               new CodeCompileUnit (),
+                               new WebReferenceOptions ());
+               }
+#endif
+       }
+}
diff --git a/mcs/class/System.Web.Services/Test/System.Web.Services.Description/test2.wsdl b/mcs/class/System.Web.Services/Test/System.Web.Services.Description/test2.wsdl
new file mode 100644 (file)
index 0000000..bba44ea
--- /dev/null
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">\r
+  <wsdl:types>\r
+    <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">\r
+      <s:element name="Hola">\r
+        <s:complexType />\r
+      </s:element>\r
+      <s:element name="HolaResponse">\r
+        <s:complexType>\r
+          <s:sequence>\r
+            <s:element minOccurs="1" maxOccurs="1" name="HolaResult" nillable="true" type="s:int" />\r
+          </s:sequence>\r
+        </s:complexType>\r
+      </s:element>\r
+    </s:schema>\r
+  </wsdl:types>\r
+  <wsdl:message name="HolaSoapIn">\r
+    <wsdl:part name="parameters" element="tns:Hola" />\r
+  </wsdl:message>\r
+  <wsdl:message name="HolaSoapOut">\r
+    <wsdl:part name="parameters" element="tns:HolaResponse" />\r
+  </wsdl:message>\r
+  <wsdl:portType name="ServiceSoap">\r
+    <wsdl:operation name="Hola">\r
+      <wsdl:input message="tns:HolaSoapIn" />\r
+      <wsdl:output message="tns:HolaSoapOut" />\r
+    </wsdl:operation>\r
+  </wsdl:portType>\r
+  <wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">\r
+    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />\r
+    <wsdl:operation name="Hola">\r
+      <soap:operation soapAction="http://tempuri.org/Hola" style="document" />\r
+      <wsdl:input>\r
+        <soap:body use="literal" />\r
+      </wsdl:input>\r
+      <wsdl:output>\r
+        <soap:body use="literal" />\r
+      </wsdl:output>\r
+    </wsdl:operation>\r
+  </wsdl:binding>\r
+  <wsdl:service name="Service">\r
+    <wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">\r
+      <soap:address location="http://localhost:4810/WebSite6/Service.asmx" />\r
+    </wsdl:port>\r
+  </wsdl:service>\r
+</wsdl:definitions>\r