Re: [protobuf] Replacing 'extensions' in proto3
On Mon, Jun 5, 2017 at 4:48 PM, R.C.wrote: > Hi Bo, > > Thanks for your response. Would using 'Any' in this fashion change the > format on the wire? How can I edit the proto file to maintain the format on > the wire (maintaining backward compatibility with older message decoders)? > Yes, using an `Any` field changes the wire representation. If you are trying to maintain binary compatibility in your move to proto3, you will have to replace extensions with actual fields with the same type and tag on the Vehicles message: message Vehicles { optional Car car = 100; optional Bike bike = 200; } You would also then need to re-structure your files, like moving the definition of Vehicle into its own file, so you don't accidentally introduce any import cycles. > > Thanks, > rc > > On Monday, June 5, 2017 at 1:21:03 PM UTC-7, Bo Yang wrote: >> >> message Vehicles { >> Any extending = 1; >> } >> >> // cpp code == >> Car car = new Car(); >> UnpackAny(vehicles.extending, ); >> >> On Mon, Jun 5, 2017 at 11:48 AM R.C. wrote: >> >>> Hi, >>> >>> I am looking to move an application written with proto2 to use proto3. I >>> understand 'extensions' is disabled in proto3 and am looking for some >>> guidance to change the below to proto3: >>> >>> >>> >>> common.proto: >>> >>> message Vehicles { >>> extensions 1 to max >>> } >>> >>> >>> car.proto: >>> >>> import "common.proto"; >>> >>> message Car { >>> string type = 1; >>> string color = 2; >>> } >>> >>> extend Vehicles { >>> optional Car CarExt = 100; >>> } >>> >>> >>> >>> bike.proto: >>> >>> import "common.proto"; >>> >>> message Bike { >>> string type = 1; >>> string color = 2; >>> } >>> >>> extend Vehicles { >>> optional Bike BikeExt = 200; >>> } >>> >>> >>> Since 'optional' is default i can remove the 'optional' keyword but I am >>> not sure how 'Any' can be used in such scenario in the place of >>> 'extensions'. >>> >>> Thanks, >>> rc >>> >>> -- >>> 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 post to this group, send email to prot...@googlegroups.com. >>> Visit this group at https://groups.google.com/group/protobuf. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > 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+unsubscr...@googlegroups.com. > To post to this group, send email to protobuf@googlegroups.com. > Visit this group at https://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/d/optout. > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
Re: [protobuf] Replacing 'extensions' in proto3
Hi Bo, Thanks for your response. Would using 'Any' in this fashion change the format on the wire? How can I edit the proto file to maintain the format on the wire (maintaining backward compatibility with older message decoders)? Thanks, rc On Monday, June 5, 2017 at 1:21:03 PM UTC-7, Bo Yang wrote: > > message Vehicles { > Any extending = 1; > } > > // cpp code == > Car car = new Car(); > UnpackAny(vehicles.extending, ); > > On Mon, Jun 5, 2017 at 11:48 AM R.C.> wrote: > >> Hi, >> >> I am looking to move an application written with proto2 to use proto3. I >> understand 'extensions' is disabled in proto3 and am looking for some >> guidance to change the below to proto3: >> >> >> >> common.proto: >> >> message Vehicles { >> extensions 1 to max >> } >> >> >> car.proto: >> >> import "common.proto"; >> >> message Car { >> string type = 1; >> string color = 2; >> } >> >> extend Vehicles { >> optional Car CarExt = 100; >> } >> >> >> >> bike.proto: >> >> import "common.proto"; >> >> message Bike { >> string type = 1; >> string color = 2; >> } >> >> extend Vehicles { >> optional Bike BikeExt = 200; >> } >> >> >> Since 'optional' is default i can remove the 'optional' keyword but I am >> not sure how 'Any' can be used in such scenario in the place of >> 'extensions'. >> >> Thanks, >> rc >> >> -- >> 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 post to this group, send email to prot...@googlegroups.com >> . >> Visit this group at https://groups.google.com/group/protobuf. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
Re: [protobuf] Replacing 'extensions' in proto3
message Vehicles { Any extending = 1; } // cpp code == Car car = new Car(); UnpackAny(vehicles.extending, ); On Mon, Jun 5, 2017 at 11:48 AM R.C.wrote: > Hi, > > I am looking to move an application written with proto2 to use proto3. I > understand 'extensions' is disabled in proto3 and am looking for some > guidance to change the below to proto3: > > > > common.proto: > > message Vehicles { > extensions 1 to max > } > > > car.proto: > > import "common.proto"; > > message Car { > string type = 1; > string color = 2; > } > > extend Vehicles { > optional Car CarExt = 100; > } > > > > bike.proto: > > import "common.proto"; > > message Bike { > string type = 1; > string color = 2; > } > > extend Vehicles { > optional Bike BikeExt = 200; > } > > > Since 'optional' is default i can remove the 'optional' keyword but I am > not sure how 'Any' can be used in such scenario in the place of > 'extensions'. > > Thanks, > rc > > -- > 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+unsubscr...@googlegroups.com. > To post to this group, send email to protobuf@googlegroups.com. > Visit this group at https://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/d/optout. > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] Replacing 'extensions' in proto3
Hi, I am looking to move an application written with proto2 to use proto3. I understand 'extensions' is disabled in proto3 and am looking for some guidance to change the below to proto3: common.proto: message Vehicles { extensions 1 to max } car.proto: import "common.proto"; message Car { string type = 1; string color = 2; } extend Vehicles { optional Car CarExt = 100; } bike.proto: import "common.proto"; message Bike { string type = 1; string color = 2; } extend Vehicles { optional Bike BikeExt = 200; } Since 'optional' is default i can remove the 'optional' keyword but I am not sure how 'Any' can be used in such scenario in the place of 'extensions'. Thanks, rc -- 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+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.