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
Use Google.Protobuf protoc 3.12 in Grpc.Tools and expose --experimental_allow_proto3_optional switch #22975
Comments
Yes we have plan to support this. We also need to add |
Hi, when using Grpc.Tools 2.30.0-pre1 (.NET) package, is there any way to specify --experimental_allow_proto3_optional flag in directive? Right now I get error like this:
|
@kskalski I see. Adding an extra flag is not something one commonly does,
|
It appears that this should be set with GrpcOutputOptions but it doesn't work. This fails:
|
grpc/src/csharp/Grpc.Tools/ProtoCompile.cs Line 297 in 686e038
grpc/src/csharp/Grpc.Tools/ProtoCompile.cs Line 416 in 686e038
Looks like we currently don't have a good way of adding a custom cmdline arg to protoc invocations (which is this case is bad, but otherwise it's a protection against breaking the msbuild logic in unexpected ways). |
It seems we would need to wait for transition of this feature to non-experimental in protobuf library, right? I think having a way to pass custom options to protoc compiler is desirable, because in future similar use-cases might pop up. But you are probably in a more informed position to decide:
|
@kskalski I would assume that in the future there would be similar to this, and this is a major blocker for us right now because this feature determines structure and obviously optional results in better nullable types in C# and other languages versus the alternatives. |
Any idea if this is possible to work around by using Google.Protobuf MSBuild task directly? Or does it have the same limitation and the one from Grpc.Tools is just a consequence of that? |
There is another way to test proto3 optional when the feature is under experimental. See https://github.com/protocolbuffers/protobuf/blob/master/docs/implementing_proto3_presence.md#satisfying-the-experimental-check
There is an example there:
So you can try that with |
This issue/PR has been automatically marked as stale because it has not had any update (including commits, comments, labels, milestones, etc) for 30 days. It will be closed automatically if no further update occurs in 7 day. Thank you for your contributions! |
bump |
If anyone has a bit of time for this it would be appreciated, a general configuration mechanism would prevent blocking configuration issues from happening again. |
I made an attempt at adding support in #25374 The basic idea is that you'd have something like this in your
|
The latest (3.15+) releases of For example, you can download the latest
In this case, protoc will be at Then you can set the
or
Once you rebuild the project with this set up, you should be able to compile the proto3 protos that have In theory you could also use the same technique with the earlier versions of |
The latest Grpc.Tools now has protoc 3.14.0 (see #25131) and in the next release we'll very likely have protoc 3.15.2 (once we update our third_party/protobuf). |
Using "optional" presence tracking in proto3 (before protobuf 3.15) required the `--experimental_allow_proto3_optional` protoc option but there was no existing Grpc.Tools feature that would allow specifying these arguments. This commit adds an optional `Protobuf.AdditionalProtocArguments` option that allows you to specify arbitrary protoc arguments. For example: ``` <Protobuf Include="**\*.proto" CompileOutputs="true" AdditionalProtocArguments="--experimental_allow_proto3_optional" /> ``` Fixes #22975
Is your feature request related to a problem? Please describe.
I would like to use --experimental_allow_proto3_optional switch to enable optional fields in proto3 files
Describe the solution you'd like
Describe alternatives you've considered
Additional context
At some point the experimental flag should be enabled by default I guess, so apart from switching to new release it's not clear that adding support for it here is worth the effort. However alternatively I would propose adding a parameter to
<Protobuf>
tag that would allow passing arbitrary custom flags (or maybe limit them to some prefix / format)The text was updated successfully, but these errors were encountered: