Skip to content

ShouldSerialize methods ignored when generating WSDL (minOccurs always 1) #1188

@avoronin565

Description

@avoronin565

Expected behavior

When a class has ShouldSerialize{PropName}() returning false, the WSDL should generate that element with minOccurs="0" (like XmlSerializer does).

Actual behavior

The element always has minOccurs="1", ignoring the ShouldSerialize method.

Minimal reproduction

public class MyRequest
{
    public int? OptionalValue { get; set; }

    public bool ShouldSerializeOptionalValue() => OptionalValue.HasValue;
}

Generated WSDL excerpt:

<xs:element name="OptionalValue" type="xs:int" minOccurs="1" .../>

Expected WSDL excerpt:

<xs:element name="OptionalValue" type="xs:int" minOccurs="0" .../>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions