Author: atsushi
Date: 2007-09-25 13:35:18 -0400 (Tue, 25 Sep 2007)
New Revision: 86346

Modified:
   trunk/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
   
trunk/mcs/class/System.XML/System.Xml.Serialization/SerializationCodeGenerator.cs
   
trunk/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs
   trunk/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs
   trunk/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog
   
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlReflectionImporterTests.cs
   
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSchemaExporterTests.cs
   
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs
Log:
2007-09-25  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * XmlSerializerTests.cs : added deserialization test for
          XmlSchemaProviderAttribute use.
        * XmlReflectionImporterTests.cs : added test for conclict resolution
          between defaultNamespace and XmlSchemaProvider() namespace.
        * XmlSchemaExporterTests.cs : use Infoset() comparison.

        * XmlTypeMapping.cs : Namespace and XmlTypeNamespace could be
          different when an explicit namespace is specified (e.g. at
          XmlReflectionImporter.ctor).
        * SerializationCodeGenerator.cs,
          XmlSerializationWriterInterpreter.cs :
          revert XmlTypeMapping.XmlTypeNamsepace usage. Now with the fix
          above, original code should work fine.



Modified: trunk/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.Serialization/ChangeLog       
2007-09-25 17:15:07 UTC (rev 86345)
+++ trunk/mcs/class/System.XML/System.Xml.Serialization/ChangeLog       
2007-09-25 17:35:18 UTC (rev 86346)
@@ -1,5 +1,15 @@
 2007-09-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * XmlTypeMapping.cs : Namespace and XmlTypeNamespace could be
+         different when an explicit namespace is specified (e.g. at
+         XmlReflectionImporter.ctor).
+       * SerializationCodeGenerator.cs,
+         XmlSerializationWriterInterpreter.cs :
+         revert XmlTypeMapping.XmlTypeNamsepace usage. Now with the fix
+         above, original code should work fine.
+
+2007-09-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * XmlTypeMapping.cs, XmlSerializationWriterInterpreter.cs,
          SerializationCodeGenerator.cs :
          More XmlSchemaProviderAttribute method check. Use QName returned

Modified: 
trunk/mcs/class/System.XML/System.Xml.Serialization/SerializationCodeGenerator.cs
===================================================================
--- 
trunk/mcs/class/System.XML/System.Xml.Serialization/SerializationCodeGenerator.cs
   2007-09-25 17:15:07 UTC (rev 86345)
+++ 
trunk/mcs/class/System.XML/System.Xml.Serialization/SerializationCodeGenerator.cs
   2007-09-25 17:35:18 UTC (rev 86346)
@@ -666,9 +666,7 @@
 
                        if (typeMap.TypeData.SchemaType == 
SchemaTypes.XmlSerializable)
                        {
-                               WriteLine (String.Format ("WriteSerializable 
(ob, {0}, {1}, isNullable);",
-                                                         typeMap.XmlType != 
null ? GetLiteral (typeMap.XmlType) : "element",
-                                                         
typeMap.XmlTypeNamespace != null ? GetLiteral (typeMap.XmlTypeNamespace) : 
"namesp"));
+                               WriteLine ("WriteSerializable (ob, element, 
namesp, isNullable);");
                                
                                GenerateEndHook ();
                                WriteLineUni ("}");

Modified: 
trunk/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs
===================================================================
--- 
trunk/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs
    2007-09-25 17:15:07 UTC (rev 86345)
+++ 
trunk/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs
    2007-09-25 17:35:18 UTC (rev 86346)
@@ -116,7 +116,7 @@
 
                        if (typeMap.TypeData.SchemaType == 
SchemaTypes.XmlSerializable)
                        {
-                               WriteSerializable ((IXmlSerializable)ob, 
typeMap.XmlType ?? element, typeMap.XmlTypeNamespace ?? namesp, isNullable);
+                               WriteSerializable ((IXmlSerializable)ob, 
element, namesp, isNullable);
                                return;
                        }
 

Modified: trunk/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs       
2007-09-25 17:15:07 UTC (rev 86345)
+++ trunk/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs       
2007-09-25 17:35:18 UTC (rev 86346)
@@ -232,6 +232,8 @@
                                        throw new InvalidOperationException (
                                                String.Format ("Method 
{0}.{1}() specified by XmlSchemaProviderAttribute has invalid signature: return 
type must be compatible with System.Xml.XmlQualifiedName.", typeData.Type.Name, 
method));
 
+                               // defaultNamespace at XmlReflectionImporter 
takes precedence for Namespace, but not for XsdTypeNamespace.
+                               UpdateRoot (new XmlQualifiedName 
(_schemaTypeName.Name, Namespace ?? _schemaTypeName.Namespace));
                                XmlTypeNamespace = _schemaTypeName.Namespace;
                                XmlType = _schemaTypeName.Name;
 

Modified: trunk/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog  
2007-09-25 17:15:07 UTC (rev 86345)
+++ trunk/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog  
2007-09-25 17:35:18 UTC (rev 86346)
@@ -1,5 +1,13 @@
 2007-09-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * XmlSerializerTests.cs : added deserialization test for
+         XmlSchemaProviderAttribute use.
+       * XmlReflectionImporterTests.cs : added test for conclict resolution
+         between defaultNamespace and XmlSchemaProvider() namespace.
+       * XmlSchemaExporterTests.cs : use Infoset() comparison.
+
+2007-09-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * XmlSerializerTests.cs, XmlReflectionImporterTests.cs :
          added tests for XmlSchemaProviderAttribute and how its qname works.
 

Modified: 
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlReflectionImporterTests.cs
===================================================================
--- 
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlReflectionImporterTests.cs
      2007-09-25 17:15:07 UTC (rev 86345)
+++ 
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlReflectionImporterTests.cs
      2007-09-25 17:35:18 UTC (rev 86346)
@@ -1611,6 +1611,16 @@
                {
                        new XmlSerializer (typeof 
(XmlSchemaProviderIncorrectReturnType));
                }
+
+               [Test]
+               public void XmlSchemaProviderAndDefaultNamespace ()
+               {
+                       XmlTypeMapping tm = new XmlReflectionImporter 
("urn:bar").ImportTypeMapping (typeof 
(XmlSchemaProviderAndDefaultNamespaceType));
+                       Assert.AreEqual ("foo", tm.ElementName, "#1");
+                       Assert.AreEqual ("foo", tm.XsdTypeName, "#2");
+                       Assert.AreEqual ("urn:bar", tm.Namespace, "#3");
+                       Assert.AreEqual ("urn:foo", tm.XsdTypeNamespace);
+               }
 #endif
 
                public class Employee : IXmlSerializable
@@ -2163,6 +2173,34 @@
                                return null;
                        }
                }
+
+               [XmlSchemaProvider ("GetXsd")]
+               public class XmlSchemaProviderAndDefaultNamespaceType : 
IXmlSerializable
+               {
+                       public static XmlQualifiedName GetXsd (XmlSchemaSet xss)
+                       {
+                               XmlSchema xs = new XmlSchema ();
+                               xs.TargetNamespace = "urn:foo";
+                               XmlSchemaComplexType ct = new 
XmlSchemaComplexType ();
+                               ct.Name = "foo";
+                               xs.Items.Add (ct);
+                               xss.Add (xs);
+                               return new XmlQualifiedName ("foo", "urn:foo");
+                       }
+
+                       public void WriteXml (XmlWriter write)
+                       {
+                       }
+
+                       public void ReadXml (XmlReader reader)
+                       {
+                       }
+
+                       public XmlSchema GetSchema ()
+                       {
+                               return null;
+                       }
+               }
 #endif
        }
 }

Modified: 
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSchemaExporterTests.cs
===================================================================
--- 
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSchemaExporterTests.cs
  2007-09-25 17:15:07 UTC (rev 86345)
+++ 
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSchemaExporterTests.cs
  2007-09-25 17:35:18 UTC (rev 86346)
@@ -27,6 +27,11 @@
                const string ANamespace = "some:urn";
                const string AnotherNamespace = "another:urn";
 
+               string Infoset (string source)
+               {
+                       return XmlSerializerTests.Infoset (source);
+               }
+
                private XmlSchemas Export (Type type)
                {
                        return Export (type, string.Empty);
@@ -1705,7 +1710,7 @@
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format 
(CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format 
(CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" 
encoding=\"utf-16\"?>{0}" +
                                "<xs:schema 
xmlns:tns=\"NSEmployeeSchemaProvider\" elementFormDefault=\"qualified\" 
targetNamespace=\"NSEmployeeSchemaProvider\" 
xmlns:xs=\"http://www.w3.org/2001/XMLSchema\";>{0}" +
 #if NET_2_0
@@ -1722,7 +1727,7 @@
                                "    </xs:complexType>{0}" +
                                "  </xs:element>{0}" +
 #endif
-                               "</xs:schema>", Environment.NewLine), 
sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset 
(sw.ToString ()), "#2");
 
                        schemas = Export (typeof (EmployeeSchemaProvider));
                        //Assert.AreEqual (1, schemas.Count, "#3");
@@ -1730,7 +1735,7 @@
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format 
(CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format 
(CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" 
encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" 
xmlns:xs=\"http://www.w3.org/2001/XMLSchema\";>{0}" +
 #if NET_2_0
@@ -1747,7 +1752,7 @@
                                "    </xs:complexType>{0}" +
                                "  </xs:element>{0}" +
 #endif
-                               "</xs:schema>", Environment.NewLine), 
sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset 
(sw.ToString ()), "#4");
 
                        schemas = Export (typeof (PrimitiveSchemaProvider), 
"NSPrimitiveSchemaProvider");
                        //Assert.AreEqual (1, schemas.Count, "#5");
@@ -1755,7 +1760,7 @@
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format 
(CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format 
(CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" 
encoding=\"utf-16\"?>{0}" +
                                "<xs:schema 
xmlns:tns=\"NSPrimitiveSchemaProvider\" elementFormDefault=\"qualified\" 
targetNamespace=\"NSPrimitiveSchemaProvider\" 
xmlns:xs=\"http://www.w3.org/2001/XMLSchema\";>{0}" +
 #if NET_2_0
@@ -1772,7 +1777,7 @@
                                "    </xs:complexType>{0}" +
                                "  </xs:element>{0}" +
 #endif
-                               "</xs:schema>", Environment.NewLine), 
sw.ToString ().Replace("<xs:import />" + Environment.NewLine, ""), "#6");
+                               "</xs:schema>", Environment.NewLine)), Infoset 
(sw.ToString ().Replace("<xs:import />" + Environment.NewLine, "")), "#6");
                }
 
                [Test]

Modified: 
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs
===================================================================
--- 
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs  
    2007-09-25 17:15:07 UTC (rev 86345)
+++ 
trunk/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs  
    2007-09-25 17:35:18 UTC (rev 86346)
@@ -2669,6 +2669,7 @@
                        xs = new XmlSerializer (typeof 
(XmlSchemaProviderQNameBecomesRootNameType));
                        Serialize (new 
XmlSchemaProviderQNameBecomesRootNameType ());
                        Assert.AreEqual (Infoset ("<foo />"), WriterText);
+                       xs.Deserialize (new StringReader ("<foo/>"));
                }
 #endif
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to