diff --git a/XmlSchemaClassGenerator/Extensions.cs b/XmlSchemaClassGenerator/Extensions.cs index 14cdb241..056d5476 100644 --- a/XmlSchemaClassGenerator/Extensions.cs +++ b/XmlSchemaClassGenerator/Extensions.cs @@ -27,11 +27,6 @@ public static IEnumerable DistinctBy(this IEnumerable x.First()); } - public static string QuoteIfNeeded(this string text) - { - return string.IsNullOrEmpty(text) ? text - : text.Contains(" ") ? "\"" + text + "\"" - : text; - } + public static string QuoteIfNeeded(this string text) => !string.IsNullOrEmpty(text) && text.Contains(" ") ? "\"" + text + "\"" : text; } } diff --git a/XmlSchemaClassGenerator/IXmlSchemaNode.cs b/XmlSchemaClassGenerator/IXmlSchemaNode.cs index d25e69d7..4d5af121 100644 --- a/XmlSchemaClassGenerator/IXmlSchemaNode.cs +++ b/XmlSchemaClassGenerator/IXmlSchemaNode.cs @@ -5,15 +5,11 @@ namespace XmlSchemaClassGenerator { public interface IXmlSchemaNode { - //string Name { get; } string DefaultValue { get; } string FixedValue { get; } XmlSchemaForm Form { get; } XmlQualifiedName QualifiedName { get; } XmlQualifiedName RefName { get; } - //XmlQualifiedName SchemaTypeName { get; } - //XmlSchemaType SchemaType { get; } - //XmlSchemaType NodeSchemaType { get; } XmlSchemaAnnotated Base { get; } XmlSchemaForm FormDefault { get; } @@ -25,24 +21,14 @@ public sealed class XmlSchemaAttributeEx : IXmlSchemaNode public XmlSchemaAttribute Real { get; } - //public string Name => Real.Name; public string DefaultValue => Real.DefaultValue; public string FixedValue => Real.FixedValue; public XmlSchemaForm Form => Real.Form; public XmlQualifiedName QualifiedName => Real.QualifiedName; public XmlQualifiedName RefName => Real.RefName; - //public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName; - //public XmlSchemaSimpleType SchemaType => Real.SchemaType; public XmlSchemaSimpleType AttributeSchemaType => Real.AttributeSchemaType; - public XmlSchemaAnnotated Base => Real; - public XmlSchemaForm FormDefault => Base.GetSchema().AttributeFormDefault; - - //XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType; - - //XmlSchemaType IXmlSchemaNode.NodeSchemaType => AttributeSchemaType; - public XmlSchemaUse Use => Real.Use; public static implicit operator XmlSchemaAttributeEx(XmlSchemaAttribute xs) => new(xs); @@ -55,24 +41,14 @@ public sealed class XmlSchemaElementEx : IXmlSchemaNode public XmlSchemaElement Real { get; } - //public string Name => Real.Name; public string DefaultValue => Real.DefaultValue; public string FixedValue => Real.FixedValue; public XmlSchemaForm Form => Real.Form; public XmlQualifiedName QualifiedName => Real.QualifiedName; public XmlQualifiedName RefName => Real.RefName; - //public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName; - //public XmlSchemaType SchemaType => Real.SchemaType; public XmlSchemaType ElementSchemaType => Real.ElementSchemaType; - public XmlSchemaAnnotated Base => Real; - public XmlSchemaForm FormDefault => Base.GetSchema().ElementFormDefault; - - //XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType; - - //XmlSchemaType IXmlSchemaNode.NodeSchemaType => ElementSchemaType; - public bool IsNillable => Real.IsNillable; public static implicit operator XmlSchemaElementEx(XmlSchemaElement xs) => new(xs); diff --git a/XmlSchemaClassGenerator/ModelBuilder.cs b/XmlSchemaClassGenerator/ModelBuilder.cs index d4d7c2aa..7373efc2 100644 --- a/XmlSchemaClassGenerator/ModelBuilder.cs +++ b/XmlSchemaClassGenerator/ModelBuilder.cs @@ -380,7 +380,7 @@ private TypeModel CreateTypeModel(XmlQualifiedName qualifiedName, XmlSchemaAnnot return typeModelBuilder.Create(type); } - private class TypeModelBuilder + private sealed class TypeModelBuilder { private readonly ModelBuilder builder; private readonly GeneratorConfiguration _configuration; diff --git a/XmlSchemaClassGenerator/TypeModel.cs b/XmlSchemaClassGenerator/TypeModel.cs index 583e1fd6..7a72a269 100644 --- a/XmlSchemaClassGenerator/TypeModel.cs +++ b/XmlSchemaClassGenerator/TypeModel.cs @@ -560,13 +560,14 @@ public void SetSchemaNameAndNamespace(TypeModel owningTypeModel, IXmlSchemaNode internal static string GetAccessors(CodeMemberField backingField = null, bool withDataBinding = false, PropertyValueTypeCode typeCode = PropertyValueTypeCode.Other, bool privateSetter = false) { + var privateString = privateSetter ? "private " : string.Empty; return backingField == null ? " { get; set; }" : CodeUtilities.NormalizeNewlines($@" {{ get {{ return {backingField.Name}; }} - {(privateSetter ? "private " : string.Empty)}set + {privateString}set {{{(typeCode, withDataBinding) switch { (PropertyValueTypeCode.ValueType, true) => $@"