--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/41207f02-8d37-42e4-a148-6580c90ab48a%40googlegroups.com.
Hi Josh, thanks for the heads up on the upcoming change needed by source code generators.At first sight, the implementation detail around synthetic/real oneofs seems like a clever hack to avoid breaking some code that uses reflection, but the consequence would be that:1. some code that does reflection would still break and need to be updated, for example if the reflection translates from a representation that depends on the oneof's name.
2. the synthetic/real oneofs distinction is going to remain with us in the foreseeable future and we'll have to keep it in mind when we write generators and reflection code: we will always need to think which list of oneofs is the appropriate one to iterate on.
What representations do you mean? In general it is not expected that oneof names are exposed in wire formats. Authors of .proto files are free to change them at will without breaking the wire.
Can you give an example of some of the code that would be affected?
What representations do you mean? In general it is not expected that oneof names are exposed in wire formats. Authors of .proto files are free to change them at will without breaking the wire.An example would be code that produces an alternative JSON representation that groups all the fields of a oneof inside a nested object. For example if a message likemessage MyMessage {oneof foo {int32 v = 1}}gets encoded to JSON by user's code as:"my_one_of": {"foo": 5}}Then such code would have to be modified to treat synthetic oneofs differently.
Can you give an example of some of the code that would be affected?Some users use oneofs to build ADTs, and for them oneofs should never be empty. To enforce this at runtime, they may have written a validator that takes an instance of a message, and uses its descriptor to traverse all the oneofs and fail when it finds a oneof where none of its fields is set. With the proposed change, this validator would have to be changed to only care about non-synthetic oneofs.