You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a project where I am trying to handle multiple versions of a binary format natively, so you could for example deserialize conforming to one version and reserialize to another, handle conversions gracefully. I'm passing in the version using the optional Context parameter upon deserialization, which works great most of the time doing things like the following:
But when creating a custom class with IBinarySerializable, it appears that I have no way of accessing my version field to control the behavior. Through the BinarySerializationContext that gets passed in to the Serialize and Deserialize methods, I appear to have access to just about anything I could use for a [SerializeWhen] except for this serialization context. Is there an easy way to get access to this value when doing custom serialization?
So far I've been able to navigate around this by not using IBinarySerializable, but there are several instances where it would vastly cut down on code, subclasses, subclass factories, etc. by just using custom serialization. My version number gets serialized as part of the format, so it's accessible in theory, but it's nested pretty deep in the tree, and I can't do things like test smaller pieces to make sure they serialize properly without access to the version.
The text was updated successfully, but these errors were encountered:
Hi!
I'm working on a project where I am trying to handle multiple versions of a binary format natively, so you could for example deserialize conforming to one version and reserialize to another, handle conversions gracefully. I'm passing in the version using the optional Context parameter upon deserialization, which works great most of the time doing things like the following:
But when creating a custom class with IBinarySerializable, it appears that I have no way of accessing my version field to control the behavior. Through the BinarySerializationContext that gets passed in to the Serialize and Deserialize methods, I appear to have access to just about anything I could use for a [SerializeWhen] except for this serialization context. Is there an easy way to get access to this value when doing custom serialization?
So far I've been able to navigate around this by not using IBinarySerializable, but there are several instances where it would vastly cut down on code, subclasses, subclass factories, etc. by just using custom serialization. My version number gets serialized as part of the format, so it's accessible in theory, but it's nested pretty deep in the tree, and I can't do things like test smaller pieces to make sure they serialize properly without access to the version.
The text was updated successfully, but these errors were encountered: