diff options
Diffstat (limited to 'mcs')
4 files changed, 32 insertions, 0 deletions
diff --git a/mcs/class/System.XML/System.Xml.Serialization/ChangeLog b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog index c07f6454371..aebd7d00759 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/ChangeLog +++ b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog @@ -1,5 +1,10 @@ 2006-11-22 Atsushi Enomoto <atsushi@ximian.com> + * XmlCustomFormatter.cs : handle hexBinary type. Fixed bug #79989 + and #79990. + +2006-11-22 Atsushi Enomoto <atsushi@ximian.com> + Fixed bug #78611. * TypeData.cs, TypeTranslator.cs: improved TypeData to actually store "nullable" information. Introduced new primitiveNullableTypes pool diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs index 736783964c3..950f5a2a56f 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs @@ -241,6 +241,7 @@ namespace System.Xml.Serialization { case "guid": return XmlConvert.ToString ((Guid)value); case "base64": case "base64Binary": return value == null ? String.Empty : Convert.ToBase64String ((byte[])value); + case "hexBinary": return value == null ? String.Empty : XmlConvert.ToBinHexString ((byte[]) value); case "duration": return XmlConvert.ToString ((TimeSpan) value); default: return value is IFormattable ? ((IFormattable) value).ToString (null, CultureInfo.InvariantCulture) : value.ToString (); } @@ -271,6 +272,7 @@ namespace System.Xml.Serialization { case "guid": return XmlConvert.ToGuid (value); case "base64": case "base64Binary": return Convert.FromBase64String (value); + case "hexBinary": return XmlConvert.FromBinHexString (value); case "duration": return XmlConvert.ToTimeSpan (value); default: if (type.Type != null) diff --git a/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog b/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog index 793d212540f..0f4cc4e8533 100644 --- a/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog +++ b/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog @@ -1,5 +1,9 @@ 2006-11-22 Atsushi Enomoto <atsushi@ximian.com> + * XmlSerializerTests.cs : added test for hexBinary. + +2006-11-22 Atsushi Enomoto <atsushi@ximian.com> + * XmlReflectionImporterTests.cs : added test for class that contains nullable value type field whose XmlElementAttribute IsNullable. diff --git a/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs b/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs index b6f72a5c5dc..44fb8c52cf1 100644 --- a/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs +++ b/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs @@ -2149,6 +2149,27 @@ namespace MonoTests.System.XmlSerialization } #endif + [Test] // bug #79989, #79990 + public void SerializeHexBinary() + { + XmlSerializer ser = new XmlSerializer (typeof (HexBinary)); + StringWriter sw = new StringWriter (); + XmlTextWriter xtw = new XmlTextWriter (sw); + ser.Serialize (xtw, new HexBinary ()); + xtw.Close (); + string expected = @"<?xml version=""1.0"" encoding=""utf-16""?><HexBinary xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" Data=""010203"" />"; + Assert.AreEqual (expected, sw.ToString ()); + HexBinary h = (HexBinary) ser.Deserialize (new StringReader (sw.ToString ())); + Assert.AreEqual (new byte [] {1, 2, 3}, h.Data); + } + + [XmlRoot ("HexBinary")] + public class HexBinary + { + [XmlAttribute (DataType = "hexBinary")] + public byte [] Data = new byte [] {1, 2, 3}; + } + public class CDataTextNodesType { public CDataTextNodesInternal foo; |