FSharp.GrpcCodeGenerator icon indicating copy to clipboard operation
FSharp.GrpcCodeGenerator copied to clipboard

Generated code does not work with JsonTranscoding

Open marner2 opened this issue 2 years ago • 1 comments

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 avatar Dec 14 '22 21:12 marner2

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.

marner2 avatar Dec 14 '22 22:12 marner2