-
-
Notifications
You must be signed in to change notification settings - Fork 714
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
DataMember attribute for properties with inheritance #886
Comments
I dived deeper in this topic and found out that if I omit |
Does the |
I checked it and I found out that it does not. Do you have any plans to support this flag in |
I don't think so. Can you share why it's important to you? If you're using the |
I want to use these business classes for |
OK, so with named keys, omitting null is a reasonable request. Appeasing that might make sense to do at the same time as #678. But let's have this issue focus on the inheritance issue as its title says. I agree this is a bug, and I'm glad you have a workaround. FWIW though, your sample has a (small) bug too. The way you have it implemented you have two fields backing [DataContract]
public class BaseClass
{
[DataMember]
public virtual int VirtualProperty { get; set; }
}
[DataContract]
public class DerivedClass : BaseClass
{
//[SomeCustomAttribute]
[DataMember]
public override int VirtualProperty {
get => base.VirtualProperty;
set => base.VirtualProperty = value;
}
} |
OK. Thanks for reasonable comment about a bug in my example. |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Bug description
There is a problem with objects with inheritance. In this case I have virtual properties with
DataMember
attribute in base class. Then I have derived class with overridden properties for adding some custom attributes for these properties. It should work for standardDataContract
serializer and forMessagePack
serializer. But it only works forDataContract
serializer.Repro steps
Demo example:
Expected behavior
It should work as well as on
DataContract
serializer.Actual behavior
I got exception:
MessagePack.Internal.MessagePackDynamicObjectResolverException : key is duplicated, all members key must be unique. type: MyLibTest+DerivedClass member:VirtualProperty
Additional context
Is it possible to add support for this case?
I can delete
DataMember
attribute from property in base class. In this caseMessagePack
serializer start working, butDataContract
serializer stops working.The text was updated successfully, but these errors were encountered: