From 91cf584a6c3b4b8046a6d02d92dcb0b81fa1223e Mon Sep 17 00:00:00 2001 From: Marek Kacprzak Date: Fri, 30 Mar 2018 12:25:26 +0200 Subject: [PATCH 1/5] Add 2 parameters for generator: GenerateSetterInCollection RemoveUderscoreInPriverMember --- XmlSchemaClassGenerator.Console/Program.cs | 7 ++++++- XmlSchemaClassGenerator/CodeUtilities.cs | 8 ++++---- XmlSchemaClassGenerator/Generator.cs | 12 ++++++++++++ XmlSchemaClassGenerator/GeneratorConfiguration.cs | 3 +++ XmlSchemaClassGenerator/TypeModel.cs | 6 ++++-- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/XmlSchemaClassGenerator.Console/Program.cs b/XmlSchemaClassGenerator.Console/Program.cs index 0e95e8ee..3dcaf2aa 100644 --- a/XmlSchemaClassGenerator.Console/Program.cs +++ b/XmlSchemaClassGenerator.Console/Program.cs @@ -35,6 +35,8 @@ static void Main(string[] args) string textValuePropertyName = "Value"; var generateDebuggerStepThroughAttribute = true; var disableComments = false; + var setterInCollection = false; + var removeUnderscoreInPrivateMember = false; var options = new OptionSet { { "h|help", "show this message and exit", v => showHelp = v != null }, @@ -77,6 +79,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l { "tvpn|textValuePropertyName=", "the name of the property that holds the text value of an element (default is Value)", v => textValuePropertyName = v }, { "dst|debuggerStepThrough", "generate DebuggerStepThroughAttribute (default is enabled)", v => generateDebuggerStepThroughAttribute = v != null }, { "dc|disableComments", "do not include comments from xsd", v => disableComments = v != null }, + { "sc|setterInCollection", "generate setter in Collection (default is false)", v => setterInCollection = v != null }, + { "ru|removeUderscore", "do not generate uderscore in priver member name (default is false)", v => removeUnderscoreInPrivateMember = v != null }, }; var files = options.Parse(args); @@ -130,7 +134,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l generator.GenerateDebuggerStepThroughAttribute = false; generator.DataAnnotationMode = DataAnnotationMode.None; } - + generator.GenerateSetterInCollection = setterInCollection; + generator.RemoveUderscoreInPriverMember = removeUnderscoreInPrivateMember; if (verbose) { generator.Log = s => System.Console.Out.WriteLine(s); } generator.Generate(files); diff --git a/XmlSchemaClassGenerator/CodeUtilities.cs b/XmlSchemaClassGenerator/CodeUtilities.cs index 9a43bf69..f53313cf 100644 --- a/XmlSchemaClassGenerator/CodeUtilities.cs +++ b/XmlSchemaClassGenerator/CodeUtilities.cs @@ -27,9 +27,9 @@ public static string ToCamelCase(this string s) return char.ToLowerInvariant(s[0]) + s.Substring(1); } - public static string ToBackingField(this string propertyName) + public static string ToBackingField(this string propertyName, bool removeUderscoreInPriverMember) { - return string.Concat("_", propertyName.ToCamelCase()); + return removeUderscoreInPriverMember ? propertyName.ToCamelCase(): string.Concat("_", propertyName.ToCamelCase()); } private static bool? IsDataTypeAttributeAllowed(XmlTypeCode typeCode, GeneratorConfiguration configuration) @@ -171,8 +171,8 @@ public static string GetUniqueTypeName(this NamespaceModel model, string name) public static string GetUniqueFieldName(this TypeModel typeModel, PropertyModel propertyModel) { - var propBackingFieldName = propertyModel.Name.ToBackingField(); var classModel = typeModel as ClassModel; + var propBackingFieldName = propertyModel.Name.ToBackingField(classModel?.RemoveUderscoreInPriverMember==true); if (classModel == null) { return propBackingFieldName; @@ -192,7 +192,7 @@ public static string GetUniqueFieldName(this TypeModel typeModel, PropertyModel break; } - var backingFieldName = prop.Name.ToBackingField(); + var backingFieldName = prop.Name.ToBackingField(classModel.RemoveUderscoreInPriverMember); if (backingFieldName == propBackingFieldName) { i += 1; diff --git a/XmlSchemaClassGenerator/Generator.cs b/XmlSchemaClassGenerator/Generator.cs index c38a3e8a..36393fd7 100644 --- a/XmlSchemaClassGenerator/Generator.cs +++ b/XmlSchemaClassGenerator/Generator.cs @@ -173,6 +173,17 @@ public bool DisableComments set { _configuration.DisableComments = value; } } + public bool GenerateSetterInCollection + { + get { return _configuration.GenerateSetterInCollection; } + set { _configuration.GenerateSetterInCollection = value; } + } + public bool RemoveUderscoreInPriverMember + { + get { return _configuration.RemoveUderscoreInPriverMember; } + set { _configuration.RemoveUderscoreInPriverMember = value; } + } + private readonly XmlSchemaSet Set = new XmlSchemaSet(); private Dictionary AttributeGroups; private Dictionary Groups; @@ -415,6 +426,7 @@ private TypeModel CreateTypeModel(Uri source, XmlSchemaAnnotated type, XmlQualif IsMixed = complexType.IsMixed, IsSubstitution = complexType.Parent is XmlSchemaElement && !((XmlSchemaElement)complexType.Parent).SubstitutionGroup.IsEmpty, EnableDataBinding = EnableDataBinding, + RemoveUderscoreInPriverMember = RemoveUderscoreInPriverMember }; classModel.Documentation.AddRange(docs); diff --git a/XmlSchemaClassGenerator/GeneratorConfiguration.cs b/XmlSchemaClassGenerator/GeneratorConfiguration.cs index c16d02dc..6e1861ab 100644 --- a/XmlSchemaClassGenerator/GeneratorConfiguration.cs +++ b/XmlSchemaClassGenerator/GeneratorConfiguration.cs @@ -158,5 +158,8 @@ public void WriteLog(string message) public NamingProvider NamingProvider { get; set; } public bool DisableComments { get; set; } + public bool GenerateSetterInCollection { get; set; } + public bool RemoveUderscoreInPriverMember { get; set; } + } } diff --git a/XmlSchemaClassGenerator/TypeModel.cs b/XmlSchemaClassGenerator/TypeModel.cs index 3d1b3325..9161910d 100644 --- a/XmlSchemaClassGenerator/TypeModel.cs +++ b/XmlSchemaClassGenerator/TypeModel.cs @@ -211,6 +211,7 @@ public class ClassModel : TypeModel public List Interfaces { get; set; } public List DerivedTypes { get; set; } public bool EnableDataBinding { get; set; } + public bool RemoveUderscoreInPriverMember { get; set; } public ClassModel(GeneratorConfiguration configuration) : base(configuration) @@ -292,7 +293,7 @@ public override CodeTypeDeclaration Generate() if (EnableDataBinding) { - var backingFieldMember = new CodeMemberField(typeReference, member.Name.ToBackingField()) + var backingFieldMember = new CodeMemberField(typeReference, member.Name.ToBackingField(RemoveUderscoreInPriverMember)) { Attributes = MemberAttributes.Private }; @@ -691,7 +692,8 @@ public void AddMembersTo(CodeTypeDeclaration typeDeclaration, bool withDataBindi else member = new CodeMemberField(typeReference, propertyName); - var isPrivateSetter = IsCollection || isArray; + var isPrivateSetter = !Configuration.GenerateSetterInCollection && (IsCollection || isArray); + if (requiresBackingField) { member.Name += GetAccessors(member.Name, backingField.Name, From 75c813c7ba3930c1f7d50ac5ace8a712a453fa92 Mon Sep 17 00:00:00 2001 From: "marek.kacprzak" Date: Tue, 3 Apr 2018 18:49:12 +0200 Subject: [PATCH 2/5] - Remove duplicate state in ClassModer (In Configuration and in property) - Add checking charp keywords - Changing name - suggestion from Michael - Changing parameter in console nu|noUnderscore --- XmlSchemaClassGenerator.Console/Program.cs | 6 +-- XmlSchemaClassGenerator/CodeUtilities.cs | 42 +++++++++++++++---- XmlSchemaClassGenerator/Generator.cs | 10 ++--- .../GeneratorConfiguration.cs | 2 +- XmlSchemaClassGenerator/TypeModel.cs | 15 +++---- 5 files changed, 49 insertions(+), 26 deletions(-) diff --git a/XmlSchemaClassGenerator.Console/Program.cs b/XmlSchemaClassGenerator.Console/Program.cs index 3dcaf2aa..f11de078 100644 --- a/XmlSchemaClassGenerator.Console/Program.cs +++ b/XmlSchemaClassGenerator.Console/Program.cs @@ -36,7 +36,7 @@ static void Main(string[] args) var generateDebuggerStepThroughAttribute = true; var disableComments = false; var setterInCollection = false; - var removeUnderscoreInPrivateMember = false; + var doNotUseUnderscoreInPrivateMemberNames = false; var options = new OptionSet { { "h|help", "show this message and exit", v => showHelp = v != null }, @@ -80,7 +80,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l { "dst|debuggerStepThrough", "generate DebuggerStepThroughAttribute (default is enabled)", v => generateDebuggerStepThroughAttribute = v != null }, { "dc|disableComments", "do not include comments from xsd", v => disableComments = v != null }, { "sc|setterInCollection", "generate setter in Collection (default is false)", v => setterInCollection = v != null }, - { "ru|removeUderscore", "do not generate uderscore in priver member name (default is false)", v => removeUnderscoreInPrivateMember = v != null }, + { "nu|noUnderscore", "do not generate underscore in private member name (default is false)", v => doNotUseUnderscoreInPrivateMemberNames = v != null }, }; var files = options.Parse(args); @@ -135,7 +135,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l generator.DataAnnotationMode = DataAnnotationMode.None; } generator.GenerateSetterInCollection = setterInCollection; - generator.RemoveUderscoreInPriverMember = removeUnderscoreInPrivateMember; + generator.DoNotUseUnderscoreInPrivateMemberNames = doNotUseUnderscoreInPrivateMemberNames; if (verbose) { generator.Log = s => System.Console.Out.WriteLine(s); } generator.Generate(files); diff --git a/XmlSchemaClassGenerator/CodeUtilities.cs b/XmlSchemaClassGenerator/CodeUtilities.cs index f53313cf..39ecbab1 100644 --- a/XmlSchemaClassGenerator/CodeUtilities.cs +++ b/XmlSchemaClassGenerator/CodeUtilities.cs @@ -27,9 +27,9 @@ public static string ToCamelCase(this string s) return char.ToLowerInvariant(s[0]) + s.Substring(1); } - public static string ToBackingField(this string propertyName, bool removeUderscoreInPriverMember) + public static string ToBackingField(this string propertyName, bool doNotUseUnderscoreInPrivateMemberNames) { - return removeUderscoreInPriverMember ? propertyName.ToCamelCase(): string.Concat("_", propertyName.ToCamelCase()); + return doNotUseUnderscoreInPrivateMemberNames ? propertyName.ToCamelCase() : string.Concat("_", propertyName.ToCamelCase()); } private static bool? IsDataTypeAttributeAllowed(XmlTypeCode typeCode, GeneratorConfiguration configuration) @@ -172,16 +172,20 @@ public static string GetUniqueTypeName(this NamespaceModel model, string name) public static string GetUniqueFieldName(this TypeModel typeModel, PropertyModel propertyModel) { var classModel = typeModel as ClassModel; - var propBackingFieldName = propertyModel.Name.ToBackingField(classModel?.RemoveUderscoreInPriverMember==true); + var propBackingFieldName = propertyModel.Name.ToBackingField(classModel?.Configuration.DoNotUseUnderscoreInPrivateMemberNames == true); + + if (CShaprpKeywords.Contains(propBackingFieldName.ToLower())) + propBackingFieldName = "@" + propBackingFieldName; + if (classModel == null) { return propBackingFieldName; } - + var i = 0; foreach (var prop in classModel.Properties) { - if (!classModel.EnableDataBinding && !(prop.Type is SimpleModel)) + if (!classModel.Configuration.EnableDataBinding && !(prop.Type is SimpleModel)) { continue; } @@ -192,7 +196,7 @@ public static string GetUniqueFieldName(this TypeModel typeModel, PropertyModel break; } - var backingFieldName = prop.Name.ToBackingField(classModel.RemoveUderscoreInPriverMember); + var backingFieldName = prop.Name.ToBackingField(classModel.Configuration.DoNotUseUnderscoreInPrivateMemberNames); if (backingFieldName == propBackingFieldName) { i += 1; @@ -207,11 +211,35 @@ public static string GetUniqueFieldName(this TypeModel typeModel, PropertyModel return string.Format("{0}{1}", propBackingFieldName, i); } - static readonly Regex NormalizeNewlinesRegex = new Regex(@"(^|[^\r])\n",RegexOptions.Compiled); + static readonly Regex NormalizeNewlinesRegex = new Regex(@"(^|[^\r])\n", RegexOptions.Compiled); internal static string NormalizeNewlines(string text) { return NormalizeNewlinesRegex.Replace(text, "$1\r\n"); } + + static readonly List CShaprpKeywords = new List + { + "abstract", "as", "base", "bool", + "break", "byte", "case", "catch", + "char", "checked", "class const", + "continue", "decimal", "default", "delegate", + "do", "double", "else", "enum", + "event", " explicit", "extern", "false", + "finally", "fixed float", "for", + "foreach", "goto", "if", "implicit", + "in", "int interface", "internal", + "is", "lock", "long", "namespace", + "new", "null", "object operator", + "out", "override", "params private", + "protected", "public", "readonly", "ref", + "return", "sbyte sealed short", + "sizeof", "stackalloc", "static string", + "struct", "switch", "this", "throw", + "true", "try", "typeof", "uint", + "ulong", "unchecked", "unsafe ushort", + "using", "using static", "virtual void", + "volatile", "while" + }; } } \ No newline at end of file diff --git a/XmlSchemaClassGenerator/Generator.cs b/XmlSchemaClassGenerator/Generator.cs index 36393fd7..32e60172 100644 --- a/XmlSchemaClassGenerator/Generator.cs +++ b/XmlSchemaClassGenerator/Generator.cs @@ -178,10 +178,10 @@ public bool GenerateSetterInCollection get { return _configuration.GenerateSetterInCollection; } set { _configuration.GenerateSetterInCollection = value; } } - public bool RemoveUderscoreInPriverMember + public bool DoNotUseUnderscoreInPrivateMemberNames { - get { return _configuration.RemoveUderscoreInPriverMember; } - set { _configuration.RemoveUderscoreInPriverMember = value; } + get { return _configuration.DoNotUseUnderscoreInPrivateMemberNames; } + set { _configuration.DoNotUseUnderscoreInPrivateMemberNames = value; } } private readonly XmlSchemaSet Set = new XmlSchemaSet(); @@ -424,9 +424,7 @@ private TypeModel CreateTypeModel(Uri source, XmlSchemaAnnotated type, XmlQualif IsAbstract = complexType.IsAbstract, IsAnonymous = complexType.QualifiedName.Name == "", IsMixed = complexType.IsMixed, - IsSubstitution = complexType.Parent is XmlSchemaElement && !((XmlSchemaElement)complexType.Parent).SubstitutionGroup.IsEmpty, - EnableDataBinding = EnableDataBinding, - RemoveUderscoreInPriverMember = RemoveUderscoreInPriverMember + IsSubstitution = complexType.Parent is XmlSchemaElement && !((XmlSchemaElement)complexType.Parent).SubstitutionGroup.IsEmpty }; classModel.Documentation.AddRange(docs); diff --git a/XmlSchemaClassGenerator/GeneratorConfiguration.cs b/XmlSchemaClassGenerator/GeneratorConfiguration.cs index 6e1861ab..68c69731 100644 --- a/XmlSchemaClassGenerator/GeneratorConfiguration.cs +++ b/XmlSchemaClassGenerator/GeneratorConfiguration.cs @@ -159,7 +159,7 @@ public void WriteLog(string message) public bool DisableComments { get; set; } public bool GenerateSetterInCollection { get; set; } - public bool RemoveUderscoreInPriverMember { get; set; } + public bool DoNotUseUnderscoreInPrivateMemberNames { get; set; } } } diff --git a/XmlSchemaClassGenerator/TypeModel.cs b/XmlSchemaClassGenerator/TypeModel.cs index 9161910d..fe5fef64 100644 --- a/XmlSchemaClassGenerator/TypeModel.cs +++ b/XmlSchemaClassGenerator/TypeModel.cs @@ -45,7 +45,7 @@ public static CodeNamespace Generate(string namespaceName, IEnumerable x.Types.Values).ToList(); - if (typeModels.OfType().Any(x => x.EnableDataBinding)) + if (typeModels.OfType().Any(x => x.Configuration.EnableDataBinding)) { codeNamespace.Imports.Add(new CodeNamespaceImport("System.Linq")); codeNamespace.Imports.Add(new CodeNamespaceImport("System.ComponentModel")); @@ -210,9 +210,6 @@ public class ClassModel : TypeModel public List Properties { get; set; } public List Interfaces { get; set; } public List DerivedTypes { get; set; } - public bool EnableDataBinding { get; set; } - public bool RemoveUderscoreInPriverMember { get; set; } - public ClassModel(GeneratorConfiguration configuration) : base(configuration) { @@ -244,7 +241,7 @@ public override CodeTypeDeclaration Generate() classDeclaration.IsClass = true; classDeclaration.IsPartial = true; - if (EnableDataBinding) + if (Configuration.EnableDataBinding) { classDeclaration.Members.Add(new CodeMemberEvent() { @@ -291,9 +288,9 @@ public override CodeTypeDeclaration Generate() Attributes = MemberAttributes.Public, }; - if (EnableDataBinding) + if (Configuration.EnableDataBinding) { - var backingFieldMember = new CodeMemberField(typeReference, member.Name.ToBackingField(RemoveUderscoreInPriverMember)) + var backingFieldMember = new CodeMemberField(typeReference, member.Name.ToBackingField(Configuration.DoNotUseUnderscoreInPrivateMemberNames)) { Attributes = MemberAttributes.Private }; @@ -326,7 +323,7 @@ public override CodeTypeDeclaration Generate() } } - if (EnableDataBinding) + if (Configuration.EnableDataBinding) { classDeclaration.BaseTypes.Add(new CodeTypeReference(typeof(INotifyPropertyChanged), Configuration.CodeTypeReferenceOptions)); } @@ -354,7 +351,7 @@ public override CodeTypeDeclaration Generate() } foreach (var property in Properties) - property.AddMembersTo(classDeclaration, EnableDataBinding); + property.AddMembersTo(classDeclaration, Configuration.EnableDataBinding); if (IsMixed && (BaseClass == null || (BaseClass is ClassModel && !AllBaseClasses.Any(b => b.IsMixed)))) { From f9d3bdb04aaf0ef49ef607dbd297f802bb0078fb Mon Sep 17 00:00:00 2001 From: "marek.kacprzak" Date: Tue, 3 Apr 2018 19:56:16 +0200 Subject: [PATCH 3/5] fix keywords list --- XmlSchemaClassGenerator/CodeUtilities.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/XmlSchemaClassGenerator/CodeUtilities.cs b/XmlSchemaClassGenerator/CodeUtilities.cs index 39ecbab1..32cdf430 100644 --- a/XmlSchemaClassGenerator/CodeUtilities.cs +++ b/XmlSchemaClassGenerator/CodeUtilities.cs @@ -222,23 +222,23 @@ internal static string NormalizeNewlines(string text) { "abstract", "as", "base", "bool", "break", "byte", "case", "catch", - "char", "checked", "class const", + "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", " explicit", "extern", "false", - "finally", "fixed float", "for", + "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", - "in", "int interface", "internal", + "in", "int", "interface", "internal", "is", "lock", "long", "namespace", - "new", "null", "object operator", - "out", "override", "params private", + "new", "null", "object", "operator", + "out", "override", "params", "private", "protected", "public", "readonly", "ref", - "return", "sbyte sealed short", - "sizeof", "stackalloc", "static string", + "return", "sbyte", "sealed", "short", + "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", - "ulong", "unchecked", "unsafe ushort", - "using", "using static", "virtual void", + "ulong", "unchecked", "unsafe", "ushort", + "using", "using static", "virtual", "void", "volatile", "while" }; } From 13e92ed0d431e99a7734f1ed90dd2fb5436cac71 Mon Sep 17 00:00:00 2001 From: "marek.kacprzak" Date: Wed, 4 Apr 2018 21:18:07 +0200 Subject: [PATCH 4/5] fix spelling --- XmlSchemaClassGenerator/CodeUtilities.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/XmlSchemaClassGenerator/CodeUtilities.cs b/XmlSchemaClassGenerator/CodeUtilities.cs index 32cdf430..e83a4012 100644 --- a/XmlSchemaClassGenerator/CodeUtilities.cs +++ b/XmlSchemaClassGenerator/CodeUtilities.cs @@ -174,7 +174,7 @@ public static string GetUniqueFieldName(this TypeModel typeModel, PropertyModel var classModel = typeModel as ClassModel; var propBackingFieldName = propertyModel.Name.ToBackingField(classModel?.Configuration.DoNotUseUnderscoreInPrivateMemberNames == true); - if (CShaprpKeywords.Contains(propBackingFieldName.ToLower())) + if (CSharpKeywords.Contains(propBackingFieldName.ToLower())) propBackingFieldName = "@" + propBackingFieldName; if (classModel == null) @@ -218,7 +218,7 @@ internal static string NormalizeNewlines(string text) return NormalizeNewlinesRegex.Replace(text, "$1\r\n"); } - static readonly List CShaprpKeywords = new List + static readonly List CSharpKeywords = new List { "abstract", "as", "base", "bool", "break", "byte", "case", "catch", From 773c9110172ab80d585c8e115f93aaaa98d60106 Mon Sep 17 00:00:00 2001 From: "marek.kacprzak" Date: Sun, 8 Apr 2018 20:59:40 +0200 Subject: [PATCH 5/5] remove one option: GenerateSetterInCollection --- XmlSchemaClassGenerator.Console/Program.cs | 3 --- XmlSchemaClassGenerator/Generator.cs | 7 +------ XmlSchemaClassGenerator/GeneratorConfiguration.cs | 1 - XmlSchemaClassGenerator/TypeModel.cs | 2 +- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/XmlSchemaClassGenerator.Console/Program.cs b/XmlSchemaClassGenerator.Console/Program.cs index f11de078..bdabdb7b 100644 --- a/XmlSchemaClassGenerator.Console/Program.cs +++ b/XmlSchemaClassGenerator.Console/Program.cs @@ -35,7 +35,6 @@ static void Main(string[] args) string textValuePropertyName = "Value"; var generateDebuggerStepThroughAttribute = true; var disableComments = false; - var setterInCollection = false; var doNotUseUnderscoreInPrivateMemberNames = false; var options = new OptionSet { @@ -79,7 +78,6 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l { "tvpn|textValuePropertyName=", "the name of the property that holds the text value of an element (default is Value)", v => textValuePropertyName = v }, { "dst|debuggerStepThrough", "generate DebuggerStepThroughAttribute (default is enabled)", v => generateDebuggerStepThroughAttribute = v != null }, { "dc|disableComments", "do not include comments from xsd", v => disableComments = v != null }, - { "sc|setterInCollection", "generate setter in Collection (default is false)", v => setterInCollection = v != null }, { "nu|noUnderscore", "do not generate underscore in private member name (default is false)", v => doNotUseUnderscoreInPrivateMemberNames = v != null }, }; @@ -134,7 +132,6 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l generator.GenerateDebuggerStepThroughAttribute = false; generator.DataAnnotationMode = DataAnnotationMode.None; } - generator.GenerateSetterInCollection = setterInCollection; generator.DoNotUseUnderscoreInPrivateMemberNames = doNotUseUnderscoreInPrivateMemberNames; if (verbose) { generator.Log = s => System.Console.Out.WriteLine(s); } diff --git a/XmlSchemaClassGenerator/Generator.cs b/XmlSchemaClassGenerator/Generator.cs index 32e60172..79f71d07 100644 --- a/XmlSchemaClassGenerator/Generator.cs +++ b/XmlSchemaClassGenerator/Generator.cs @@ -172,12 +172,7 @@ public bool DisableComments get { return _configuration.DisableComments; } set { _configuration.DisableComments = value; } } - - public bool GenerateSetterInCollection - { - get { return _configuration.GenerateSetterInCollection; } - set { _configuration.GenerateSetterInCollection = value; } - } + public bool DoNotUseUnderscoreInPrivateMemberNames { get { return _configuration.DoNotUseUnderscoreInPrivateMemberNames; } diff --git a/XmlSchemaClassGenerator/GeneratorConfiguration.cs b/XmlSchemaClassGenerator/GeneratorConfiguration.cs index 68c69731..97793809 100644 --- a/XmlSchemaClassGenerator/GeneratorConfiguration.cs +++ b/XmlSchemaClassGenerator/GeneratorConfiguration.cs @@ -158,7 +158,6 @@ public void WriteLog(string message) public NamingProvider NamingProvider { get; set; } public bool DisableComments { get; set; } - public bool GenerateSetterInCollection { get; set; } public bool DoNotUseUnderscoreInPrivateMemberNames { get; set; } } diff --git a/XmlSchemaClassGenerator/TypeModel.cs b/XmlSchemaClassGenerator/TypeModel.cs index fe5fef64..72b3ef19 100644 --- a/XmlSchemaClassGenerator/TypeModel.cs +++ b/XmlSchemaClassGenerator/TypeModel.cs @@ -689,7 +689,7 @@ public void AddMembersTo(CodeTypeDeclaration typeDeclaration, bool withDataBindi else member = new CodeMemberField(typeReference, propertyName); - var isPrivateSetter = !Configuration.GenerateSetterInCollection && (IsCollection || isArray); + var isPrivateSetter = IsCollection || isArray; if (requiresBackingField) {