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

DataContract.Name is ignored for generic types #1067

Closed
navozenko opened this issue Jun 15, 2024 · 0 comments · Fixed by #1068
Closed

DataContract.Name is ignored for generic types #1067

navozenko opened this issue Jun 15, 2024 · 0 comments · Fixed by #1068

Comments

@navozenko
Copy link
Contributor

navozenko commented Jun 15, 2024

Hi. I found that SoapCore ignores the Name property specified in DataContractAttribute for generic type. Here is an example:

[ServiceContract]
public interface IMyService
{
    [OperationContract]
    MyType<int, string> Test();
}

public class MyService : IMyService
{
    public MyType<int, string> Test() => new();
}

[DataContract(Name = "MyType")]
public class MyType<TKey, TValue>
{
    [DataMember]
    public TKey? Key { get; set; }

    [DataMember]
    public TValue? Value { get; set; }
}

The produced wsdl refers to the auto-generated name "MyTypeOfInt32String" instead of the "MyType" name specified in the DataContract.Name property.

<xs:element name="TestResponse">
  <xs:complexType>
    <xs:sequence>
      <xs:element minOccurs="1" name="TestResult" nillable="true" type="q1:MyTypeOfInt32String"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

I wrote a small fix, based on the CollectionDataContract.Name processing code.
#1068

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 a pull request may close this issue.

1 participant