Protobuf how to add custom version in binary format

I want to tag each protobuf serial file with my version number. so I can check which version was used to serialize the data, if necessary. Although protobuf is designed around an idea, so you do not need to check the version.

To do this, I can use the same method that we did in .net serialization by adding a version field to it.

I just want to confirm that this is the preferred way to do it in protobuf too.

class protodata1
{
  public protodata1()
 {
  version = 1;
 }
  [Protomember(1)]
  int version { get; set;}
  [Protomember(2)]
  int somedata { get; set;}
}

Should also be done as above in protobuf-net? Assign a version in the constructor that will be overridden if the class gets de-styled. for new objects to be serialized, it will use version 1

+3
1

, "" , ; . , (, ), , "v2", ( ).

, , , , , " 1". "v2" WCF ( ). , " 0" - , (, , , ).

+1

Source: https://habr.com/ru/post/1759022/


All Articles