The data is of course compatible. A `List<Foo>` is directly mappable to
.proto via for example:
message SomeOuterMessage {
repeated Foo items = 1;
}
In fact, for that reason, serializing a List<Foo> will produce **exactly**
the same data on the wire as serializing:
[ProtoContract]
public class Whatever {
[ProtoMember(1)]
public List<Foo> Items {get;set;}
}
which is (give or take) what you will get if you feed the above .proto into
"protogen" (protobuf-net's entirely optional code generator for handling
.proto definitions)
Marc
On 27 June 2012 16:21, Joel Carrier <[email protected]> wrote:
> 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 Gravell wrote:
>>
>> (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 it finds the list is "null", it will create a new list of
>> the appropriate type and use the "set" to update the object.
>>
>> So, your code would be fine if it has been designated a number, or a
>> related example:
>>
>> [ProtoMember(4)]
>> public List<Order> Orders { get { return orders; } }
>> private readonly List<Order> orders = new List<Order>();
>>
>> Marc
>> (protobuf-net)
>>
>> On 20 June 2012 13:08, Farooq Mushtaq <[email protected]> wrote:
>>
>>> How can we serialize list of objects by using protobuf-net? Is
>>> protobuf-net support list of objects like
>>> public List(ABC) DEF
>>> {
>>> get;
>>> set;
>>> }
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Protocol Buffers" group.
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/protobuf/-/W0yySDcbES8J<https://groups.google.com/d/msg/protobuf/-/W0yySDcbES8J>
>>> .
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to protobuf+unsubscribe@**
>>> googlegroups.com <protobuf%[email protected]>.
>>> For more options, visit this group at http://groups.google.com/**
>>> group/protobuf?hl=en <http://groups.google.com/group/protobuf?hl=en>.
>>>
>>
>>
>>
>> --
>> Regards,
>>
>> Marc
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/protobuf/-/2pcXp7q9LCcJ.
>
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
--
Regards,
Marc
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en.