Question

I have a large set of XML files of a propriatary schema -the XML files define binary communication protocol (message structure).

I'd like to leverage Google's protocol buffers technology.

I am using existing code to load the XML files into an object model (in memory). I'd like to generate a .proto file from that object model.

so basically what I am looking for is code/library (in C#/.NET) that represents the .proto file format as an object model and can save that object model into a .proto file.

I took a look at Jon Skeet's dotnet-protobufs, I think I understand what it does (generate c# code based on .proto files)

However, I didn't figure out if I can use it for my project (it probably has the .proto format object model there, but probably only code that can parse this format and not write it out)

Was it helpful?

Solution

protobuf-net (my version of protocol buffers in .NET) has primitive support for generating proto files, but it wouldn't be hard to fill in the blanks. I concentrated on the core engine first, then the generation of C# from proto. Writing an xslt to generate a proto from the object model wouldn't be much different. It would take a few days though... (I have limited time at the moment).

If this would be useful, please let me know.

For info, the protobuf-net engine is compatible with most XmlSerializer classes (and DataContractSerializer, and recently BinaryFormatter) - so if your code currently works as xml, we can probably get it working in protobuf-net. No guarantees, of course...

OTHER TIPS

My code can only serialize and deserialize to binary and text. However, I believe Marc Gravell's project has XML capabilities. In fact, I believe he generates C# code based on loading the binary version of a .proto file (which is itself encoded as a protobuf), writing it out as XML, and then applying XSLT to it...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top