Skip to content

Commit

Permalink
Generate enum if enum values present unless pattern is also there
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Jan 24, 2020
1 parent c4414d2 commit c8971df
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion XmlSchemaClassGenerator/ModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ private TypeModel CreateTypeModel(XmlSchemaSimpleType simpleType, NamespaceModel
if (simpleType.Content is XmlSchemaSimpleTypeRestriction typeRestriction)
{
var enumFacets = typeRestriction.Facets.OfType<XmlSchemaEnumerationFacet>().ToList();
var isEnum = (enumFacets.Count == typeRestriction.Facets.Count && enumFacets.Count != 0);
// If there's a pattern restriction mixed into the enumeration values, we'll generate a string to play it safe.
var isEnum = enumFacets.Count > 0 && !typeRestriction.Facets.OfType<XmlSchemaPatternFacet>().Any();
if (isEnum)
{
// we got an enum
Expand Down

0 comments on commit c8971df

Please sign in to comment.