Commit 2a197b3e authored by Jon Skeet's avatar Jon Skeet

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.
parent 3ffbdd71
...@@ -306,7 +306,9 @@ std::string FieldGeneratorBase::default_value() { ...@@ -306,7 +306,9 @@ std::string FieldGeneratorBase::default_value() {
std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) { std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) {
switch (descriptor->type()) { switch (descriptor->type()) {
case FieldDescriptor::TYPE_ENUM: 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_MESSAGE:
case FieldDescriptor::TYPE_GROUP: case FieldDescriptor::TYPE_GROUP:
if (IsWrapperType(descriptor)) { if (IsWrapperType(descriptor)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment