Share

MsgPack Explorer

Since I really want to use the MsgPack format for a cross-platform project I'm planning to build, I wanted to have a tool that could validate and inspect MsgPack messages. As I have stated in a previous blogpost, MsgPack messages are not really human readable, and when an error occurs it is quite hard to find the exact spot.

The sources are on GitHub, and you can download a binary release from there as well.

With this tool you can view the hirarchical structure of a message in the treeview. Details of each element can be viewed by selecting the node. The property-grid on the right will display information about the item and below it a small hex-editor will highlight the bytes belonging to the item.

In addition some validation warnings, hints, comments and errors will be shown in a listview at the bottom.

The tool can also be used as a Fiddler Inspector:

Screenshot of the tool integrated into Fiddler

In order to use this tool as a Fiddler plugin, copy the following files to the Fiddler Inspectors directory (usually C:\Program Files\Fiddler2\Inspectors):

MsgPackExplorer.exe
LsMsgPackFiddlerInspector.dll
LsMsgPack.dll

Restart fiddler and you should see a MsgPack option in the Inspectors list.

I hope this tool will be a great aid for others also using this format.

The Library

The library currently only supports a limited subset of primitive types, but enough to get me started. For example: it will serialize any IEnumerable but only deserialize IList instances. The following is a simple example of what it can do. If you define a message class like this:

class MyClass {       public string Name { get; set; }       public int Quantity { get; set; }       public List<object> Anything { get; set; }     }

You can serialize and deserialize it like this:

MyClass message = new MyClass() {         Name = "TestMessage",         Quantity = 35,         Anything = new List<object>(new object[] { "First", 2, false, null, 5.5d, "last" })       };        // Serialize       byte[] buffer = MsgPackSerializer.Serialize(message);        // Deserialize       MyClass creceiveMessage = MsgPackSerializer.Deserialize<MyClass>(buffer);

The result in MsgPack Explorer would look like this:

Treeview of the serialised properties

Note that any special types like DateTime and TimeStamp are not supported as they have no certain cross-platform/language standerd as of yet. I'd rather handle these on application level than make a chioce now, and need to make breaking changes later when a standard is settled.