[Mono-bugs] [Bug 52155][Wis] New - XmlEnum attribute causes XmlSerializer to not identify the enum string.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 14 Dec 2003 09:25:23 -0500 (EST)


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 erezl@mainsoft.com.

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

--- shadow/52155	2003-12-14 09:25:23.000000000 -0500
+++ shadow/52155.tmp.18180	2003-12-14 09:25:23.000000000 -0500
@@ -0,0 +1,95 @@
+Bug#: 52155
+Product: Mono/Class Libraries
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: System.XML
+AssignedTo: lluis@ximian.com                            
+ReportedBy: erezl@mainsoft.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Summary: XmlEnum attribute causes XmlSerializer to not identify the enum string.
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+Adding an '[XmlEnum]' to the definition of an enum value, causes the 
+XmlSerializer to not recognize the string that represents the value as a 
+valid enumeration value.
+
+Steps to reproduce the problem:
+1. Write a class that has enum type public member such as:
+public class WithEnum
+{
+  public E e;
+}
+and an enum that contains the XmlEnum attribute such as:
+public E
+{
+  [XmlEnum()] E1,
+  [XmlEnum()] E2,
+  [XmlEnum()] E3,
+}
+
+2. Try to serialize an instance of the WithEnum class using XmlSerializer.
+3. Try to deserialize the following XML data into an instance of WithEnum:
+<?xml version="1.0" encoding="utf-8"?>
+<WithEnum>
+  <e>E1</e>
+</WithEnum>
+
+Actual Results:
+1). When serializing to Xml, the WithEnum.e member is not serialized.
+2). When deserializing the above XML you will get the following exception:
+
+
+Expected Results:
+Unhandled Exception: System.InvalidOperationException: Invalid 
+enumeration value: E1
+in <0x00400> System.Xml.Serialization.EnumMap:GetEnumName (string)
+in <0x00071> 
+System.Xml.Serialization.XmlSerializationReaderInterpreter:GetEnumValue 
+(System.Xml.Serialization.XmlTypeMapping,string)
+in <0x0005f> 
+System.Xml.Serialization.XmlSerializationReaderInterpreter:GetValueFromXml
+String 
+(string,System.Xml.Serialization.TypeData,System.Xml.Serialization.XmlType
+Mapping)
+in <0x00162> 
+System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadPrimitiveVa
+lue (System.Xml.Serialization.XmlTypeMapElementInfo)
+in <0x00081> 
+System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadObjectEleme
+nt (System.Xml.Serialization.XmlTypeMapElementInfo)
+in <0x0231c> 
+System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadMembers 
+(System.Xml.Serialization.ClassMap,object,bool,bool)
+in <0x00058> 
+System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadClassInstan
+ceMembers (System.Xml.Serialization.XmlTypeMapping,object)
+in <0x0021e> 
+System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadClassInstan
+ce (System.Xml.Serialization.XmlTypeMapping,bool,bool)
+in <0x00067> 
+System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadObject 
+(System.Xml.Serialization.XmlTypeMapping,bool,bool)
+in <0x000a2> 
+System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadObject ()
+in <0x00075> System.Xml.Serialization.XmlSerializer:Deserialize 
+(System.Xml.Serialization.XmlSerializationReader)
+in <0x00068> System.Xml.Serialization.XmlSerializer:Deserialize 
+(System.Xml.XmlReader)
+in <0x0003f> System.Xml.Serialization.XmlSerializer:Deserialize 
+(System.IO.TextReader)
+in <0x0008e> .Deserializer:Main (string[])
+
+
+How often does this happen? 
+Always.
+
+Additional Information: