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 <[email protected]> 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]<protobuf%[email protected]> > . > 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 [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.
