I have a .proto
file that I have traditionally been using with protogen.exe
to generate a .cs
file for the relevant class. The class generated implements Protobuf.IExtensible
. However, I now need to deserialise protobuf data coming from Kafka, from a topic that has the same .proto
file in its schema registry. From what I can see, the Confluent.SchemaRegistry.Serdes.ProtobufDeserializer
expects the underlying type to implement Google.Protobuf.IMessage<T>
instead. I haven't been able to find good information linking IExtensible
and IMessage
. Is there a way for me to deserialise the object, using the same class I have always been using? I have tried Protobuf.Serializer.Deserialize
and it gives me ProtoException
: "Invalid field in source data: 0".
There are (at least) two separate implementations of Protobuf in regular use in .NET code:
IMessage<T>
API and is intended for schema-first scenarios, and is idiomatic protobuf that just happens to be in .NET / C#If the Confluent
API wants IMessage<T>
, then you should use the Google.Protobuf
library and associated tools to process the schema, and work from there. This processes the exact same binary payloads, but the API has some differences.