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

XmlSerializer WSDL: XmlAttribute: Set use="required" attribute #1007

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

vidrenning
Copy link
Contributor

If a member has been annotated with the [XmlAttribute] attribute, and it is a value type, such as int, it will get the use="required" attribute. However if it has a ShouldSerialize*() method, then it is considered optional and the use="required" attribute is not added.

Added a new test to verify this behavior.

Fixes #1006

If a member has been annotated with the [XmlAttribute] attribute, and it
is a value type, such as int, it will get the use="required" attribute.
However if it has a ShouldSerialize*() method, then it is considered
optional and the use="required" attribute is not added.

Added a new test to verify this behavior.

Fixes DigDes#1006
@andersjonsson andersjonsson self-requested a review February 7, 2024 13:30
Copy link
Collaborator

@andersjonsson andersjonsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Maybe you should check that the return type of the ShouldSerialize*()-methods is System.Boolean.
On the other hand serialization will fail if the return type is something else, so the user that does something like that will have bigger issues than faulty wsdl 😛

@andersjonsson andersjonsson merged commit 180355b into DigDes:develop Feb 7, 2024
4 checks passed
@vidrenning
Copy link
Contributor Author

Thanks for merging! Before implementing this I have tested the behavior of the .NET Framework ASMX Web Service WSDL generator. In that generator, the return type of the ShouldSerialize*() methods is also not checked. The WSDL is the same, no matter if a int ShouldSerialize*() method or a bool ShouldSerialize*() method is defined. Therefore I decided to also not check it, to maximize compatibility with the .NET Framework ASMX Web Service WSDL generator. 😄

@vidrenning vidrenning deleted the xmlattribute branch February 7, 2024 13:43
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

Successfully merging this pull request may close these issues.

XmlSerializer: WSDL for XmlAttribute fields does not set use="required" flag
2 participants