-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GUID pattern restriction on xs:string results in string instead of Guid #402
Comments
I can't repro using xsd.exe. Can you provide a full example with the corresponding command line to invoke xsd.exe? |
See this post |
OK now I can repro. But it doesn't work if the namespace of the OTOH, the actual schema definition of |
2.0.863 contains support for this out of the box. |
@mganss Wow, thanks for implementing the solution so fast! I really appreciate it 👍 I just generated the code with the new version (2.0.863) and found out it's not working, yet. The reason is that we use an intermediate simpleType instead of using the guid type directly. This is causing the resulting properties to still be of type string. The benefit of this approach is that I can specify the guid namespace in only one XSD, rather than in all of the XSD's where I want to use it. UUID.xsd <?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:mxs="http://microsoft.com/wsdl/types/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
id="UUID"
targetNamespace="http://tempuri.org/v1"
elementFormDefault="qualified"
version="1.0">
<xs:import schemaLocation="Guid.xsd" namespace="http://microsoft.com/wsdl/types/"/>
<xs:simpleType name="UUID">
<xs:restriction base="mxs:guid"/>
</xs:simpleType>
</xs:schema> Header.xsd <?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
id="BerichtHeaderSHV"
targetNamespace="http://tempuri.org/v1"
elementFormDefault="qualified"
xmlns="http://tempuri.org/v1"
version="1.0">
<xs:include schemaLocation="../SimpleTypes/UUID.xsd"/>
<xs:complexType name="Header">
<xs:sequence>
<xs:element name="Reference" type="UUID"/>
<xs:element name="Receiver" type="UUID" minOccurs="0" nillable="true"/>
<xs:element name="CrossReference" type="UUID" minOccurs="0" nillable="true"/>
<xs:element name="ConversationReference" type="UUID" minOccurs="0" nillable="true"/>
<xs:element name="Version" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Header" type="Header"/>
</xs:schema> which results in: [System.CodeDom.Compiler.GeneratedCodeAttribute("XmlSchemaClassGenerator", "2.0.863.0")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute("Header", Namespace="http://tempuri.org/v1")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlRootAttribute("Header", Namespace="http://tempuri.org/v1")]
public partial class Header
{
[System.ComponentModel.DataAnnotations.RequiredAttribute()]
[System.Xml.Serialization.XmlElementAttribute("Reference")]
public string Reference { get; set; }
[System.Xml.Serialization.XmlElementAttribute("Receiver", IsNullable=true)]
public string Receiver { get; set; }
[System.Xml.Serialization.XmlElementAttribute("CrossReference", IsNullable=true)]
public string CrossReference { get; set; }
[System.Xml.Serialization.XmlElementAttribute("ConversationReference", IsNullable=true)]
public string ConversationReference { get; set; }
[System.ComponentModel.DataAnnotations.RequiredAttribute()]
[System.Xml.Serialization.XmlElementAttribute("Version")]
public string Version { get; set; }
} Would it be possible to fix this as well? I'd really appreciate that! |
It should work in 2.0.864. |
Thank you so much! It's all working now 👍 |
I found out why we need the http://schemas.microsoft.com/2003/10/Serialization/ namespace instead. We use CoreWCF and when the generated code is serialized for the WSDL it expects the guid type to be present in that namespace. I created a PR already: #403 |
@bzwieratinnovadis Did you ever get xsd.exe to generate |
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).
Running the CLI with these options:
which results in:
When using xsd.exe, it generates Guid instead of string. Is there some option or alternate way to do this with the CLI?
Thanks!
The text was updated successfully, but these errors were encountered: