Skip to content

GUID pattern restriction on xs:string results in string instead of Guid #402

Closed
@bzwieratinnovadis

Description

@bzwieratinnovadis

Hi,

We are currently in the process of migrating our code generation process from xsd.exe to this library. There is one issue that I can't seem to figure out with the CLI options and that is to generate Guid based properties when there is a regex pattern restriction (below).

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/"
           version="1.0">
    <xs:simpleType name="guid">
        <xs:annotation>
            <xs:documentation xml:lang="en">
                The representation of a GUID, generally the id of an element.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

Running the CLI with these options:

dotnet xscgen --nf .\namespaceMapping.txt --uc --cc- --csm=PublicWithoutConstructorInitialization --nc -i=i --fb Xsds\**\*.xsd

which results in:

/// <summary>
/// <para xml:lang="en">The representation of a GUID, generally the id of an element.</para>
/// <para xml:lang="en">Pattern: [a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}.</para>
/// </summary>
[System.ComponentModel.DataAnnotations.RegularExpressionAttribute("[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}")]
[System.Xml.Serialization.XmlElementAttribute("BatchReferentie", IsNullable=true)]
public string BatchReferentie { get; set; }

When using xsd.exe, it generates Guid instead of string. Is there some option or alternate way to do this with the CLI?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions