Added to my todo list.
On Sat, Oct 25, 2008 at 1:19 AM, Marc Gravell [EMAIL PROTECTED]wrote:
Ah! Right. That makes more sense. Could that perhaps be added to the
language guide Optional Fields And Default Values?
Marc
--~--~-~--~~~---~--~~
You received
Ah! Right. That makes more sense. Could that perhaps be added to the
language guide Optional Fields And Default Values?
Marc
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Protocol Buffers group.
To post to this
and FieldDescriptorProto.Type.
So:
* have I doe something wrong (i.e. I shouldn't be seeing these zeros)?
or
* should protobuf-net accept zero enums even if no such enum is
defined?
or
* is the descriptor.proto lacking some zeros that should be there?
(if I add the missing zero enum values it works fine and I can
I might have found the answer... if you try to provide a different
value, the parser will treat it like an unknown field (from the
language guide). So this means that enums are essentially unchecked:
invalid values are silently ignored?
Marc
--~--~-~--~~~---~--~~
More: actually, the problem wasn't in the file - it was in the
defaults... for example:
enum Label {
// 0 is reserved for errors
LABEL_OPTIONAL = 1;
LABEL_REQUIRED = 2;
LABEL_REPEATED = 3;
// TODO(sanjay): Should we add LABEL_MAP?
};
...
optional Label
The reasoning for unknown enums being treated as unknown fields goes
something like this:
We cannot simply use an unknown numeric value since many languages do not
allow enum types to represent numeric values other than the set of values
explicitly defined for them. Furthermore, even if they did,
Makes sense - it just seems a little odd that the optional enums don't
have a valid default...
Marc
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Protocol Buffers group.
To post to this group, send email to
Oh, the implicit default for enums is the first defined value, not zero.
On Fri, Oct 24, 2008 at 3:03 PM, Marc Gravell [EMAIL PROTECTED]wrote:
Makes sense - it just seems a little odd that the optional enums don't
have a valid default...
Marc