Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mganss/XmlSchemaClassGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Dec 21, 2018
2 parents 9dabc90 + 6807563 commit 0126fc1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Options:
groups (default is enabled)
-a, --pascal use Pascal case for class and property names (
default is enabled)
-u, --enableUpaCheck should XmlSchemaSet check for Unique Particle
Attribution (UPA) (default is enabled)
--ct, --collectionType=VALUE
collection type to use (default is System.
Collections.ObjectModel.Collection`1)
Expand Down
5 changes: 4 additions & 1 deletion XmlSchemaClassGenerator.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static void Main(string[] args)
var disableComments = false;
var doNotUseUnderscoreInPrivateMemberNames = false;
var generateDescriptionAttribute = true;
var enableUpaCheck = true;

var options = new OptionSet {
{ "h|help", "show this message and exit", v => showHelp = v != null },
Expand Down Expand Up @@ -74,6 +75,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
{ "f|ef", "generate Entity Framework Code First compatible classes", v => entityFramework = v != null },
{ "t|interface", "generate interfaces for groups and attribute groups (default is enabled)", v => interfaces = v != null },
{ "a|pascal", "use Pascal case for class and property names (default is enabled)", v => pascal = v != null },
{ "u|enableUpaCheck", "should XmlSchemaSet check for Unique Particle Attribution (UPA) (default is enabled)", v => enableUpaCheck = v != null },
{ "ct|collectionType=", "collection type to use (default is " + typeof(Collection<>).FullName + ")", v => collectionType = v == null ? typeof(Collection<>) : Type.GetType(v, true) },
{ "cit|collectionImplementationType=", "the default collection type implementation to use (default is null)", v => collectionImplementationType = v == null ? null : Type.GetType(v, true) },
{ "ctro|codeTypeReferenceOptions=", "the default CodeTypeReferenceOptions Flags to use (default is unset; can be: {GlobalReference, GenericTypeParameter})", v => codeTypeReferenceOptions = v == null ? default(CodeTypeReferenceOptions) : (CodeTypeReferenceOptions)Enum.Parse(typeof(CodeTypeReferenceOptions), v, false) },
Expand Down Expand Up @@ -126,7 +128,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
GenerateDebuggerStepThroughAttribute = generateDebuggerStepThroughAttribute,
DisableComments = disableComments,
GenerateDescriptionAttribute = generateDescriptionAttribute,
DoNotUseUnderscoreInPrivateMemberNames = doNotUseUnderscoreInPrivateMemberNames
DoNotUseUnderscoreInPrivateMemberNames = doNotUseUnderscoreInPrivateMemberNames,
EnableUpaCheck = enableUpaCheck
};

if (pclCompatible)
Expand Down
7 changes: 7 additions & 0 deletions XmlSchemaClassGenerator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ public bool DoNotUseUnderscoreInPrivateMemberNames
set { _configuration.DoNotUseUnderscoreInPrivateMemberNames = value; }
}

public bool EnableUpaCheck
{
get { return _configuration.EnableUpaCheck; }
set { _configuration.EnableUpaCheck = value; }
}

public void Generate(IEnumerable<string> files)
{
var set = new XmlSchemaSet();
Expand All @@ -216,6 +222,7 @@ public void Generate(IEnumerable<string> files)

public void Generate(XmlSchemaSet set)
{
set.CompilationSettings.EnableUpaCheck = EnableUpaCheck;
set.Compile();

var m = new ModelBuilder(_configuration, set);
Expand Down
6 changes: 6 additions & 0 deletions XmlSchemaClassGenerator/GeneratorConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public GeneratorConfiguration()
MemberVisitor = (member, model) => { };
NamingProvider = new NamingProvider(NamingScheme);
Version = VersionProvider.CreateFromAssembly();
EnableUpaCheck = true;
}

/// <summary>
Expand Down Expand Up @@ -171,5 +172,10 @@ public void WriteLog(string message)

public bool DisableComments { get; set; }
public bool DoNotUseUnderscoreInPrivateMemberNames { get; set; }

/// <summary>
/// Check for Unique Particle Attribution (UPA) violations
/// </summary>
public bool EnableUpaCheck { get; set; }
}
}

0 comments on commit 0126fc1

Please sign in to comment.