Include the oneof-case in equality and hash code generated code.

The included C# test will fail until the regenerated code is used, which is in the next commit.
diff --git a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
index 575d458..1163f52 100644
--- a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
+++ b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
@@ -566,6 +566,16 @@
         }

 

         [Test]

+        public void Oneof_DefaultValuesNotEqual()

+        {

+            var message1 = new TestAllTypes { OneofString = "" };

+            var message2 = new TestAllTypes { OneofUint32 = 0 };

+            Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message1.OneofFieldCase);

+            Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase);

+            Assert.AreNotEqual(message1, message2);

+        }

+

+        [Test]

         public void OneofSerialization_NonDefaultValue()

         {

             var message = new TestAllTypes();

diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc
index 21fbf7e..6cca670 100644
--- a/src/google/protobuf/compiler/csharp/csharp_message.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_message.cc
@@ -323,6 +323,10 @@
             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 @@
             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");