What are your suggestions? One option that I was thinking is to add a boolean field in the message that determines if the list is empty or not. What do you think?
On Jun 22, 1:21 pm, Marc Gravell <marc.grav...@gmail.com> wrote: > Kenton is of course quite correct. There is no *native* distinction between > a null list and an empty list in the raw protobuf data stream. There *are* > some ways of working around that, to distinguish between the two, but not > when using the code-generation from .proto. > > Marc > > On 22 June 2010 18:59, Kenton Varda <ken...@google.com> wrote: > > > > > > > Protocol Buffers has no concept of "null". Lists can be empty, but not > > "null". > > > On Mon, Jun 21, 2010 at 6:35 PM, Manh Do <mdo...@gmail.com> wrote: > > >> I am working a project where we need to determine if a protobuf list > >> have is null or not in the protocol buffer. > > >> The problem is the generated c# automatically instantiates the list. > > >> IE. Protocol: > >> message B { > >> repeated A MyList = 0; > >> } > > >> Generated C#: > > >> private readonly global::System.Collections.Generic.List<A> _MyList = > >> new global::System.Collections.Generic.List<A>(); > >> [global::ProtoBuf.ProtoMember(0, Name=@"MyList", DataFormat = > >> global::ProtoBuf.DataFormat.Default)] > >> public global::System.Collections.Generic.List<A> MyList > >> { > >> get { return _MyList ; } > >> } > > >> The problem with this is I cannot determine if the list is null. I am > >> using an empty list as a way to remove all objects. > > >> Is there a way where I can make the generator not automatically > >> instantiate the list? Better yet, how do I check for default values in > >> protocol buffer C#? I know you can check for > >> 'default(typeof(MyType));'. > > >> Thanks for the help! > > >> -Manh > > >> -- > >> You received this message because you are subscribed to the Google Groups > >> "Protocol Buffers" group. > >> To post to this group, send email to proto...@googlegroups.com. > >> To unsubscribe from this group, send email to > >> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.c > >> om> > >> . > >> For more options, visit this group at > >>http://groups.google.com/group/protobuf?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Protocol Buffers" group. > > To post to this group, send email to proto...@googlegroups.com. > > To unsubscribe from this group, send email to > > protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.c > > om> > > . > > 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 proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.