Arshia001 / FSharp.GrpcCodeGenerator

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

How to achieve `Any.Pack/Unpack` from FSharp? #26

Open iskandersierra opened 1 year ago

iskandersierra commented 1 year ago

How do I create a Google.Protobuf.FSharp.WellKnownTypes.Any instance from another message?

In C# we use method static Google.Protobuf.WellKnownTypes.Any.Pack(IMessage) and Google.Protobuf.WellKnownTypes.Any.[Try]Unpack<T>(...)

Also, how to know the message type from the Any.TypeUrl?

Thanks for this libraries! I finally found some FSharp libraries to work with Protobuf/Grpc 🥳

iskandersierra commented 1 year ago

We would have to add from https://github.com/protocolbuffers/protobuf/blob/main/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs the needed operations to module Any and type Any, like pack, unpack, tryUnpack, is and a way to access descriptor from all the messages, like Dog.descriptor, taken from module DogReflection.

I would like to work on this as a PR, if you are open for it