Arshia001 / FSharp.GrpcCodeGenerator

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

Generated code does not work with JsonTranscoding #23

Open marner2 opened 1 year ago

marner2 commented 1 year ago

Get the following error when starting the app with JSON Transcoding enabled in .net 7:

warn: Microsoft.AspNetCore.Grpc.JsonTranscoding.Internal.Binding.JsonTranscodingServiceMethodProvider[2]
      Error getting service descriptor for BarServer.BarServerService.
      System.InvalidOperationException: Get not find Descriptor property on FooServiceMethodBinder.
         at Grpc.Shared.ServiceDescriptorHelpers.GetServiceDescriptor(Type serviceReflectionType)
         at Microsoft.AspNetCore.Grpc.JsonTranscoding.Internal.Binding.JsonTranscodingServiceMethodProvider`1.OnServiceMethodDiscovery(ServiceMethodProviderContext`1 context)

This seems like it's related to some missing generated Descriptor properties.

marner2 commented 1 year ago

After manually adding a descriptor property on the type requested, I get the following error hitting the generated REST endpoint:

{
  "code": 3,
  "message": "Cannot dynamically create an instance of type 'Proto.FooRequest'. Reason: No parameterless constructor defined.",
  "details": []
}

Maybe this just won't work with F# records as the protobuf messages.