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 [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=77530 --- shadow/77530 2006-02-11 08:18:42.000000000 -0500 +++ shadow/77530.tmp.14391 2006-02-11 08:18:42.000000000 -0500 @@ -0,0 +1,60 @@ +Bug#: 77530 +Product: Mono: Class Libraries +Version: 1.1 +OS: +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Normal +Component: Sys.XML +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: [PATCH] serialization of integral enum value is not correct + +When an integral value of an enum is serialized, Mono currently does not +translate the integral value to its corresponding enum constant name. + +The attached patch fixes this (and enables the corresponding unit tests), +and ensures we throw the same exceptions as MS when a corresponding +constant does not exist. + +* XmlTypeMapping.cs: EnumMapMember now also stores value for enums. +Modified EnumMapping.GetXmlName to use XmlCustomFormatter to support +serialization of integral value to enum constant name, and made sure +the exceptions we throw match those of MSFT. In EnumMapping.GetEnumName +throw InvalidOperationException if no matching enum constant exists. +* XmlSerializationReaderInterpreter.cs: Pass full type name to +EnumMapping.GetEnumName for construction of exception message. +* XmlSerializer.cs: In Deserialize, wrap InvalidOperationException +and InvalidCastException in another InvalidOperationException to match +MSFT. In Serialize, wrap InvalidOperationException, InvalidCastException +and the inner exception for a TargetInvocationException in an +InvalidOperationException to match MSFT. +* SerializationCodeGenerator.cs: In GenerateGetXmlEnumValue, use +XmlCustomFormatter.FromEnum in order to also support serialization +integral value to enum constant name. In 2.0 profile, throw +InvalidOperationException if numeric value cannot be serialized into +an enum constant value. In GenerateSingleEnumValue, no longer attempt +to parse unknown constant value but instead report it as +InvalidOperationException. Use string.Length instead of "" comparison +to check whether a string is empty. Fixed compiler warning in +generated code (possible empty statement). +* XmlSerializationWriterInterpreter.cs: Pass full type name to +EnumMap.GetXmlName. +* XmlSchemaImporter.cs: Pass full type name to EnumMap.GetEnumName +to allow it to be used in exception messages. +* XmlReflectionImporter.cs: Use FieldInfo instead of MemberInfo for +enum fields. Use IsDefined instead of GetCustomAttributes for checking +if a certain attribute is defined. Use integral value of enum constant +in EnumMapMember ctor. +* SoapReflectionImporter.cs: Use FieldInfo instead of MemberInfo for +enum fields. Use IsDefined instead of GetCustomAttributes for checking +if a certain attribute is defined. Use integral value of enum constant +in EnumMapMember ctor. + +Let me know if its ok to commit this patch. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
