[Mono-bugs] [Bug 62048][Nor] New - XmlSerializer crashes on Deserialize from MemoryStream

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 28 Jul 2004 11:06:02 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by monobugs@radeldudel.de.

http://bugzilla.ximian.com/show_bug.cgi?id=62048

--- shadow/62048	2004-07-28 11:06:02.000000000 -0400
+++ shadow/62048.tmp.10385	2004-07-28 11:06:02.000000000 -0400
@@ -0,0 +1,93 @@
+Bug#: 62048
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: monobugs@radeldudel.de               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: XmlSerializer crashes on Deserialize from MemoryStream
+
+Description of Problem:
+When I serialize a struc into a memorystream and immediately deserialize 
+it again mono throws an exception instead. This test performs well 
+running in .NET though.
+
+The test case should be sufficient to reproduce the problem.
+
+
+NUnit test case to reproduce the problem:
+----------------------------
+[TestFixture] 
+public class MonoTests
+{
+ public struct XmlLinebreakStruc
+ {
+  public String  Name;
+ }
+
+ [Test] public void TestXmlLinebreak1()
+ {
+  XmlLinebreakStruc p1= new XmlLinebreakStruc();
+  p1.Name= "Test";
+
+  XmlSerializer ser= new XmlSerializer( typeof( XmlLinebreakStruc));
+
+  MemoryStream memStream= new MemoryStream();
+  ser.Serialize( memStream, p1);
+  memStream.Close();
+  String personAsString= System.Text.Encoding.UTF8.GetString( 
+memStream.GetBuffer());
+
+  memStream= new MemoryStream( System.Text.Encoding.UTF8.GetBytes( 
+personAsString));
+  XmlLinebreakStruc p2= (XmlLinebreakStruc )ser.Deserialize( memStream);
+  memStream.Close();
+
+  Assert.AreEqual( p2.Name, "Test");
+ }
+}
+----------------------------
+
+TestCase 'M:Sam.Tests.MonoTests.TestXmlLinebreak1' failed: 
+	System.Xml.XmlException: Text node cannot appear in this state. 
+Line 4, position 21.
+	in <0x0004d> System.Xml.XmlTextReader:ReadText (bool)
+	in <0x001dd> System.Xml.XmlTextReader:ReadContent ()
+	in <0x0017f> System.Xml.XmlTextReader:Read ()
+	in <0x0010f> System.Xml.XmlReader:ReadEndElement ()
+	in <0x00046> 
+System.Xml.Serialization.XmlSerializationReader:ReadEndElement ()
+	in <0x00235> 
+System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadClassInstan
+ce (System.Xml.Serialization.XmlTypeMapping,bool,bool)
+	in <0x0005a> 
+System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadObject 
+(System.Xml.Serialization.XmlTypeMapping,bool,bool)
+	in <0x000ea> 
+System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadRoot 
+(System.Xml.Serialization.XmlTypeMapping)
+	in <0x00079> 
+System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadRoot ()
+	in <0x0007a> System.Xml.Serialization.XmlSerializer:Deserialize 
+(System.Xml.Serialization.XmlSerializationReader)
+	in <0x0004d> System.Xml.Serialization.XmlSerializer:Deserialize 
+(System.Xml.XmlReader)
+	in <0x00035> System.Xml.Serialization.XmlSerializer:Deserialize 
+(System.IO.Stream)
+	in <0x000f4> Sam.Tests.MonoTests:TestXmlLinebreak1 ()
+	in (unmanaged) (wrapper managed-to-native) 
+System.Reflection.MonoMethod:InternalInvoke (object,object[])
+	in <0x00004> (wrapper managed-to-native) 
+System.Reflection.MonoMethod:InternalInvoke (object,object[])
+	in <0x0008e> System.Reflection.MonoMethod:Invoke 
+(object,System.Reflection.BindingFlags,System.Reflection.Binder,object
+[],System.Globalization.CultureInfo)