-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
Upgrading a VersionTolerant Model #185
Comments
Hello. There seems to be a problem as you have pointed out. |
The feature to detect default values was problematic and was reverted in 1.20.5 |
Hello. Before, we tried to take care of all default values, but it is hard to deal with all cases and there were performance problems. In the end, we only addressed it by adding an attribute for cases where you want to handle a special default value. Please check [MemoryPackable].
public partial class DefaultValue
{
public string Prop1 { get; set; }
[SuppressDefaultInitialization].
public int Prop2 { get; set; } = 111; // < if old data is missing, set `111`.
public int Prop3 { get; set; } = 222; // < if old data is missing, set `default`.
} For members with this attribute, the default value of the type declaration can be used. |
If you have something like this already serialized:
Then lets say you need to upgrade the model by adding an additional property, but you want the new property to have non-default value, like this:
So when the original model is deserialized the value of Age should be 99 even though this was not in the original byte[]. Is there any way to do that? (I showed how I'd do it with Protobuf-net, but this does not seem to work in Memorypack.)
Thanks!
The text was updated successfully, but these errors were encountered: