diff options
author | Jon Skeet <jonskeet@google.com> | 2016-04-08 10:02:04 +0100 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2016-04-11 06:47:43 +0100 |
commit | 2a197b3eb0d74ac1f1d461ac958ebccaf968031c (patch) | |
tree | d41e6e66bc21147f4e495f99c055bef7d6899431 /src | |
parent | 3ffbdd712f0413ce4964d626c5e10533f1f74893 (diff) | |
download | protobuf-2a197b3eb0d74ac1f1d461ac958ebccaf968031c.tar.gz protobuf-2a197b3eb0d74ac1f1d461ac958ebccaf968031c.tar.bz2 protobuf-2a197b3eb0d74ac1f1d461ac958ebccaf968031c.zip |
Use 0 as the default value for all enums, rather than finding the actual enum value name
This will make it easier to change the enum value names, as it reduces the number of places they're used.
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_field_base.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index 3b88954c..e3c34040 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -306,7 +306,9 @@ std::string FieldGeneratorBase::default_value() { std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) { switch (descriptor->type()) { case FieldDescriptor::TYPE_ENUM: - return type_name() + "." + descriptor->default_value_enum()->name(); + // All proto3 enums have a default value of 0, and there's an implicit conversion from the constant 0 to + // any C# enum. This means we don't need to work out what we actually mapped the enum value name to. + return "0"; case FieldDescriptor::TYPE_MESSAGE: case FieldDescriptor::TYPE_GROUP: if (IsWrapperType(descriptor)) { |