I'm using protobuf-net.grpc
and in general the setup is working, but now I ran into an issue: one of the message objects cannot be used as service method parameter.
Consider the following service definition:
[ServiceContract]
public interface IFooService
{
[OperationContract]
public ValueTask<FooResponse> Foo(FooRequest req); // works
[OperationContract]
public ValueTask<BarResponse> Bar(FooDto dto); // FooDto cannot be serialized, ignoring
}
[ProtoContract]
public sealed class FooRequest
{
[ProtoMember(1)]
FootDto Foo {get; set;}
}
[ProtoContract]
public sealed class FootDto
{
[ProtoMember(1)]
int Id {get; set;}
// many other properties
}
Note that FooRequest
contains FooDto
and it can be serialized without any issues sending and receiving.
But if I use it directly as a parameter of the service I get a message that it cannot be serialized and that this service method will be ignored (so the endpoint will return an Unimplemented
error when called).
I suppose it has to do with grpc specifics, but simply don't understand why the same object can be serialized if used as part of a message but not on its own.
It is working using the wrapper object, but I would like to know why this is happening anyway.