aboutsummaryrefslogtreecommitdiff
path: root/src/google
diff options
context:
space:
mode:
authorJan Tattermusch <jtattermusch@users.noreply.github.com>2015-10-24 11:41:00 -0700
committerJan Tattermusch <jtattermusch@users.noreply.github.com>2015-10-24 11:41:00 -0700
commitd4569d1f5ede96238dbb87b0ecc1fdcfbd399f62 (patch)
tree879c8b3b426b7ca4aab0af31ae1b847832dbf989 /src/google
parentdfae9e36c7c45b02f39463152c4f6560622d4a78 (diff)
parent55313c9c5d7917d58428d84d193ae3772e4684f8 (diff)
downloadprotobuf-d4569d1f5ede96238dbb87b0ecc1fdcfbd399f62.tar.gz
protobuf-d4569d1f5ede96238dbb87b0ecc1fdcfbd399f62.tar.bz2
protobuf-d4569d1f5ede96238dbb87b0ecc1fdcfbd399f62.zip
Merge pull request #908 from jskeet/oneof-equality
Use oneof case in equality tests
Diffstat (limited to 'src/google')
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_message.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc
index 21fbf7e3..6cca6703 100644
--- a/src/google/protobuf/compiler/csharp/csharp_message.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_message.cc
@@ -323,6 +323,10 @@ void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) {
CreateFieldGeneratorInternal(descriptor_->field(i)));
generator->WriteEquals(printer);
}
+ for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
+ printer->Print("if ($property_name$Case != other.$property_name$Case) return false;\n",
+ "property_name", UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true));
+ }
printer->Outdent();
printer->Print(
" return true;\n"
@@ -339,6 +343,10 @@ void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) {
CreateFieldGeneratorInternal(descriptor_->field(i)));
generator->WriteHash(printer);
}
+ for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
+ printer->Print("hash ^= (int) $name$Case_;\n",
+ "name", UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false));
+ }
printer->Print("return hash;\n");
printer->Outdent();
printer->Print("}\n\n");