Given a protocol buffer encoded Stream
or byte[]
but NOT knowing the object type itself, how can we print the skeleton of the message? The use case is for debugging IO that's protobuf based, for root cause analysis.
If there are existing tools that can parse the raw Protocol Buffer byte stream from a binary file - that would be great! An alternative could be using the ProtoBuf.NET class ProtoReader()
to keep chugging along till we hit the error but the usage of ProtoReader() isn't clear. I started as below but couldn't find good documentation on how to use the ProtoReader
class to actually do it. The source code of the project wasn't very straightforward to follow either ... so would appreciate some tips/help
using (var fs = File.OpenRead(filePath))
{
using (var pr = new ProtoReader(fs, TypeModel.Create(), null))
{
// Use ProtoReader to march through the bytes
// Printing field number, type, size and payload values/bytes
}
}