Skip to content

Commit

Permalink
Fix collection setter when EnableDataBinding is true
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Jun 11, 2015
1 parent 0343da0 commit 49cd164
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions XmlSchemaClassGenerator.Tests/XmlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions XmlSchemaClassGenerator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -390,7 +390,7 @@ private IEnumerable<XmlSchemaAttribute> GetAttributes(XmlSchemaObjectCollection
}

// see http://msdn.microsoft.com/en-us/library/z2w0sxhf.aspx
private static readonly HashSet<string> EnumTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
private static readonly HashSet<string> EnumTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{ "string", "normalizedString", "token", "Name", "NCName", "ID", "ENTITY", "NMTOKEN" };

// ReSharper disable once FunctionComplexityOverflow
Expand Down Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion XmlSchemaClassGenerator/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 49cd164

Please sign in to comment.