diff options
author | Jon Skeet <jonskeet@google.com> | 2017-10-24 14:14:15 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2017-10-31 17:11:40 -0700 |
commit | cbe250591fca9d2e776776be065a72c5550a5556 (patch) | |
tree | b9b6b3de8fe8af9aaa9238b40611bf09f8f87b65 /src/google/protobuf/compiler/csharp/csharp_message_field.cc | |
parent | 6dd82243932e929331f3808742b191c85a353461 (diff) |
Fix merging with message-valued oneof
If messages A and B have the same oneof case, which is a message
type, and we merge B into A, those sub-messages should be merged.
Fixes #3200.
Note that I haven't regenerated all the code, as some of the protos
have been changed, breaking generation.
Diffstat (limited to 'src/google/protobuf/compiler/csharp/csharp_message_field.cc')
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_message_field.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index 438f3102..59b7edfb 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -171,6 +171,14 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { "}\n"); } +void MessageOneofFieldGenerator::GenerateMergingCode(io::Printer* printer) { + printer->Print(variables_, + "if ($property_name$ == null) {\n" + " $property_name$ = new $type_name$();\n" + "}\n" + "$property_name$.MergeFrom(other.$property_name$);\n"); +} + void MessageOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { // TODO(jonskeet): We may be able to do better than this printer->Print( |