-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Serializing polymorphic records with constructor parameters #9026
Comments
|
@MickaelThumerel it didn't change anything. This doesn't work:
This doesn't work either:
Need to get rid of constructor parameter to make it work, for example:
Obviously using ordinary class also works:
It looks like constructor parameters are lost during default serialization / deserialization. Obviously can also write custom serializer to deal with that. |
A record have 2 constructors. One with the parameter you pass and another (also called a copy constructor (LIKE c++)) that take another instance and make a copy. It true that many Mapper or serializer framework are not ready to process record properly. In a project call Democrite i encounter a similar problem. I choose to create a base interface as common type and record structure as surrogate. Serialization, surrogate ... is an heavy point to write but it's due to a choice of performance. |
Is serializing polymorphic records with constructor parameters supposed to work?
I mean something like this:
And then:
In my tests Value always has default value (zero). So result of the call is always zero (if serialization is involved, so not in local calls).
If I make Value a property instead of a constructor parameter then it works, but it means I can't easily make it read only.
The text was updated successfully, but these errors were encountered: