From: Nicolas Raoul Date: Mon, 5 Nov 2012 08:01:35 +0000 (+0900) Subject: Merged into single file, added assertions X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=504e922ed86aee42fa1b4ce01c90e13af9bdce81;p=mono.git Merged into single file, added assertions --- diff --git a/mono/tests/bug-2907.cs b/mono/tests/bug-2907.cs index b02c2af890c..c1223c44379 100644 --- a/mono/tests/bug-2907.cs +++ b/mono/tests/bug-2907.cs @@ -2,38 +2,131 @@ using System; using System.IO; using System.Xml.Serialization; -class Test + +class Program { - static public T DeserializeFromString(string xml) where T : class + static public T DeserializeFromString(string xml) where T : class + { + + if (String.IsNullOrEmpty(xml)) { + return null; + } - if (String.IsNullOrEmpty(xml)) + StringReader reader = null; + T deserializedObject = null; + try + { + reader = new StringReader(xml); + XmlSerializer serializer = new XmlSerializer(typeof(T)); + deserializedObject = serializer.Deserialize(reader) as T; + } + finally + { + if (null != reader) { - return null; + reader.Close(); } + } + return deserializedObject; + } - StringReader reader = null; - T deserializedObject = null; - try - { - reader = new StringReader(xml); - XmlSerializer serializer = new XmlSerializer(typeof(T)); - deserializedObject = serializer.Deserialize(reader) as T; - } - finally - { - if (null != reader) - { - reader.Close(); - } - } - return deserializedObject; + + static void Main(string[] args) + { + string myXML = @""; + + // The following line fails on Mono 2.8 2.10 2.10.8.1 2.10.9 + TASK data = DeserializeFromString(myXML); + if(data == null) + { + throw new Exception("A#01"); } + if(data.ItemElementName != ItemChoiceType.OptionA) + { + throw new Exception("A#02"); + } + } +} + +// Below is the code generated from the following XSD: +/* + + + + + + + + + + + +*/ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.239 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// +// This source code was auto-generated by xsd, Version=4.0.30319.1. +// + + +/// +[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")] +[System.SerializableAttribute()] +[System.Diagnostics.DebuggerStepThroughAttribute()] +[System.ComponentModel.DesignerCategoryAttribute("code")] +[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] +[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] +public partial class TASK { + + private object itemField; + + private ItemChoiceType itemElementNameField; + + /// + [System.Xml.Serialization.XmlElementAttribute("OptionA", typeof(object), Order=0)] + [System.Xml.Serialization.XmlElementAttribute("OptionB", typeof(object), Order=0)] + [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemElementName")] + public object Item { + get { + return this.itemField; + } + set { + this.itemField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=1)] + [System.Xml.Serialization.XmlIgnoreAttribute()] + public ItemChoiceType ItemElementName { + get { + return this.itemElementNameField; + } + set { + this.itemElementNameField = value; + } + } +} - static void Main () - { - string myXML = @""; - TASK data = DeserializeFromString(myXML); - System.Console.WriteLine(data); - } +/// +[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")] +[System.SerializableAttribute()] +[System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)] +public enum ItemChoiceType { + + /// + OptionA, + + /// + OptionB, } diff --git a/mono/tests/bug-2907i-lib.cs b/mono/tests/bug-2907i-lib.cs deleted file mode 100644 index 5b869a1dac6..00000000000 --- a/mono/tests/bug-2907i-lib.cs +++ /dev/null @@ -1,69 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.239 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using System.Xml.Serialization; - -// -// This source code was auto-generated by xsd, Version=4.0.30319.1. -// - - -/// -[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")] -[System.SerializableAttribute()] -[System.Diagnostics.DebuggerStepThroughAttribute()] -[System.ComponentModel.DesignerCategoryAttribute("code")] -[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] -[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] -public partial class TASK { - - private object itemField; - - private ItemChoiceType itemElementNameField; - - /// - [System.Xml.Serialization.XmlElementAttribute("OptionA", typeof(object), Order=0)] - [System.Xml.Serialization.XmlElementAttribute("OptionB", typeof(object), Order=0)] - [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemElementName")] - public object Item { - get { - return this.itemField; - } - set { - this.itemField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=1)] - [System.Xml.Serialization.XmlIgnoreAttribute()] - public ItemChoiceType ItemElementName { - get { - return this.itemElementNameField; - } - set { - this.itemElementNameField = value; - } - } -} - -/// -[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")] -[System.SerializableAttribute()] -[System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)] -public enum ItemChoiceType { - - /// - OptionA, - - /// - OptionB, -} -