2

I am trying to port a project from Google Protocol Buffers 3.0.0-beta-2 to 3.1.0. After recompiling my .proto file I noticed that I had a number of compilation errors with the project due to protoc enforcing a coding standard that I did not choose and renaming fields accordingly. I do not want to rename e.g. MDData to Mddata or XYServer to Xyserver inside the project since the intended meanings of the abbreviations are now lost and possibly subject to change in further Protocol Buffer releases to come.

I have seen this behaviour on the C# part so far and am not sure if this is also the case for generated code for C++.

TL;DR:

Is there a way to disable automatic code style changes inside Google Protocol Buffer's Proto Compiler (and keep my own formatting) of fields?

vonludi
  • 419
  • 2
  • 20

1 Answers1

0

There is no way to enforce this short of writing your own code generator. Only the public API of the stubs is considered stable.

Under the hood, the protoc compiler regenerates the code from scratch each time, so there is no way for it to know the original style of the file. It would need to be passed in the original generated file along with the proto in order to do this.

That said, if you want to modify the code generator, it is certainly possible.

Carl Mastrangelo
  • 5,970
  • 1
  • 28
  • 37
  • Thanks for your response. Could you link to a reference of what is considered part of the public API and what isn't? When upgrading, for example the names of enum values changed. Is this considered part of the public API? – vonludi Jun 06 '17 at 19:59