From: Daniel C. \(kzu\) <dca...@us...> - 2005-11-15 17:29:30
|
Update of /cvsroot/mvp-xml/Design/v2/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19060/v2/tests Modified Files: CustomerSchema.Serialization.cs CustomerSchema.cs Log Message: Updated tests and generator for a bug in debug compilations of the generator when multiple types are generated, that causes generation of code that didn't compile. Index: CustomerSchema.Serialization.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/tests/CustomerSchema.Serialization.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CustomerSchema.Serialization.cs 31 Oct 2005 12:28:17 -0000 1.3 +++ CustomerSchema.Serialization.cs 15 Nov 2005 17:29:04 -0000 1.4 @@ -1,3 +1,283 @@ +#region Original XmlSerializer code +/* ------------------------------------------------------------------------------------- +#if _DYNAMIC_XMLSERIALIZER_COMPILATION +[assembly:System.Security.AllowPartiallyTrustedCallers()] +[assembly:System.Security.SecurityTransparent()] +#endif +[assembly:System.Reflection.AssemblyVersionAttribute("1.0.2145.25559")] +namespace Microsoft.Xml.Serialization.GeneratedAssembly { + + public class XmlSerializationWriterCustomerSchema : System.Xml.Serialization.XmlSerializationWriter { + + public void Write4_CustomerSchema(object o) { + WriteStartDocument(); + if (o == null) { + WriteEmptyTag(@"CustomerSchema", @"http://tempuri.org/CustomerSchema.xsd"); + return; + } + TopLevelElement(); + Write3_CustomerSchema(@"CustomerSchema", @"http://tempuri.org/CustomerSchema.xsd", ((global::Mvp.Xml.Design.Tests.CustomerSchema)o), false, false); + } + + void Write3_CustomerSchema(string n, string ns, global::Mvp.Xml.Design.Tests.CustomerSchema o, bool isNullable, bool needType) { + if ((object)o == null) { + if (isNullable) WriteNullTagLiteral(n, ns); + return; + } + if (!needType) { + System.Type t = o.GetType(); + if (t == typeof(global::Mvp.Xml.Design.Tests.CustomerSchema)) { + } + else { + throw CreateUnknownTypeException(o); + } + } + WriteStartElement(n, ns, o, false, null); + if (needType) WriteXsiType(null, @"http://tempuri.org/CustomerSchema.xsd"); + WriteElementString(@"Name", @"http://tempuri.org/CustomerSchema.xsd", ((global::System.String)o.@Name)); + Write2_CustomerSchemaOrders(@"Orders", @"http://tempuri.org/CustomerSchema.xsd", ((global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)o.@Orders), false, false); + WriteEndElement(o); + } + + void Write2_CustomerSchemaOrders(string n, string ns, global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o, bool isNullable, bool needType) { + if ((object)o == null) { + if (isNullable) WriteNullTagLiteral(n, ns); + return; + } + if (!needType) { + System.Type t = o.GetType(); + if (t == typeof(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)) { + } + else { + throw CreateUnknownTypeException(o); + } + } + WriteStartElement(n, ns, o, false, null); + if (needType) WriteXsiType(null, @"http://tempuri.org/CustomerSchema.xsd"); + WriteElementStringRaw(@"Date", @"http://tempuri.org/CustomerSchema.xsd", FromDateTime(((global::System.DateTime)o.@Date))); + WriteEndElement(o); + } + + protected override void InitCallbacks() { + } + } + + public class XmlSerializationReaderCustomerSchema : System.Xml.Serialization.XmlSerializationReader { + + public object Read4_CustomerSchema() { + object o = null; + Reader.MoveToContent(); + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (((object) Reader.LocalName == (object)id1_CustomerSchema && (object) Reader.NamespaceURI == (object)id2_Item)) { + o = Read3_CustomerSchema(false, true); + } + else { + throw CreateUnknownNodeException(); + } + } + else { + UnknownNode(null, @"http://tempuri.org/CustomerSchema.xsd:CustomerSchema"); + } + return (object)o; + } + + global::Mvp.Xml.Design.Tests.CustomerSchema Read3_CustomerSchema(bool isNullable, bool checkType) { + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + bool isNull = false; + if (isNullable) isNull = ReadNull(); + if (checkType) { + if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id3_Item && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) { + } + else + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); + } + if (isNull) return null; + global::Mvp.Xml.Design.Tests.CustomerSchema o; + o = new global::Mvp.Xml.Design.Tests.CustomerSchema(); + bool[] paramsRead = new bool[2]; + while (Reader.MoveToNextAttribute()) { + if (!IsXmlnsAttribute(Reader.Name)) { + UnknownNode((object)o); + } + } + Reader.MoveToElement(); + if (Reader.IsEmptyElement) { + Reader.Skip(); + return o; + } + Reader.ReadStartElement(); + Reader.MoveToContent(); + int whileIterations0 = 0; + int readerCount0 = ReaderCount; + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (!paramsRead[0] && ((object) Reader.LocalName == (object)id4_Name && (object) Reader.NamespaceURI == (object)id2_Item)) { + { + o.@Name = Reader.ReadElementString(); + } + paramsRead[0] = true; + } + else if (!paramsRead[1] && ((object) Reader.LocalName == (object)id5_Orders && (object) Reader.NamespaceURI == (object)id2_Item)) { + o.@Orders = Read2_CustomerSchemaOrders(false, true); + paramsRead[1] = true; + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Name, http://tempuri.org/CustomerSchema.xsd:Orders"); + } + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Name, http://tempuri.org/CustomerSchema.xsd:Orders"); + } + Reader.MoveToContent(); + CheckReaderCount(ref whileIterations0, ref readerCount0); + } + ReadEndElement(); + return o; + } + + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders Read2_CustomerSchemaOrders(bool isNullable, bool checkType) { + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + bool isNull = false; + if (isNullable) isNull = ReadNull(); + if (checkType) { + if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id3_Item && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) { + } + else + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); + } + if (isNull) return null; + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o; + o = new global::Mvp.Xml.Design.Tests.CustomerSchemaOrders(); + bool[] paramsRead = new bool[1]; + while (Reader.MoveToNextAttribute()) { + if (!IsXmlnsAttribute(Reader.Name)) { + UnknownNode((object)o); + } + } + Reader.MoveToElement(); + if (Reader.IsEmptyElement) { + Reader.Skip(); + return o; + } + Reader.ReadStartElement(); + Reader.MoveToContent(); + int whileIterations1 = 0; + int readerCount1 = ReaderCount; + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (!paramsRead[0] && ((object) Reader.LocalName == (object)id6_Date && (object) Reader.NamespaceURI == (object)id2_Item)) { + { + o.@Date = ToDateTime(Reader.ReadElementString()); + } + paramsRead[0] = true; + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Date"); + } + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Date"); + } + Reader.MoveToContent(); + CheckReaderCount(ref whileIterations1, ref readerCount1); + } + ReadEndElement(); + return o; + } + + protected override void InitCallbacks() { + } + + string id1_CustomerSchema; + string id4_Name; + string id2_Item; + string id6_Date; + string id3_Item; + string id5_Orders; + + protected override void InitIDs() { + id1_CustomerSchema = Reader.NameTable.Add(@"CustomerSchema"); + id4_Name = Reader.NameTable.Add(@"Name"); + id2_Item = Reader.NameTable.Add(@"http://tempuri.org/CustomerSchema.xsd"); + id6_Date = Reader.NameTable.Add(@"Date"); + id3_Item = Reader.NameTable.Add(@""); + id5_Orders = Reader.NameTable.Add(@"Orders"); + } + } + + public abstract class XmlSerializer1 : System.Xml.Serialization.XmlSerializer { + protected override System.Xml.Serialization.XmlSerializationReader CreateReader() { + return new XmlSerializationReaderCustomerSchema(); + } + protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() { + return new XmlSerializationWriterCustomerSchema(); + } + } + + public sealed class CustomerSchemaSerializer : XmlSerializer1 { + + public override System.Boolean CanDeserialize(System.Xml.XmlReader xmlReader) { + return xmlReader.IsStartElement(@"CustomerSchema", @"http://tempuri.org/CustomerSchema.xsd"); + } + + protected override void Serialize(object objectToSerialize, System.Xml.Serialization.XmlSerializationWriter writer) { + ((XmlSerializationWriterCustomerSchema)writer).Write4_CustomerSchema(objectToSerialize); + } + + protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) { + return ((XmlSerializationReaderCustomerSchema)reader).Read4_CustomerSchema(); + } + } + + public class XmlSerializerContract : global::System.Xml.Serialization.XmlSerializerImplementation { + public override global::System.Xml.Serialization.XmlSerializationReader Reader { get { return new XmlSerializationReaderCustomerSchema(); } } + public override global::System.Xml.Serialization.XmlSerializationWriter Writer { get { return new XmlSerializationWriterCustomerSchema(); } } + System.Collections.Hashtable readMethods = null; + public override System.Collections.Hashtable ReadMethods { + get { + if (readMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchema:http://tempuri.org/CustomerSchema.xsd::False:"] = @"Read4_CustomerSchema"; + if (readMethods == null) readMethods = _tmp; + } + return readMethods; + } + } + System.Collections.Hashtable writeMethods = null; + public override System.Collections.Hashtable WriteMethods { + get { + if (writeMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchema:http://tempuri.org/CustomerSchema.xsd::False:"] = @"Write4_CustomerSchema"; + if (writeMethods == null) writeMethods = _tmp; + } + return writeMethods; + } + } + System.Collections.Hashtable typedSerializers = null; + public override System.Collections.Hashtable TypedSerializers { + get { + if (typedSerializers == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp.Add(@"Mvp.Xml.Design.Tests.CustomerSchema:http://tempuri.org/CustomerSchema.xsd::False:", new CustomerSchemaSerializer()); + if (typedSerializers == null) typedSerializers = _tmp; + } + return typedSerializers; + } + } + public override System.Boolean CanSerialize(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchema)) return true; + return false; + } + public override System.Xml.Serialization.XmlSerializer GetSerializer(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchema)) return new CustomerSchemaSerializer(); + return null; + } + } +} + +-------------------------------------------------------------------------------------*/ +#endregion //------------------------------------------------------------------------------ // <autogenerated> // This code was generated by the Mvp.Xml.XGen tool. @@ -402,7 +682,209 @@ } -#pragma warning restore 0642, 0219//------------------------------------------------------------------------------ +#pragma warning restore 0642, 0219 + +#region Original XmlSerializer code +/* ------------------------------------------------------------------------------------- +#if _DYNAMIC_XMLSERIALIZER_COMPILATION +[assembly:System.Security.AllowPartiallyTrustedCallers()] +[assembly:System.Security.SecurityTransparent()] +#endif +[assembly:System.Reflection.AssemblyVersionAttribute("1.0.2145.25559")] +namespace Microsoft.Xml.Serialization.GeneratedAssembly { + + public class XmlSerializationWriterCustomerSchemaOrders : System.Xml.Serialization.XmlSerializationWriter { + + public void Write3_CustomerSchemaOrders(object o) { + WriteStartDocument(); + if (o == null) { + WriteNullTagLiteral(@"CustomerSchemaOrders", @""); + return; + } + TopLevelElement(); + Write2_CustomerSchemaOrders(@"CustomerSchemaOrders", @"", ((global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)o), true, false); + } + + void Write2_CustomerSchemaOrders(string n, string ns, global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o, bool isNullable, bool needType) { + if ((object)o == null) { + if (isNullable) WriteNullTagLiteral(n, ns); + return; + } + if (!needType) { + System.Type t = o.GetType(); + if (t == typeof(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)) { + } + else { + throw CreateUnknownTypeException(o); + } + } + WriteStartElement(n, ns, o, false, null); + if (needType) WriteXsiType(null, @""); + WriteElementStringRaw(@"Date", @"", FromDateTime(((global::System.DateTime)o.@Date))); + WriteEndElement(o); + } + + protected override void InitCallbacks() { + } + } + + public class XmlSerializationReaderCustomerSchemaOrders : System.Xml.Serialization.XmlSerializationReader { + + public object Read3_CustomerSchemaOrders() { + object o = null; + Reader.MoveToContent(); + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (((object) Reader.LocalName == (object)id1_CustomerSchemaOrders && (object) Reader.NamespaceURI == (object)id2_Item)) { + o = Read2_CustomerSchemaOrders(true, true); + } + else { + throw CreateUnknownNodeException(); + } + } + else { + UnknownNode(null, @":CustomerSchemaOrders"); + } + return (object)o; + } + + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders Read2_CustomerSchemaOrders(bool isNullable, bool checkType) { + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + bool isNull = false; + if (isNullable) isNull = ReadNull(); + if (checkType) { + if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id2_Item && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) { + } + else + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); + } + if (isNull) return null; + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o; + o = new global::Mvp.Xml.Design.Tests.CustomerSchemaOrders(); + bool[] paramsRead = new bool[1]; + while (Reader.MoveToNextAttribute()) { + if (!IsXmlnsAttribute(Reader.Name)) { + UnknownNode((object)o); + } + } + Reader.MoveToElement(); + if (Reader.IsEmptyElement) { + Reader.Skip(); + return o; + } + Reader.ReadStartElement(); + Reader.MoveToContent(); + int whileIterations0 = 0; + int readerCount0 = ReaderCount; + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (!paramsRead[0] && ((object) Reader.LocalName == (object)id3_Date && (object) Reader.NamespaceURI == (object)id2_Item)) { + { + o.@Date = ToDateTime(Reader.ReadElementString()); + } + paramsRead[0] = true; + } + else { + UnknownNode((object)o, @":Date"); + } + } + else { + UnknownNode((object)o, @":Date"); + } + Reader.MoveToContent(); + CheckReaderCount(ref whileIterations0, ref readerCount0); + } + ReadEndElement(); + return o; + } + + protected override void InitCallbacks() { + } + + string id1_CustomerSchemaOrders; + string id3_Date; + string id2_Item; + + protected override void InitIDs() { + id1_CustomerSchemaOrders = Reader.NameTable.Add(@"CustomerSchemaOrders"); + id3_Date = Reader.NameTable.Add(@"Date"); + id2_Item = Reader.NameTable.Add(@""); + } + } + + public abstract class XmlSerializer1 : System.Xml.Serialization.XmlSerializer { + protected override System.Xml.Serialization.XmlSerializationReader CreateReader() { + return new XmlSerializationReaderCustomerSchemaOrders(); + } + protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() { + return new XmlSerializationWriterCustomerSchemaOrders(); + } + } + + public sealed class CustomerSchemaOrdersSerializer : XmlSerializer1 { + + public override System.Boolean CanDeserialize(System.Xml.XmlReader xmlReader) { + return xmlReader.IsStartElement(@"CustomerSchemaOrders", @""); + } + + protected override void Serialize(object objectToSerialize, System.Xml.Serialization.XmlSerializationWriter writer) { + ((XmlSerializationWriterCustomerSchemaOrders)writer).Write3_CustomerSchemaOrders(objectToSerialize); + } + + protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) { + return ((XmlSerializationReaderCustomerSchemaOrders)reader).Read3_CustomerSchemaOrders(); + } + } + + public class XmlSerializerContract : global::System.Xml.Serialization.XmlSerializerImplementation { + public override global::System.Xml.Serialization.XmlSerializationReader Reader { get { return new XmlSerializationReaderCustomerSchemaOrders(); } } + public override global::System.Xml.Serialization.XmlSerializationWriter Writer { get { return new XmlSerializationWriterCustomerSchemaOrders(); } } + System.Collections.Hashtable readMethods = null; + public override System.Collections.Hashtable ReadMethods { + get { + if (readMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchemaOrders::"] = @"Read3_CustomerSchemaOrders"; + if (readMethods == null) readMethods = _tmp; + } + return readMethods; + } + } + System.Collections.Hashtable writeMethods = null; + public override System.Collections.Hashtable WriteMethods { + get { + if (writeMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchemaOrders::"] = @"Write3_CustomerSchemaOrders"; + if (writeMethods == null) writeMethods = _tmp; + } + return writeMethods; + } + } + System.Collections.Hashtable typedSerializers = null; + public override System.Collections.Hashtable TypedSerializers { + get { + if (typedSerializers == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp.Add(@"Mvp.Xml.Design.Tests.CustomerSchemaOrders::", new CustomerSchemaOrdersSerializer()); + if (typedSerializers == null) typedSerializers = _tmp; + } + return typedSerializers; + } + } + public override System.Boolean CanSerialize(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)) return true; + return false; + } + public override System.Xml.Serialization.XmlSerializer GetSerializer(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)) return new CustomerSchemaOrdersSerializer(); + return null; + } + } +} + +-------------------------------------------------------------------------------------*/ +#endregion +//------------------------------------------------------------------------------ // <autogenerated> // This code was generated by the Mvp.Xml.XGen tool. // Tool Version: 1.1.1.0 @@ -706,3 +1188,5 @@ #pragma warning restore 0642, 0219 + + Index: CustomerSchema.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/tests/CustomerSchema.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CustomerSchema.cs 31 Oct 2005 09:31:24 -0000 1.1 +++ CustomerSchema.cs 15 Nov 2005 17:29:04 -0000 1.2 @@ -1,3 +1,15 @@ +//------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by the Mvp.Xml.XsdGen tool. +// Tool Version: 1.1.1.0 +// Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +//------------------------------------------------------------------------------ +// Workaround for bug http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=d457a36e-0ce8-4368-9a27-92762860d8e1 +#pragma warning disable 1591 namespace Mvp.Xml.Design.Tests { @@ -68,3 +80,5 @@ } } } + +#pragma warning restore 1591 \ No newline at end of file |