Skip to content

Commit

Permalink
Use Array.Empty<T>() instead of new Array[0] (fixes #250)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Jan 29, 2021
1 parent 89fc3a9 commit d2c854d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion XmlSchemaClassGenerator/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,8 @@ public void AddMembersTo(CodeTypeDeclaration typeDeclaration, bool withDataBindi
if (collectionType == typeof(System.Array))
{
var initTypeReference = propertyType.GetReferenceFor(OwningType.Namespace, collection: false, forInit: true, attribute: IsAttribute);
initExpression = new CodeArrayCreateExpression(initTypeReference);
var arrayReference = CodeUtilities.CreateTypeReference(typeof(System.Array), Configuration);
initExpression = new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(arrayReference), "Empty", initTypeReference));
}
else
{
Expand Down

0 comments on commit d2c854d

Please sign in to comment.