From e835215d64a86b4bec7c4fe0d72e6f5680fab0ac Mon Sep 17 00:00:00 2001 From: Michael Ganss Date: Fri, 17 May 2024 19:15:05 +0200 Subject: [PATCH] Set AllowEmptyStrings to true on RequiredAttribute (fixes #200) --- XmlSchemaClassGenerator/TypeModel.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/XmlSchemaClassGenerator/TypeModel.cs b/XmlSchemaClassGenerator/TypeModel.cs index 7cbb112..d2e9526 100644 --- a/XmlSchemaClassGenerator/TypeModel.cs +++ b/XmlSchemaClassGenerator/TypeModel.cs @@ -762,6 +762,8 @@ public void AddMembersTo(CodeTypeDeclaration typeDeclaration, bool withDataBindi if (IsRequired && Configuration.DataAnnotationMode != DataAnnotationMode.None) { var requiredAttribute = new CodeAttributeDeclaration(CodeUtilities.CreateTypeReference(Attributes.Required, Configuration)); + var allowEmptyStringsArgument = new CodeAttributeArgument("AllowEmptyStrings", new CodePrimitiveExpression(true)); + requiredAttribute.Arguments.Add(allowEmptyStringsArgument); member.CustomAttributes.Add(requiredAttribute); }