Skip to content

Commit 0126fc1

Browse files
author
Michael Ganss
committed
Merge branch 'master' of github.com:mganss/XmlSchemaClassGenerator
2 parents 9dabc90 + 6807563 commit 0126fc1

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Options:
8383
groups (default is enabled)
8484
-a, --pascal use Pascal case for class and property names (
8585
default is enabled)
86+
-u, --enableUpaCheck should XmlSchemaSet check for Unique Particle
87+
Attribution (UPA) (default is enabled)
8688
--ct, --collectionType=VALUE
8789
collection type to use (default is System.
8890
Collections.ObjectModel.Collection`1)

XmlSchemaClassGenerator.Console/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static void Main(string[] args)
3838
var disableComments = false;
3939
var doNotUseUnderscoreInPrivateMemberNames = false;
4040
var generateDescriptionAttribute = true;
41+
var enableUpaCheck = true;
4142

4243
var options = new OptionSet {
4344
{ "h|help", "show this message and exit", v => showHelp = v != null },
@@ -74,6 +75,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
7475
{ "f|ef", "generate Entity Framework Code First compatible classes", v => entityFramework = v != null },
7576
{ "t|interface", "generate interfaces for groups and attribute groups (default is enabled)", v => interfaces = v != null },
7677
{ "a|pascal", "use Pascal case for class and property names (default is enabled)", v => pascal = v != null },
78+
{ "u|enableUpaCheck", "should XmlSchemaSet check for Unique Particle Attribution (UPA) (default is enabled)", v => enableUpaCheck = v != null },
7779
{ "ct|collectionType=", "collection type to use (default is " + typeof(Collection<>).FullName + ")", v => collectionType = v == null ? typeof(Collection<>) : Type.GetType(v, true) },
7880
{ "cit|collectionImplementationType=", "the default collection type implementation to use (default is null)", v => collectionImplementationType = v == null ? null : Type.GetType(v, true) },
7981
{ "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) },
@@ -126,7 +128,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
126128
GenerateDebuggerStepThroughAttribute = generateDebuggerStepThroughAttribute,
127129
DisableComments = disableComments,
128130
GenerateDescriptionAttribute = generateDescriptionAttribute,
129-
DoNotUseUnderscoreInPrivateMemberNames = doNotUseUnderscoreInPrivateMemberNames
131+
DoNotUseUnderscoreInPrivateMemberNames = doNotUseUnderscoreInPrivateMemberNames,
132+
EnableUpaCheck = enableUpaCheck
130133
};
131134

132135
if (pclCompatible)

XmlSchemaClassGenerator/Generator.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ public bool DoNotUseUnderscoreInPrivateMemberNames
193193
set { _configuration.DoNotUseUnderscoreInPrivateMemberNames = value; }
194194
}
195195

196+
public bool EnableUpaCheck
197+
{
198+
get { return _configuration.EnableUpaCheck; }
199+
set { _configuration.EnableUpaCheck = value; }
200+
}
201+
196202
public void Generate(IEnumerable<string> files)
197203
{
198204
var set = new XmlSchemaSet();
@@ -216,6 +222,7 @@ public void Generate(IEnumerable<string> files)
216222

217223
public void Generate(XmlSchemaSet set)
218224
{
225+
set.CompilationSettings.EnableUpaCheck = EnableUpaCheck;
219226
set.Compile();
220227

221228
var m = new ModelBuilder(_configuration, set);

XmlSchemaClassGenerator/GeneratorConfiguration.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public GeneratorConfiguration()
3535
MemberVisitor = (member, model) => { };
3636
NamingProvider = new NamingProvider(NamingScheme);
3737
Version = VersionProvider.CreateFromAssembly();
38+
EnableUpaCheck = true;
3839
}
3940

4041
/// <summary>
@@ -171,5 +172,10 @@ public void WriteLog(string message)
171172

172173
public bool DisableComments { get; set; }
173174
public bool DoNotUseUnderscoreInPrivateMemberNames { get; set; }
175+
176+
/// <summary>
177+
/// Check for Unique Particle Attribution (UPA) violations
178+
/// </summary>
179+
public bool EnableUpaCheck { get; set; }
174180
}
175181
}

0 commit comments

Comments
 (0)