Abyss wrote:
What is the preferred approach?
If there was a preferred approach that applies in all circumstances, all other approaches would be dropped. I'd go for the simplest solution; meaning the OptionalField if I'd expect that the class is not going to change much. Anything that could have more/complexer versions, I'd write a custom ISerializable.
Abyss wrote:
However I expected that such kind of versioning is already implemented by the streaming framework. I tried to obtain the Assembly version from the SerializationInfo but it is always set to current version not to the version which was used when the object was saved.
It'd be overkill, and not everybody will be wanting to use those version-numbers. Keep in mind that the version-number you see is the one of the assembly that the class is contained in. Alternatively, one might use different version numbers for files, created with a single version of a class. So, the one-size-fits all wouldn't fit here.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]