Search code examples
protocol-buffersprotobuf-net

protogen - support the <Property>Specified syntax


After several years, I've upgraded my version of protogen.exe to 3.0.101.

The earlier version generated, for each optional member, a boolean property "Specified".

For example, my message had an optional boolean field TurnScreenOnAndOff.

The C# class would have two properties:

public bool TurnScreenOnAndOff {get; set; }
public bool TurnScreenOnAndOffSpecified {get; set; }

Using the later version of protogen, I get the following members:

public bool TurnScreenOnAndOff {get; set; }
public bool ShouldSerializeTurnScreenOnAndOff();

This has broken much of my existing code. Is there a command-line option so that the protobuf code generator uses the earlier convention?


Solution

  • Currently, no. However, it is probably no more than a few minutes to enable it; the relevant code is in WriteField(), noting that ctx.GetCustomOption(key) accesses additional key/value pairs passed to the generator. This is possibly more of a GitHub discussion, though.