c# - protobuf-net: Backward compability when type has changed? -


is there way provide backward compability when member type has changed? example, class person consists in version 1 of 1 integer, in version 2 of string. know breaking contract, example issue isn't seldom in real life software development.

thanks in advance.

// version 1 [protocontract] class person  {     [protomember(1)]     public int id { get; set; } }  // version 2 [protocontract] class person  {     [protomember(1)]     public string id { get; set; } } 

a shim property best bet:

// version 2 [protocontract] class person  {     [protomember(1)]     private int? id_v1 {         { return null; } // means won't serialized         set { if(value != null) id = value.tostring(); }     }      [protomember(2)]     public string id { get; set; } } 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -