Skip to content
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

Unable to generate contracts when XSD contains nillable boolean elements in a group #350

Closed
UserAvailableIsNotAvailable opened this issue Aug 19, 2022 · 4 comments

Comments

@UserAvailableIsNotAvailable
Copy link

UserAvailableIsNotAvailable commented Aug 19, 2022

To reproduce the error, try to generate contracts from the following XSD:

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://car/1.0"
           attributeFormDefault="unqualified"
           elementFormDefault="qualified"
           targetNamespace="http://car/1.0"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:group name="LimitedEditionType">
    <xs:sequence>
      <xs:element nillable="true" name="IsAvailable" type="xs:boolean" />
    </xs:sequence>
  </xs:group>

  <xs:complexType name="PorscheType">
    <xs:sequence>
      <xs:group ref="LimitedEditionType"/>
      <xs:element name="Model" type="xs:string" />
    </xs:sequence>
  </xs:complexType>

</xs:schema>

Error:

Contract.cs(177,40): error CS0738: 'PorscheType' does not implement interface member 'ILimitedEditionType.IsAvailable'. 'PorscheType.IsAvailable' cannot implement 'ILimitedEditionType.IsAvailable' because it does not have the matching return type of 'bool'.

XSD group generates an interface but does not handle Nullable types:

public partial class PorscheType : ILimitedEditionType
{
    
    [System.Xml.Serialization.XmlElementAttribute("IsAvailable", Namespace="http://car/1.0", IsNullable=true)]
    public System.Nullable<bool> IsAvailable { get; set; }
    
    [System.Xml.Serialization.XmlElementAttribute("Model", Namespace="http://car/1.0")]
    public string Model { get; set; }
}

public partial interface ILimitedEditionType
{
    
    bool IsAvailable
    {
        get;
        set;
    }
}
@mganss mganss closed this as completed in 544994f Aug 23, 2022
@mganss
Copy link
Owner

mganss commented Aug 23, 2022

Fixed in 2.0.732.

@UserAvailableIsNotAvailable
Copy link
Author

UserAvailableIsNotAvailable commented Aug 25, 2022

Hello,

I tested again with 2.0.732.
The problem is still present. The interface is not generated with nullable types:

public partial interface ILimitedEditionType
{
    
    bool IsAvailable
    {
        get;
        set;
    }
}

It should be:

public partial interface ILimitedEditionType
{
    
    System.Nullable<bool> IsAvailable
    {
        get;
        set;
    }
}

Can the issue be reopened?

@mganss
Copy link
Owner

mganss commented Aug 25, 2022

Have you specified -0 on the command line?

@UserAvailableIsNotAvailable
Copy link
Author

I did not. After specifying it it eventually works.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants