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

Parent classes not inherited from in WSDL #206

Closed
agpreynolds opened this issue Mar 7, 2019 · 2 comments
Closed

Parent classes not inherited from in WSDL #206

agpreynolds opened this issue Mar 7, 2019 · 2 comments

Comments

@agpreynolds
Copy link
Contributor

Given the following basic class structure:

    public abstract class Animal
    {
        public Guid RequestId { get; set; }
    }

    public class Cat : Animal
    {
        public string Name { get; set; }
    }

    public class Dog : Animal
    {
        public string Name { get; set; }
    }

and the following service definition:

    [ServiceContract]
    public interface ITestService
    {
        [OperationContract]
        Cat GetCat();

        [OperationContract]
        Dog GetDog();

        [OperationContract]
        bool CheckAnimalStatus(Animal animal);
    }

It should be possible for the consumer to do something like the following:

service.OpenAsync().Wait();

var cat = service.GetCatAsync().Result;

while (service.CheckAnimalStatusAsync(cat).Result)
{
       Console.WriteLine($"Cat id: {cat.RequestId}, name: {cat.Name} is ok.");
}

service.CloseAsync().Wait();

However the current serialization strategy is to serialize all properties, including properties from a parent class into one class, see:

<xs:complexType xmlns:ser="http://schemas.microsoft.com/2003/10/Serialization/" name="Cat">
<xs:sequence>
<xs:element minOccurs="0" name="Name" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="RequestId" type="ser:guid"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Cat" nillable="true" type="tns:Cat"/>
<xs:complexType xmlns:ser="http://schemas.microsoft.com/2003/10/Serialization/" name="Dog">
<xs:sequence>
<xs:element minOccurs="0" name="Name" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="RequestId" type="ser:guid"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Dog" nillable="true" type="tns:Dog"/>

This results in a class looking like the following being generated:

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
    [System.Runtime.Serialization.DataContractAttribute(Name="Cat", Namespace="http://schemas.datacontract.org/2004/07/CoreService")]
    public partial class Cat : object
    {
        
        private string NameField;
        
        private System.Guid RequestIdField;
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string Name
        {
            get
            {
                return this.NameField;
            }
            set
            {
                this.NameField = value;
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public System.Guid RequestId
        {
            get
            {
                return this.RequestIdField;
            }
            set
            {
                this.RequestIdField = value;
            }
        }
    }

As this class does not inherit the 'Animal' parent class, it is not able to be used to pass into the 'CheckAnimalStatus' message.

What's the current plan for dealing with inheritance in serialization? I'd be happy to help out and work on this feature but I think it's worth a discussion on desired approach first.

Additional Info
This was tested against this mornings release of 0.9.9.4

@kotovaleksandr
Copy link
Member

@agpreynolds Can i close issue?

@agpreynolds
Copy link
Contributor Author

yeah all resolved

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