Protocol buffers detect type from raw message
问题 Is it possible to detect the type of a raw protocol buffer message (in byte[]) I have a situation where an endpoint can receive different messages and I need to be able to detect the type before I can deserialize it. I am using protobuf-net 回答1: You can't detect the type in isolation, since the protobuf spec doesn't add any data to the stream for this; however, there are a number of ways of making this easy, depending on the context: a union type (as mentioned by Jon) covers a range of