I have a type like this:
[ProtoContract]
class Person {
[ProtoMember(1)]
public string Name {get;set:}
[ProtoMember(2)]
public int Id {get;set;}
}
Later I realized I need another property Age so added it like:
[ProtoContract]
class Person {
[ProtoMember(1)]
public string Name {get;set:}
[ProtoMember(3)]
public int Age {get;set;}
[ProtoMember(2)]
public int Id {get;set;}
}
But since I am still in development phase, I want to change the Age ProtoMember index from 3 to 2, and update the Id ProtoMember appropriately.
Is there a way to do this easily? Or do I have to create another type temporarily to convert it back and forth until I can serialize it to the right type I want in the updated form?
I assume the issue is migrating old data? If so, then v2 can do this for you; however, I would also be personally included to say “meh, Age is #3, Id stays #2” (I can’t see huge benefits in changing this number).
But as an example for the more general case:
By having 2 different
RuntimeTypeModelinstances with different configurations you can apply all sorts of odd translations between data. But again – using this just so thatAgeis #2 seems massive overkill. Indeed, I would simply make my class:And look! They are magically in order!