diff options
5 files changed, 48 insertions, 3 deletions
diff --git a/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XsdDataContractImporter.cs b/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XsdDataContractImporter.cs index 63d66170b40..b05b2bd22f0 100644 --- a/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XsdDataContractImporter.cs +++ b/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XsdDataContractImporter.cs @@ -435,6 +435,12 @@ namespace System.Runtime.Serialization if (seq != null) { + if (seq.Items.Count == 1 && seq.Items [0] is XmlSchemaAny && type.Parent is XmlSchemaElement) { + + // looks like it is not rejected (which contradicts the error message on .NET). See XsdDataContractImporterTest.ImportTestX32(). Also ImporTestX13() for Parent check. + + } else { + foreach (var child in seq.Items) if (!(child is XmlSchemaElement)) throw new InvalidDataContractException (String.Format ("Only local element is allowed as the content of the sequence of the top-level content of a complex type '{0}'. Other particles (sequence, choice, all, any, group ref) are not supported.", qname)); @@ -453,10 +459,12 @@ namespace System.Runtime.Serialization } if (seq.Items.Count == 1) { - var xe = (XmlSchemaElement) seq.Items [0]; - if (xe.MaxOccursString == "unbounded") { + var pt = (XmlSchemaParticle) seq.Items [0]; + var xe = pt as XmlSchemaElement; + if (pt.MaxOccursString == "unbounded") { // import as a collection contract. - if (isDictionary) { + if (pt is XmlSchemaAny) { + } else if (isDictionary) { var kvt = xe.ElementSchemaType as XmlSchemaComplexType; var seq2 = kvt != null ? kvt.Particle as XmlSchemaSequence : null; var k = seq2 != null && seq2.Items.Count == 2 ? seq2.Items [0] as XmlSchemaElement : null; @@ -503,6 +511,7 @@ namespace System.Runtime.Serialization AddProperty (td, xe); } + } // if (seq contains only an xs:any) } // if (seq != 0) AddTypeAttributes (td, type); diff --git a/mcs/class/System.Runtime.Serialization/Test/Resources/Schemas/ns-readme.txt b/mcs/class/System.Runtime.Serialization/Test/Resources/Schemas/ns-readme.txt index d34d825e9ee..f7e2c1beccc 100644 --- a/mcs/class/System.Runtime.Serialization/Test/Resources/Schemas/ns-readme.txt +++ b/mcs/class/System.Runtime.Serialization/Test/Resources/Schemas/ns-readme.txt @@ -17,6 +17,7 @@ ns10.xsd : contains element with substitutionGroup. E2 is resolved to be ns11.xsd : contains xs:choice as the particle, not supported in WCF(!) ns12.xsd : contains xs:all as the particle, not supported in WCF(!) ns13.xsd : contains xs:any as the content of xs:sequence, not supported in WCF. + see also ns33.xsd which contains an xs:element and thus OK. ns14.xsd : contains simple content restriction by enum. Mapped to CLI enum. ns15.xsd : contains simple list by string, not supported in WCF. ns16.xsd : contains simple list by embedded enumeration string type. @@ -38,3 +39,7 @@ ns28.xsd : dictionary collection type. ns29.xsd : variation of ns28, removed Value. Error. ns30.xsd : variation of ns28, customized name. Shown in [DataMember]. ns31.xsd : variation of ns28, removed IsDictionary appInfo. Becomes List<T>. +ns32.xsd : variation of ns13, moved xs:complexType under xs:element and thus + became OK. (despite the error message explicitly prohibits this!) +ns33.xsd : variation of ns13, replaced xs:any with xs:element and became OK + (despite the error message explicitly prohibits this!) diff --git a/mcs/class/System.Runtime.Serialization/Test/Resources/Schemas/ns32.xsd b/mcs/class/System.Runtime.Serialization/Test/Resources/Schemas/ns32.xsd new file mode 100644 index 00000000000..e3100ee54cc --- /dev/null +++ b/mcs/class/System.Runtime.Serialization/Test/Resources/Schemas/ns32.xsd @@ -0,0 +1,10 @@ +<xs:schema targetNamespace="urn:bar" xmlns="urn:bar" + xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> + <xs:element name="E1"> + <xs:complexType> + <xs:sequence> + <xs:any /> + </xs:sequence> + </xs:complexType> + </xs:element> +</xs:schema> diff --git a/mcs/class/System.Runtime.Serialization/Test/Resources/Schemas/ns33.xsd b/mcs/class/System.Runtime.Serialization/Test/Resources/Schemas/ns33.xsd new file mode 100644 index 00000000000..2d31c5fe702 --- /dev/null +++ b/mcs/class/System.Runtime.Serialization/Test/Resources/Schemas/ns33.xsd @@ -0,0 +1,9 @@ +<xs:schema targetNamespace="urn:bar" xmlns="urn:bar" + xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> + <xs:element name="E1" type="T1" /> + <xs:complexType name="T1"> + <xs:sequence> + <xs:element name="x" /> + </xs:sequence> + </xs:complexType> +</xs:schema> diff --git a/mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/XsdDataContractImporterTest.cs b/mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/XsdDataContractImporterTest.cs index a506b808020..b20fedd4103 100644 --- a/mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/XsdDataContractImporterTest.cs +++ b/mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/XsdDataContractImporterTest.cs @@ -632,6 +632,18 @@ namespace MonoTests.System.Runtime.Serialization DoImport ("Test/Resources/Schemas/ns31.xsd"); } + [Test] + public void ImportTestX32 () + { + DoImport ("Test/Resources/Schemas/ns32.xsd"); + } + + [Test] + public void ImportTestX33 () + { + DoImport ("Test/Resources/Schemas/ns32.xsd"); + } + /* Helper methods */ private void CheckDC (CodeTypeDeclaration type, string name, Dictionary<string, string> members, string msg) { |