Arshia001 / FSharp.GrpcCodeGenerator

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

Set default values according to Spec #12

Closed purkhusid closed 2 years ago

purkhusid commented 3 years ago

What?

This changes the generator to not return ValueOption for scalar types and return default values according to the proto3 spec: https://developers.google.com/protocol-buffers/docs/proto3#default

Why?

The proto3 wire format does not make it possible to know if a value was intentionally set to the default value of a scalar

The spec dictates that scalar fields should always return default values and only message fields should have language specific implementations

Since support for the optional keyword has landed in proto3 and proper support for it is implemented in #8 I don't think this makes the API any worse since the end user can simply add the optional keyword to their .proto files and get the same API

purkhusid commented 2 years ago

@Arshia001 I've been using these patches in production for a few months now and not faced any issues so far and we are interoping with e.g. the rust protobuf implementation in https://github.com/tokio-rs/prost

Is there any chance to get this merged?

Arshia001 commented 2 years ago

Closed in #16.