C#C
C#8mo ago
osadriofary

Serialization and retrocompatibility

Hi. So i'm working on a client that communicates with a server using serialization. I need the old client to be able to communicate with the new server.

My problem is some of the fields in my app were created with auto properties (get; set;) way. And i now have to change them to private _id and public Id.

I've looked around and found that for the auto properties, the compiler Will create a private field called <Id>kBackingField. This property is used for serialization.

For now i've been using a custom serialization where i create the <nameof(Id)>k
BackingField.

This isnt very pretty and i've also Just discovered it gets even worse with inheritance. Is there a way to fix this retrocompatibility problem in an easier way ?
Was this page helpful?