Apply patch from Tom Hindle to fix ##2893 and add a test case.
authorMiguel de Icaza <miguel@gnome.org>
Sat, 14 Jan 2012 20:35:29 +0000 (15:35 -0500)
committerMiguel de Icaza <miguel@gnome.org>
Sat, 14 Jan 2012 20:35:45 +0000 (15:35 -0500)
The serializer interpreted was broken, but the compiled version was fine,
running MONO_XMLSERIALIZER_THS=0 allowed this to run

mcs/class/System.XML/Makefile
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs
mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs

index e30541c3d824ba11698c9c47b512d750e0807906..18e2840776568778c1ad0770f87c064231dcc26d 100644 (file)
@@ -26,7 +26,7 @@ endif
 ifeq (2.1, $(FRAMEWORK_VERSION))
 LIB_MCS_FLAGS += -unsafe -d:AGCLR -d:NET_2_1_HACK
 endif
-TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:0618 -nowarn:219 -nowarn:169
+TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:0618 -nowarn:219 -nowarn:169 -r:System.Data
 
 ifeq (2.0, $(FRAMEWORK_VERSION))
 # Happens on net_2_0_bootstrap and net_2_0 profiles
index dad96241215334f66212b022868553e07ce5f4f3..6faf77f97d51bbdb0205ab030ff6b0147f7b8a1c 100644 (file)
@@ -483,7 +483,10 @@ namespace System.Xml.Serialization
 #if MOONLIGHT
                        throw new NotSupportedException ();
 #else
-                       if (member.TypeData.Type == typeof (XmlElement)) {
+                       //
+                       // XmlAnyElement can be of XmlElement or XmlNode type
+                       // 
+                       if (member.TypeData.Type == typeof (XmlElement) || member.TypeData.Type == typeof(XmlNode)) {
                                memberValue = new object[] { memberValue };
                        }
 
index 8061423ee01e46a1651e37751b8b2caed410b81c..a7f00ab1e24e084243c71cb2ad5424f4c35c12cf 100644 (file)
@@ -31,6 +31,7 @@ using System.Globalization;
 using System.IO;
 using System.Text;
 using System.Xml;
+using System.Data;
 using System.Xml.Schema;
 using System.Xml.Serialization;
 #if NET_2_0
@@ -2845,6 +2846,39 @@ namespace MonoTests.System.XmlSerialization
                        new XmlSerializer (typeof (XmlAnyElementForObjectsType)).Serialize (TextWriter.Null, new XmlAnyElementForObjectsType ());
                }
 
+
+               public class Bug2893 {
+                       public Bug2893 ()
+                       {                       
+                               Contents = new XmlDataDocument();
+                       }
+                       
+                       [XmlAnyElement("Contents")]
+                       public XmlNode Contents;
+               }
+
+               // Bug Xamarin #2893
+               [Test]
+               public void XmlAnyElementForXmlNode ()
+               {
+                       var obj = new Bug2893 ();
+                       XmlSerializer mySerializer = new XmlSerializer(typeof(Bug2893));
+                       XmlWriterSettings settings = new XmlWriterSettings();
+
+                       var xsn = new XmlSerializerNamespaces();
+                       xsn.Add(string.Empty, string.Empty);
+
+                       byte[] buffer = new byte[2048];
+                       var ms = new MemoryStream(buffer);
+                       using (var xw = XmlWriter.Create(ms, settings))
+                       {
+                               mySerializer.Serialize(xw, obj, xsn);
+                               xw.Flush();
+                       }
+
+                       mySerializer.Serialize(ms, obj);
+               }
+
                [Test]
                public void XmlRootOverridesSchemaProviderQName ()
                {