In Java it is strongly recommended that all serializable classes explicitly declare serialVersionUID since the default serialVersionUID computation is highly sensitive to class details and compiler implementation is unreliable.
What's so special about serialization in C#?
-
Note that, in Java, it's deliberately unreliable.Stack Exchange Broke The Law– Stack Exchange Broke The Law2015年05月12日 08:21:01 +00:00Commented May 12, 2015 at 8:21
-
@Juan That's only relevant in Java contextVarinder Singh– Varinder Singh2015年05月12日 08:22:12 +00:00Commented May 12, 2015 at 8:22
-
Sorry, still sleepy this morning!Juan– Juan2015年05月12日 08:22:46 +00:00Commented May 12, 2015 at 8:22
-
Suggest you read this question/answer: stackoverflow.com/questions/15631341/…Erwin Bolwidt– Erwin Bolwidt2015年05月12日 09:16:09 +00:00Commented May 12, 2015 at 9:16
-
@immibis What is achieved by making it deliberately unreliable?Varinder Singh– Varinder Singh2015年05月13日 05:43:34 +00:00Commented May 13, 2015 at 5:43
1 Answer 1
In .Net Serialization is less cranky than in Java.
By default it supports new fields just defaulting them, and it just ignore any data it doesn't expect.
You can still implement the same kind of version control by implementing the ISerializable interface in your class and adding your own custom VersionId to your class and check it there.
You can read more about this here
1 Comment
GetField.get methods even include an option to use a specific value if missing for custom deserialisation. The difference is, if you want to retain compatibility after you have changed a class, Java requires you to explicitly state the version.