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
Post a Comment