diff --git a/XmlSchemaClassGenerator.Tests/Compiler.cs b/XmlSchemaClassGenerator.Tests/Compiler.cs index 6a3b134e..5cec2c3b 100644 --- a/XmlSchemaClassGenerator.Tests/Compiler.cs +++ b/XmlSchemaClassGenerator.Tests/Compiler.cs @@ -102,7 +102,8 @@ public static Assembly GenerateFiles(string name, IEnumerable files, Gen MemberVisitor = generatorPrototype.MemberVisitor, GenerateDescriptionAttribute = generatorPrototype.GenerateDescriptionAttribute, CodeTypeReferenceOptions = generatorPrototype.CodeTypeReferenceOptions, - TextValuePropertyName = generatorPrototype.TextValuePropertyName + TextValuePropertyName = generatorPrototype.TextValuePropertyName, + EmitOrder = generatorPrototype.EmitOrder }; gen.Generate(files); diff --git a/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj b/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj index 7e6bf6c9..d707ece6 100644 --- a/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj +++ b/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj @@ -179,6 +179,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/XmlSchemaClassGenerator.Tests/XmlTests.cs b/XmlSchemaClassGenerator.Tests/XmlTests.cs index 2cd9afa9..2f357344 100644 --- a/XmlSchemaClassGenerator.Tests/XmlTests.cs +++ b/XmlSchemaClassGenerator.Tests/XmlTests.cs @@ -71,6 +71,7 @@ private IEnumerable ConvertXml(string name, string xsd, Generator genera const string WadlPattern = @"xsd\wadl\*.xsd"; const string ListPattern = @"xsd\list\list.xsd"; const string SimplePattern = @"xsd\simple\simple.xsd"; + const string ArrayOrderPattern = @"xsd\array-order\array-order.xsd"; const string ClientPattern = @"xsd\client\client.xsd"; const string IataPattern = @"xsd\iata\*.xsd"; const string TimePattern = @"xsd\time\time.xsd"; @@ -131,6 +132,18 @@ public void TestSimple() TestSamples("Simple", SimplePattern); } + [Fact, TestPriority(1)] + [UseCulture("en-US")] + public void TestArrayOrder() + { + Compiler.Generate("ArrayOrder", ArrayOrderPattern, new Generator + { + NamespacePrefix = "ArrayOrder", + EmitOrder = true + }); + TestSamples("ArrayOrder", ArrayOrderPattern); + } + [Fact, TestPriority(1)] [UseCulture("en-US")] public void TestIS24RestApi() diff --git a/XmlSchemaClassGenerator.Tests/xsd/array-order/array-order.xsd b/XmlSchemaClassGenerator.Tests/xsd/array-order/array-order.xsd new file mode 100644 index 00000000..fa4c8d7e --- /dev/null +++ b/XmlSchemaClassGenerator.Tests/xsd/array-order/array-order.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/XmlSchemaClassGenerator/TypeModel.cs b/XmlSchemaClassGenerator/TypeModel.cs index 08370166..9c8aded9 100644 --- a/XmlSchemaClassGenerator/TypeModel.cs +++ b/XmlSchemaClassGenerator/TypeModel.cs @@ -1048,8 +1048,11 @@ private IEnumerable GetAttributes(bool isArray) } else { - attributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(XmlArrayAttribute), Configuration.CodeTypeReferenceOptions), - new CodeAttributeArgument(new CodePrimitiveExpression(XmlSchemaName.Name)))); + var arrayAttribute = new CodeAttributeDeclaration(new CodeTypeReference(typeof(XmlArrayAttribute), Configuration.CodeTypeReferenceOptions), + new CodeAttributeArgument(new CodePrimitiveExpression(XmlSchemaName.Name))); + if (Order != null) + arrayAttribute.Arguments.Add(new CodeAttributeArgument("Order", new CodePrimitiveExpression(Order.Value))); + attributes.Add(arrayAttribute); } foreach (var attribute in attributes)