I have a complex model serialized/deserialized with protobuf-net, and we had several bugs with this "feature" of not serializing default values.
Example:
[DataContract]
class Foo{
public Foo(){
// Value forced by constructor
this.Value = 1;
}
// Buggy, when Value is set to zero
[DataMember(Order = 1)]
public double Value {get; set}
}
When Value = 0, it is not serialized by protobuf-net, but during deserialization, the constructor forces Value to 1 (and protobuf-net do not change this).
In order to make it work, I need to force protobuf-net to serialize values, with:
// Works fine
[DataMember(Order = 1, IsRequired = true)]
public double Value {get; set}
But, as we already got bugs because of this feature, we'd like to force protobuf-net for the whole model, instead of marking every property.
Is it possible?