[Mono-bugs] [Bug 44623][Nor] New - mono crashes when using XmlSerializer with XmlIncludeAttribute for serializing an abstract class.
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Thu, 12 Jun 2003 10:43:05 -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 bugzilla@kirkner.com.ar.
http://bugzilla.ximian.com/show_bug.cgi?id=44623
--- shadow/44623 Thu Jun 12 10:43:05 2003
+++ shadow/44623.tmp.13539 Thu Jun 12 10:43:05 2003
@@ -0,0 +1,121 @@
+Bug#: 44623
+Product: Mono/Runtime
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: bugzilla@kirkner.com.ar
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: mono crashes when using XmlSerializer with XmlIncludeAttribute for serializing an abstract class.
+
+Description of Problem:
+When running the test program, you get and unhandled exception. It relates
+somehow with XmlSerializer not correctly handling serialization of classes
+that are derived from an abstract class (therefore the need to use
+XmlIncludeAttribute)
+
+
+Steps to reproduce the problem:
+1. compile the source (just do mcs XmlSerializerTest.cs)
+2. run the program (mono XmlSerializerTest.exe)
+
+Actual Results:
+(these results you get when running with mono)
+<?xml version="1.0" encoding="iso-8859-1"?>
+<TestClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <member4
+Unhandled Exception: System.NullReferenceException: A null value was found
+where an object instance was required
+in <0x00236> 00 System.Xml.Serialization.XmlSerializer:SerializeMembers
+(System.Xml.XmlWriter,object,bool)
+in <0x00795> 00 System.Xml.Serialization.XmlSerializer:WriteElement
+(System.Xml.XmlWriter,System.Xml.Serialization.XmlAttributes,string,string,System.Type,object)
+in <0x00eb1> 00 System.Xml.Serialization.XmlSerializer:SerializeMembers
+(System.Xml.XmlWriter,object,bool)
+in <0x00a02> 00 System.Xml.Serialization.XmlSerializer:Serialize
+(System.Xml.XmlWriter,object,System.Xml.Serialization.XmlSerializerNamespaces)
+in <0x0001c> 00 System.Xml.Serialization.XmlSerializer:Serialize
+(System.Xml.XmlWriter,object)
+in <0x000d6> 00 .MainClass:Main (string[])
+
+
+Expected Results:
+(these results you get when running with microsoft's compiler)
+<?xml version="1.0" encoding="IBM437"?>
+<TestClass xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <member4 xsi:type="SubClass1">
+ <member1>60</member1>
+ </member4>
+</TestClass>
+
+
+
+How often does this happen?
+every time you run the program with mono. with microsoft's compiler it
+works correctly.
+
+Additional Information:
+I append the source of the test program i used:
+
+XmlSerializerTest.cs
+----------------------------------------------------------
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+[Serializable]
+[XmlInclude(typeof(SubClass1))]
+[XmlInclude(typeof(SubClass2))]
+public abstract class BaseClass {}
+
+[Serializable]
+public class SubClass1 : BaseClass {
+ public int member1;
+
+ public SubClass1 () : this (60) {}
+ public SubClass1 (int member1) { this.member1 = member1 }
+}
+
+[Serializable]
+public class SubClass2 : BaseClass {
+ public int member2;
+ public int member3;
+
+ public SubClass () : this (24,100) {}
+ public SubClass (int member2, int member3) {
+ this.member2 = member2;
+ this.member3 = member3;
+ }
+}
+
+[Serializable]
+public class TestClass {
+ public BaseClass member4;
+
+ public TestClass () {
+ this.member4 = new SubClass1 ();
+ }
+}
+
+public class MainClass {
+ public static void Main (string [] args) {
+ TestClass tc = new TestClass ();
+ XmlSerializer s = new XmlSerializer (typeof (TestClass));
+ XmlTextWriter w = new XmlTextWriter (Console.Out);
+ w.Formatting = Formatting.Indented;
+ w.Indentation = 4;
+
+ s.Serialize (w, tc);
+ }
+}
+------------------------------------------------------------