[Mono-bugs] [Bug 74351][Nor] New - XmlChoiceIdentifier attribute is ignored during deserialization (patch attached)

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 3 Apr 2005 09:39:54 -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 kostat@mainsoft.com.

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

--- shadow/74351	2005-04-03 09:39:54.000000000 -0400
+++ shadow/74351.tmp.8588	2005-04-03 09:39:54.000000000 -0400
@@ -0,0 +1,79 @@
+Bug#: 74351
+Product: Mono: Class Libraries
+Version: 1.1
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.XML
+AssignedTo: lluis@ximian.com                            
+ReportedBy: kostat@mainsoft.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: XmlChoiceIdentifier attribute is ignored during deserialization (patch attached)
+
+Test case:
+
+using System;
+using System.Xml;
+using System.IO;
+using System.Diagnostics;
+using System.Xml.Serialization;
+using System.Data;
+
+public class Choices{
+   [System.Xml.Serialization.XmlElementAttribute("Wrong", typeof(string),
+IsNullable=false)]
+   [System.Xml.Serialization.XmlElementAttribute("ChoiceOne",
+typeof(string), IsNullable=false)]
+       [System.Xml.Serialization.XmlElementAttribute("ChoiceTwo",
+typeof(string), IsNullable=false)]
+   [XmlChoiceIdentifier("ItemType")]
+   public string MyChoice;
+   // Do not serialize this next field:
+   [XmlIgnore]
+   public ItemChoiceType ItemType;
+}
+// Do not include this enumeration in the XML schema.
+[XmlType(IncludeInSchema = false)]
+public enum ItemChoiceType{
+   Wrong,
+   ChoiceOne,
+   ChoiceTwo,
+}
+
+
+public class Test {
+
+   static void Test5() {
+       Choices ch = new Choices();
+       ch.MyChoice = "ChoiceOne";
+       ch.ItemType = ItemChoiceType.ChoiceOne;
+
+       XmlSerializer ser = new XmlSerializer(typeof(Choices));
+
+       MemoryStream stream = new MemoryStream();
+       ser.Serialize(stream, ch);
+
+       stream.Position = 0;
+       ch = (Choices)ser.Deserialize(stream);
+
+       //should be ChoiceOne
+       Console.WriteLine(ch.ItemType);
+   }
+
+   public static void Main () {
+       Test5();
+
+   }
+}
+
+Actual Results:
+ItemType is filled with default value
+
+Expected Results:
+ItemType is filled with ItemChoiceType.ChoiceOne value