3 using System.Runtime.Serialization;
5 using System.Xml.Schema;
6 using System.Xml.Serialization;
11 namespace MonoTests.System.Runtime.Serialization
14 [XmlSchemaProvider(null, IsAny = true)]
15 public class TestElement : IXmlSerializable
17 public string Value { get; set; }
19 void IXmlSerializable.WriteXml(XmlWriter writer)
21 writer.WriteElementString("dummy", Value);
24 void IXmlSerializable.ReadXml(XmlReader reader)
26 Value = reader.ReadElementString("dummy");
29 XmlSchema IXmlSerializable.GetSchema()
37 public class Bug11916Test
40 public void TestIsAnyTrueDataContractSerializer()
42 TestElement element = new TestElement();
43 element.Value = "bar";
45 StringBuilder stringBuilder = new StringBuilder ();
47 DataContractSerializer ser = new DataContractSerializer (typeof (TestElement));
49 using (var xw = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (new StringWriter (stringBuilder))))
51 ser.WriteObject(xw, element);
54 string actualXml = stringBuilder.ToString ();
55 string expectedXml = "<?xml version=\"1.0\" encoding=\"utf-16\"?><dummy>bar</dummy>";
57 Assert.AreEqual (expectedXml, actualXml, "#1 IsAny=true DataContractSerializer");