diff --git a/XmlSchemaClassGenerator.Tests/XmlTests.cs b/XmlSchemaClassGenerator.Tests/XmlTests.cs index 09bffb02..caad02e1 100644 --- a/XmlSchemaClassGenerator.Tests/XmlTests.cs +++ b/XmlSchemaClassGenerator.Tests/XmlTests.cs @@ -45,6 +45,7 @@ private Assembly Compile(string name, string pattern) IntegerDataType = typeof(int), DataAnnotationMode = DataAnnotationMode.Partial, GenerateDesignerCategoryAttribute = false, + EnableDataBinding = true }; var files = Glob.Glob.ExpandNames(pattern); diff --git a/XmlSchemaClassGenerator/Generator.cs b/XmlSchemaClassGenerator/Generator.cs index bbbf0e0b..4d1f525d 100644 --- a/XmlSchemaClassGenerator/Generator.cs +++ b/XmlSchemaClassGenerator/Generator.cs @@ -183,7 +183,7 @@ private string BuildNamespace(Uri source, string xmlNamespace) var result = NamespaceProvider.FindNamespace(key); if (!string.IsNullOrEmpty(result)) return result; - + throw new Exception(string.Format("Namespace {0} not provided through map or generator.", xmlNamespace)); } @@ -390,7 +390,7 @@ private IEnumerable GetAttributes(XmlSchemaObjectCollection } // see http://msdn.microsoft.com/en-us/library/z2w0sxhf.aspx - private static readonly HashSet EnumTypes = new HashSet(StringComparer.OrdinalIgnoreCase) + private static readonly HashSet EnumTypes = new HashSet(StringComparer.OrdinalIgnoreCase) { "string", "normalizedString", "token", "Name", "NCName", "ID", "ENTITY", "NMTOKEN" }; // ReSharper disable once FunctionComplexityOverflow @@ -562,8 +562,8 @@ private TypeModel CreateTypeModel(Uri source, XmlSchemaType type, XmlQualifiedNa .Select(s => new XmlQualifiedName(attributeQualifiedName.Name + s, attributeQualifiedName.Namespace)) .First(n => !NameExists(n)); } - } - + } + var attributeName = ToTitleCase(attribute.QualifiedName.Name); if (attributeName == classModel.Name) attributeName += "Property"; // member names cannot be the same as their enclosing type diff --git a/XmlSchemaClassGenerator/TypeModel.cs b/XmlSchemaClassGenerator/TypeModel.cs index f744a51e..bdc203a2 100644 --- a/XmlSchemaClassGenerator/TypeModel.cs +++ b/XmlSchemaClassGenerator/TypeModel.cs @@ -465,7 +465,8 @@ public void AddMembersTo(CodeTypeDeclaration typeDeclaration, bool withDataBindi var isPrivateSetter = IsCollection || isArray; if (requiresBackingField) { - member.Name += GetAccessors(member.Name, backingField.Name, propertyType.GetPropertyValueTypeCode(), + member.Name += GetAccessors(member.Name, backingField.Name, + IsCollection || isArray ? PropertyValueTypeCode.Array : propertyType.GetPropertyValueTypeCode(), isPrivateSetter, withDataBinding); } else