Skip to content

Commit

Permalink
Add vstst test (modified, see #119)
Browse files Browse the repository at this point in the history
Surface GenerateComplexTypesForCollections on cli and make it true by default
  • Loading branch information
Michael Ganss committed Jul 8, 2019
1 parent a928573 commit 1fbc339
Show file tree
Hide file tree
Showing 7 changed files with 3,044 additions and 5 deletions.
8 changes: 6 additions & 2 deletions XmlSampleGenerator/XmlSampleGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,12 @@ private void ProcessGroup(InstanceGroup grp) {
}

private void ProcessChoiceGroup(InstanceGroup grp) {
for (int i=0; i < grp.Occurs; i++) { //Cyclically iterate over the children of choice
ProcessGroup(grp.GetChild(i % grp.NoOfChildren));
if (grp.NoOfChildren > 0)
{
for (int i = 0; i < grp.Occurs; i++)
{ //Cyclically iterate over the children of choice
ProcessGroup(grp.GetChild(i % grp.NoOfChildren));
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion XmlSchemaClassGenerator.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ static void Main(string[] args)
var doNotUseUnderscoreInPrivateMemberNames = false;
var generateDescriptionAttribute = true;
var enableUpaCheck = true;
var generateComplexTypesForCollections = true;

var options = new OptionSet {
{ "h|help", "show this message and exit", v => showHelp = v != null },
Expand Down Expand Up @@ -86,6 +87,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
{ "dc|disableComments", "do not include comments from xsd", v => disableComments = v != null },
{ "nu|noUnderscore", "do not generate underscore in private member name (default is false)", v => doNotUseUnderscoreInPrivateMemberNames = v != null },
{ "da|description", "generate DescriptionAttribute (default is true)", v => generateDescriptionAttribute = v != null },
{ "cc|complexTypesForCollections", "generate complex types for collections (default is true)", v => generateComplexTypesForCollections = v != null },
};

var files = options.Parse(args);
Expand Down Expand Up @@ -132,7 +134,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
DisableComments = disableComments,
GenerateDescriptionAttribute = generateDescriptionAttribute,
PrivateMemberPrefix = doNotUseUnderscoreInPrivateMemberNames ? "" : "_",
EnableUpaCheck = enableUpaCheck
EnableUpaCheck = enableUpaCheck,
GenerateComplexTypesForCollections = generateComplexTypesForCollections
};

if (pclCompatible)
Expand Down
4 changes: 3 additions & 1 deletion XmlSchemaClassGenerator.Tests/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public static Assembly GenerateFiles(string name, IEnumerable<string> files, Gen
GenerateInterfaces = true,
NamespacePrefix = name,
GenerateDescriptionAttribute = true,
TextValuePropertyName = "Value"
};

var output = new FileWatcherOutputWriter(Path.Combine("output", name));
Expand All @@ -100,7 +101,8 @@ public static Assembly GenerateFiles(string name, IEnumerable<string> files, Gen
GenerateInterfaces = generatorPrototype.GenerateInterfaces,
MemberVisitor = generatorPrototype.MemberVisitor,
GenerateDescriptionAttribute = generatorPrototype.GenerateDescriptionAttribute,
CodeTypeReferenceOptions = generatorPrototype.CodeTypeReferenceOptions
CodeTypeReferenceOptions = generatorPrototype.CodeTypeReferenceOptions,
TextValuePropertyName = generatorPrototype.TextValuePropertyName
};

gen.Generate(files);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,12 @@
<None Update="xsd\ts-api\ts-api_2_8.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="xsd\vstst\vstst.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="xsd\vstst\vstst2.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="xsd\wadl\wadl.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
13 changes: 13 additions & 0 deletions XmlSchemaClassGenerator.Tests/XmlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private IEnumerable<string> ConvertXml(string name, string xsd, Generator genera
const string IataPattern = @"xsd\iata\*.xsd";
const string TimePattern = @"xsd\time\time.xsd";
const string TableauPattern = @"xsd\ts-api\*.xsd";
const string VSTstPattern = @"xsd\vstst\vstst.xsd";

// IATA test takes too long to perform every time

Expand Down Expand Up @@ -168,6 +169,18 @@ public void TestTableau()
TestSamples("Tableau", TableauPattern);
}

[Fact, TestPriority(1)]
[UseCulture("en-US")]
public void TestVSTst()
{
Compiler.Generate("VSTst", VSTstPattern, new Generator
{
TextValuePropertyName = "TextValue",
GenerateComplexTypesForCollections = true
});
TestSamples("VSTst", VSTstPattern);
}

private void TestSamples(string name, string pattern)
{
var assembly = Compiler.GetAssembly(name);
Expand Down
Loading

0 comments on commit 1fbc339

Please sign in to comment.