Arshia001 / FSharp.GrpcCodeGenerator

A protoc plugin to enable generation of F# code + supporting libraries
MIT License
81 stars 9 forks source link

Plugin fails when proto3 fields are marked as optional #4

Closed purkhusid closed 2 years ago

purkhusid commented 3 years ago

The F# plugin fails when it encounters an proto3 file that contains the optional keyword. This keyword was recently to the proto3 spec. More information about it here: https://github.com/protocolbuffers/protobuf/blob/master/docs/implementing_proto3_presence.md

My guess is that this does not really affect the output of the F# plugin since it it is not outputting nullable fields?

Arshia001 commented 3 years ago

To the best of my knowledge, the optional keyword was added to forcibly support presence on all fields. We already support presence on all fields anyway, so as you say, it shouldn't really affect the output.

I can't spot any errors when compiling a file with optional fields. This may be due the recent change in how one-of fields are handled. Can you share the error?

Anyway, optional fields are turned into single-case one-ofs by the compiler. This causes the generated F# field to be wrapped in a single-case union, which is less-than-desirable behaviour. Thanks for pointing this out.

purkhusid commented 3 years ago

Fixed in #8

Arshia001 commented 2 years ago

Closed in #16.