proto2 syntax allows the first enum to have a non zero value. This means any
field using that default has a non zero default without having an explicit
default being set. So when deciding what runtime info is needed, don't rely
on an explicit default, always check that the values aren't zero.
Fixes https://github.com/google/protobuf/issues/1453
A protobuf message will be corrupted in the following scenario:
1. Use LITE_RUNTIME.
2. Have an optional enum field following some other field.
3. Update protocol by adding new values to the enum.
4. Have an old client parse and serialize a message having enum field
set to a value the client does not understand.
5. Field preceeding the enum is now corrupted.
The bug is due to the fact that optimized fallthrough in parser code
does not update variablle 'tag' when jumping to the parser code for the
next field.
(There are documentation changes and new fields in descriptor.proto that have resulted
in changes to the serialized descriptor, but no breaking changes for C#.)
- Always generated into a temp directory so we can see if things changed.
- Add a flag to control exiting with error when stale vs updating.
This should let the continuous builds error out when ObjC needs to have the
checked in sources updated.
Overview of changes:
- A new C#-specific command-line option, legacy_enum_values to revert to the old behavior
- When legacy_enum_values isn't specified, we strip the enum name as a prefix, and PascalCase the value name
- A new attribute within the C# code so that we can always tell the original in-proto name
Regenerating the C# code with legacy_enum_values leads to code which still compiles and works - but
there's more still to do.
proto3.
Added a couple unit test proto3 files, for arena_lite and lite. Cloned
the proto3_arena_unittest to test some of the basics of generated code
(and to ensure that the generated proto3 test files are used by some
test).
For JSON encoding we provide a new option to decide at
encode time whether to use camelCase or original proto field
names:
json = MapMessage.encode_json(m, :preserve_proto_fieldnames => true)
The flags are:
UPB_JSON_ACCEPT_LEGACY_FIELD_NAMES
UPB_JSON_WRITE_LEGACY_FIELD_NAMES
The first just allows the parser to accept the old field names.
The second makes the printer print the old field names.
These flags are intended to be temporary, as a migration aid
for users.