CameraSchoolDropout
CameraSchoolDropout

Reputation: 893

c# Using .proto file to deserialize into a dynamic object

Are there any examples of using an existing .proto file (generated from ProtoBuf.Serializer.GetProto();) and raw bytes to de-serialize into a dynamic object or plain object.

Let me stress this is a problem I am tackling to improve the debugging tools I have for my out of memory cache - the objective is to be able to make any object within human readable without having to use the app (as I will store the .proto for each type in the cache as it existed when it was serialization occurred).

There are no performance considerations in this solution, all options are on the table. I would be happy if there was a method to do this in protobuf-net, but if I needed to use code generation / alternative libraries, that is just fine. I am unsure of what the most prudent approach would be.

Upvotes: 1

Views: 2503

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1064324

Protobuf-net itself doesn't have any .proto parsing tools, however one of the companion tools included with the google-code download (but not the NuGet download) is "ProtoGen", which has some support for this. It can be referenced (it is just a .net assembly) and used - that is actually how the integration tests for it operate. This tool works as a c# code generator; hook that to CSharpCodeProvider and you have a viable, if basic, mechanism to process data in memory. You wouldn't want to process vast quantities of .proto in a single app-domain this way, though - the runtime isn't good at unloading assemblies.

To do what you want, it would be preferable to use tools that are specifically designed for that scenario. That translates into "somebody wanted that scenario sufficiently that they took the time to investigate, design, implement, test, and support it".

Upvotes: 2

Related Questions