Re: [protobuf] Serializing List of Objects

2012-10-23 Thread Daniel Morgan
Hello Mark. Is it possible for me to serialize and deserialize a list directly? Like this: public static void SerializeT(T obj, string filename) { //Serialize using (FileStream stream = File.Open(filename, FileMode.Create)) {

Re: [protobuf] Serializing List of Objects

2012-09-10 Thread Amina Khalique
Hi Marc, I had a similar question about the serialization of objects using protocol buffers. I prefer using a single .proto file for generation of C# and Java file, and would like to know if my understanding of how to implement a generic list of objects in the .proto file is right or not.

Re: [protobuf] Serializing List of Objects

2012-06-28 Thread Joel Carrier
Thanks a lot for the explanation Marc. I'm currently investigating some interop issues we're having and I'm starting to realize that this might be the source of the problem. [CollectionDataContract(Name = ItemList)] public class ItemListTItem : ListItemTItem where TItem : class ... where

Re: [protobuf] Serializing List of Objects

2012-06-28 Thread Marc Gravell
Well, until I get around to re-implementing it for v2, GetProtoT will just make a quiet apology. But to answer your question, consider an example such as ItemListCustomer ItemTItem could be (I can't remember how v1 implements this) something like message Item_Customer { optional

Re: [protobuf] Serializing List of Objects

2012-06-28 Thread Joel Carrier
Yes it does. Thanks. Where can I read more about this disabling of list-handling and its effects? On Thu, Jun 28, 2012 at 8:31 AM, Marc Gravell marc.grav...@gmail.comwrote: Well, until I get around to re-implementing it for v2, GetProtoT will just make a quiet apology. But to answer your

Re: [protobuf] Serializing List of Objects

2012-06-28 Thread Marc Gravell
Firstly, I must say that I don't generally recommend inheriting from lists in this context. The code, as an implementation detail, tries to detect things that look like lists, and switches to treat it as repeated data. Sometimes, pretty rarely, something *looks* like a list, but should be treated

Re: [protobuf] Serializing List of Objects

2012-06-27 Thread Joel Carrier
Hi Marc, Could you elaborate on your note: (note: this is specific to protobuf-net, not protocol buffers more widely) What are the implications if communicating with non-protobuf-net targets? (ie. java, python, ... applications) Joel On Wednesday, June 20, 2012 9:05:49 AM UTC-4, Marc

Re: [protobuf] Serializing List of Objects

2012-06-27 Thread Marc Gravell
The data is of course compatible. A `ListFoo` is directly mappable to .proto via for example: message SomeOuterMessage { repeated Foo items = 1; } In fact, for that reason, serializing a ListFoo will produce **exactly** the same data on the wire as serializing:

Re: [protobuf] Serializing List of Objects

2012-06-20 Thread Marc Gravell
(note: this is specific to protobuf-net, not protocol buffers more widely), but yes: that (a generic list) would work fine, as long as the property has been marked for serialization and given a number. There also doesn't need to be a set accessor, although it can make full use of a set - i.e. if