-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support new oneof feature #95
Comments
Original comment by |
Original comment by |
Original comment by |
Original comment by |
Is there any news on this as one of my team has implemented |
I have no plans to add features to this codebase. oneof is fully supported in the proto3 implementation at https://github.com/google/protobuf, along with all other proto3 features (maps, official JSON representation etc)... but be aware that that does not support proto2. Given that oneof doesn't require any wire changes, you could fake part of it reasonably easily against proto2 codegen if you only need it in a couple of very specific situations - just manually write partial classes against the generated code to add a property which checks which value has been set. That's fine for reading, but you wouldn't get any benefits on the writing side though... you might want to add a method on the builder which sets a field and clears the others in the oneof... it depends on your situation. |
We, like the other commenters, would like oneof support in our proto2 implementation. |
It's certainly not something I would consider doing in this version - as I've said before, this version is really in "serious bugs only" mode. I simply don't have the time to put any very significant effort into it. I'm sure it would be feasible to add oneof support to this version, but it's definitely more work than I'd be willing to take on. Even reviewing someone else's code on it is likely to be quite a bit of work, to be honest - because there are quite a few potential corner cases. |
I understand the status of the project and I was not proposing any work on your part. I was just trying to understand just how one might go about adding oneof support knowing you are probably privy to how they may have done it in the Google/protobuf 3 project. You dropped some proposals earlier in the comments. I was just digging for a little more info. Thanks. |
To be honest, anyone else adding support would still require work on my part - to review it and then support it afterwards. In terms of how it's implemented in the proto3 project, the simplest approach is probably to look at the output generated for a oneof... although it's worth bearing in mind that the messages in the proto3 port are mutable, which will change things somewhat. |
Thanks for the framework Jon. I understand you don't have the time, and this discussion is pretty stale anyway. I think I have the same problem that others will have, which is that we work with partners that have, for whatever reason, implemented using proto2. This old project can't handle oneof, and the new Google protoc can't compile proto2 code. For me, I can't reasonable ask other companies I work with to change their proto definitions, and meanwhile Google says proto2 will be supported for a long time. My best case scenario would be that the new protoc would support proto2 as well, and we could have everything in one place. But I know I'm dreaming, so I'll try and sort out the oneof problem now from my generated C# code manually. Thanks for all the great contributions! |
Original issue reported on code.google.com by
[email protected]
on 14 Nov 2014 at 3:58The text was updated successfully, but these errors were encountered: