Merge pull request #908 from jskeet/oneof-equality

Use oneof case in equality tests
pull/915/head
Jan Tattermusch 9 years ago
commit d4569d1f5e
  1. 6
      csharp/src/Google.Protobuf.Conformance/Conformance.cs
  2. 10
      csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
  3. 4
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs
  4. 4
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs
  5. 2
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs
  6. 196
      csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs
  7. 2
      csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
  8. 8
      src/google/protobuf/compiler/csharp/csharp_message.cc

@ -269,6 +269,7 @@ namespace Conformance {
if (ProtobufPayload != other.ProtobufPayload) return false; if (ProtobufPayload != other.ProtobufPayload) return false;
if (JsonPayload != other.JsonPayload) return false; if (JsonPayload != other.JsonPayload) return false;
if (RequestedOutputFormat != other.RequestedOutputFormat) return false; if (RequestedOutputFormat != other.RequestedOutputFormat) return false;
if (PayloadCase != other.PayloadCase) return false;
return true; return true;
} }
@ -277,6 +278,7 @@ namespace Conformance {
if (payloadCase_ == PayloadOneofCase.ProtobufPayload) hash ^= ProtobufPayload.GetHashCode(); if (payloadCase_ == PayloadOneofCase.ProtobufPayload) hash ^= ProtobufPayload.GetHashCode();
if (payloadCase_ == PayloadOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode(); if (payloadCase_ == PayloadOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode();
if (RequestedOutputFormat != global::Conformance.WireFormat.UNSPECIFIED) hash ^= RequestedOutputFormat.GetHashCode(); if (RequestedOutputFormat != global::Conformance.WireFormat.UNSPECIFIED) hash ^= RequestedOutputFormat.GetHashCode();
hash ^= (int) payloadCase_;
return hash; return hash;
} }
@ -512,6 +514,7 @@ namespace Conformance {
if (ProtobufPayload != other.ProtobufPayload) return false; if (ProtobufPayload != other.ProtobufPayload) return false;
if (JsonPayload != other.JsonPayload) return false; if (JsonPayload != other.JsonPayload) return false;
if (Skipped != other.Skipped) return false; if (Skipped != other.Skipped) return false;
if (ResultCase != other.ResultCase) return false;
return true; return true;
} }
@ -522,6 +525,7 @@ namespace Conformance {
if (resultCase_ == ResultOneofCase.ProtobufPayload) hash ^= ProtobufPayload.GetHashCode(); if (resultCase_ == ResultOneofCase.ProtobufPayload) hash ^= ProtobufPayload.GetHashCode();
if (resultCase_ == ResultOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode(); if (resultCase_ == ResultOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode();
if (resultCase_ == ResultOneofCase.Skipped) hash ^= Skipped.GetHashCode(); if (resultCase_ == ResultOneofCase.Skipped) hash ^= Skipped.GetHashCode();
hash ^= (int) resultCase_;
return hash; return hash;
} }
@ -1461,6 +1465,7 @@ namespace Conformance {
if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false; if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false;
if (OneofString != other.OneofString) return false; if (OneofString != other.OneofString) return false;
if (OneofBytes != other.OneofBytes) return false; if (OneofBytes != other.OneofBytes) return false;
if (OneofFieldCase != other.OneofFieldCase) return false;
return true; return true;
} }
@ -1532,6 +1537,7 @@ namespace Conformance {
if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) hash ^= OneofNestedMessage.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) hash ^= OneofNestedMessage.GetHashCode();
if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) hash ^= OneofString.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) hash ^= OneofString.GetHashCode();
if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode();
hash ^= (int) oneofFieldCase_;
return hash; return hash;
} }

@ -565,6 +565,16 @@ namespace Google.Protobuf
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
} }
[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] [Test]
public void OneofSerialization_NonDefaultValue() public void OneofSerialization_NonDefaultValue()
{ {

@ -1260,6 +1260,8 @@ namespace UnitTest.Issues.TestProtos {
if (PlainString != other.PlainString) return false; if (PlainString != other.PlainString) return false;
if (O2Int32 != other.O2Int32) return false; if (O2Int32 != other.O2Int32) return false;
if (O2String != other.O2String) return false; if (O2String != other.O2String) return false;
if (O1Case != other.O1Case) return false;
if (O2Case != other.O2Case) return false;
return true; return true;
} }
@ -1271,6 +1273,8 @@ namespace UnitTest.Issues.TestProtos {
if (PlainString.Length != 0) hash ^= PlainString.GetHashCode(); if (PlainString.Length != 0) hash ^= PlainString.GetHashCode();
if (o2Case_ == O2OneofCase.O2Int32) hash ^= O2Int32.GetHashCode(); if (o2Case_ == O2OneofCase.O2Int32) hash ^= O2Int32.GetHashCode();
if (o2Case_ == O2OneofCase.O2String) hash ^= O2String.GetHashCode(); if (o2Case_ == O2OneofCase.O2String) hash ^= O2String.GetHashCode();
hash ^= (int) o1Case_;
hash ^= (int) o2Case_;
return hash; return hash;
} }

@ -868,6 +868,7 @@ namespace Google.Protobuf.TestProtos {
if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false; if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false;
if (OneofString != other.OneofString) return false; if (OneofString != other.OneofString) return false;
if (OneofBytes != other.OneofBytes) return false; if (OneofBytes != other.OneofBytes) return false;
if (OneofFieldCase != other.OneofFieldCase) return false;
return true; return true;
} }
@ -921,6 +922,7 @@ namespace Google.Protobuf.TestProtos {
if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) hash ^= OneofNestedMessage.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) hash ^= OneofNestedMessage.GetHashCode();
if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) hash ^= OneofString.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) hash ^= OneofString.GetHashCode();
if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode();
hash ^= (int) oneofFieldCase_;
return hash; return hash;
} }
@ -4470,6 +4472,7 @@ namespace Google.Protobuf.TestProtos {
if (FooInt != other.FooInt) return false; if (FooInt != other.FooInt) return false;
if (FooString != other.FooString) return false; if (FooString != other.FooString) return false;
if (!object.Equals(FooMessage, other.FooMessage)) return false; if (!object.Equals(FooMessage, other.FooMessage)) return false;
if (FooCase != other.FooCase) return false;
return true; return true;
} }
@ -4478,6 +4481,7 @@ namespace Google.Protobuf.TestProtos {
if (fooCase_ == FooOneofCase.FooInt) hash ^= FooInt.GetHashCode(); if (fooCase_ == FooOneofCase.FooInt) hash ^= FooInt.GetHashCode();
if (fooCase_ == FooOneofCase.FooString) hash ^= FooString.GetHashCode(); if (fooCase_ == FooOneofCase.FooString) hash ^= FooString.GetHashCode();
if (fooCase_ == FooOneofCase.FooMessage) hash ^= FooMessage.GetHashCode(); if (fooCase_ == FooOneofCase.FooMessage) hash ^= FooMessage.GetHashCode();
hash ^= (int) fooCase_;
return hash; return hash;
} }

@ -1596,6 +1596,7 @@ namespace Google.Protobuf.TestProtos {
if (BoolField != other.BoolField) return false; if (BoolField != other.BoolField) return false;
if (StringField != other.StringField) return false; if (StringField != other.StringField) return false;
if (BytesField != other.BytesField) return false; if (BytesField != other.BytesField) return false;
if (OneofFieldCase != other.OneofFieldCase) return false;
return true; return true;
} }
@ -1619,6 +1620,7 @@ namespace Google.Protobuf.TestProtos {
if (oneofFieldCase_ == OneofFieldOneofCase.BoolField) hash ^= BoolField.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.BoolField) hash ^= BoolField.GetHashCode();
if (oneofFieldCase_ == OneofFieldOneofCase.StringField) hash ^= StringField.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.StringField) hash ^= StringField.GetHashCode();
if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) hash ^= BytesField.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) hash ^= BytesField.GetHashCode();
hash ^= (int) oneofFieldCase_;
return hash; return hash;
} }

@ -50,90 +50,91 @@ namespace Google.Protobuf.Reflection {
"dG9idWYuRGVzY3JpcHRvclByb3RvLlJlc2VydmVkUmFuZ2USFQoNcmVzZXJ2", "dG9idWYuRGVzY3JpcHRvclByb3RvLlJlc2VydmVkUmFuZ2USFQoNcmVzZXJ2",
"ZWRfbmFtZRgKIAMoCRosCg5FeHRlbnNpb25SYW5nZRINCgVzdGFydBgBIAEo", "ZWRfbmFtZRgKIAMoCRosCg5FeHRlbnNpb25SYW5nZRINCgVzdGFydBgBIAEo",
"BRILCgNlbmQYAiABKAUaKwoNUmVzZXJ2ZWRSYW5nZRINCgVzdGFydBgBIAEo", "BRILCgNlbmQYAiABKAUaKwoNUmVzZXJ2ZWRSYW5nZRINCgVzdGFydBgBIAEo",
"BRILCgNlbmQYAiABKAUiqQUKFEZpZWxkRGVzY3JpcHRvclByb3RvEgwKBG5h", "BRILCgNlbmQYAiABKAUivAUKFEZpZWxkRGVzY3JpcHRvclByb3RvEgwKBG5h",
"bWUYASABKAkSDgoGbnVtYmVyGAMgASgFEjoKBWxhYmVsGAQgASgOMisuZ29v", "bWUYASABKAkSDgoGbnVtYmVyGAMgASgFEjoKBW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", "Cghsb2NhdGlvbhgBIAMoCzIoLmdvb2dsZS5wcm90b2J1Zi5Tb3VyY2VDb2Rl",
"b2NhdGlvbhIQCgRwYXRoGAEgAygFQgIQARIQCgRzcGFuGAIgAygFQgIQARIY", "SW5mby5Mb2NhdGlvbhqGAQoITG9jYXRpb24SEAoEcGF0aBgBIAMoBUICEAES",
"ChBsZWFkaW5nX2NvbW1lbnRzGAMgASgJEhkKEXRyYWlsaW5nX2NvbW1lbnRz", "EAoEc3BhbhgCIAMoBUICEAESGAoQbGVhZGluZ19jb21tZW50cxgDIAEoCRIZ",
"GAQgASgJEiEKGWxlYWRpbmdfZGV0YWNoZWRfY29tbWVudHMYBiADKAlCWAoT", "ChF0cmFpbGluZ19jb21tZW50cxgEIAEoCRIhChlsZWFkaW5nX2RldGFjaGVk",
"Y29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRvclByb3Rvc0gBWgpkZXNj", "X2NvbW1lbnRzGAYgAygJQlgKE2NvbS5nb29nbGUucHJvdG9idWZCEERlc2Ny",
"cmlwdG9yogIDR1BCqgIaR29vZ2xlLlByb3RvYnVmLlJlZmxlY3Rpb24=")); "aXB0b3JQcm90b3NIAVoKZGVzY3JpcHRvcqICA0dQQqoCGkdvb2dsZS5Qcm90",
"b2J1Zi5SZWZsZWN0aW9u"));
descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] { new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] {
@ -141,7 +142,7 @@ namespace Google.Protobuf.Reflection {
new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.FileDescriptorProto), new[]{ "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.FileDescriptorProto), new[]{ "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto), new[]{ "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName" }, null, null, new pbr::GeneratedCodeInfo[] { new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange), new[]{ "Start", "End" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto), new[]{ "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName" }, null, null, new pbr::GeneratedCodeInfo[] { new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange), new[]{ "Start", "End" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange), new[]{ "Start", "End" }, null, null, null)}), new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange), new[]{ "Start", "End" }, null, null, null)}),
new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto), new[]{ "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "Options" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type), typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label) }, null), new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto), new[]{ "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "JsonName", "Options" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type), typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label) }, null),
new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.OneofDescriptorProto), new[]{ "Name" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.OneofDescriptorProto), new[]{ "Name" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.EnumDescriptorProto), new[]{ "Name", "Value", "Options" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.EnumDescriptorProto), new[]{ "Name", "Value", "Options" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), new[]{ "Name", "Number", "Options" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), new[]{ "Name", "Number", "Options" }, null, null, null),
@ -1255,6 +1256,7 @@ namespace Google.Protobuf.Reflection {
extendee_ = other.extendee_; extendee_ = other.extendee_;
defaultValue_ = other.defaultValue_; defaultValue_ = other.defaultValue_;
oneofIndex_ = other.oneofIndex_; oneofIndex_ = other.oneofIndex_;
jsonName_ = other.jsonName_;
Options = other.options_ != null ? other.Options.Clone() : null; Options = other.options_ != null ? other.Options.Clone() : null;
} }
@ -1368,6 +1370,22 @@ namespace Google.Protobuf.Reflection {
} }
} }
/// <summary>Field number for the "json_name" field.</summary>
public const int JsonNameFieldNumber = 10;
private string jsonName_ = "";
/// <summary>
/// JSON name of this field. The value is set by protocol compiler. If the
/// user has set a "json_name" option on this field, that option's value
/// will be used. Otherwise, it's deduced from the field's name by converting
/// it to camelCase.
/// </summary>
public string JsonName {
get { return jsonName_; }
set {
jsonName_ = pb::Preconditions.CheckNotNull(value, "value");
}
}
/// <summary>Field number for the "options" field.</summary> /// <summary>Field number for the "options" field.</summary>
public const int OptionsFieldNumber = 8; public const int OptionsFieldNumber = 8;
private global::Google.Protobuf.Reflection.FieldOptions options_; private global::Google.Protobuf.Reflection.FieldOptions options_;
@ -1397,6 +1415,7 @@ namespace Google.Protobuf.Reflection {
if (Extendee != other.Extendee) return false; if (Extendee != other.Extendee) return false;
if (DefaultValue != other.DefaultValue) return false; if (DefaultValue != other.DefaultValue) return false;
if (OneofIndex != other.OneofIndex) return false; if (OneofIndex != other.OneofIndex) return false;
if (JsonName != other.JsonName) return false;
if (!object.Equals(Options, other.Options)) return false; if (!object.Equals(Options, other.Options)) return false;
return true; return true;
} }
@ -1411,6 +1430,7 @@ namespace Google.Protobuf.Reflection {
if (Extendee.Length != 0) hash ^= Extendee.GetHashCode(); if (Extendee.Length != 0) hash ^= Extendee.GetHashCode();
if (DefaultValue.Length != 0) hash ^= DefaultValue.GetHashCode(); if (DefaultValue.Length != 0) hash ^= DefaultValue.GetHashCode();
if (OneofIndex != 0) hash ^= OneofIndex.GetHashCode(); if (OneofIndex != 0) hash ^= OneofIndex.GetHashCode();
if (JsonName.Length != 0) hash ^= JsonName.GetHashCode();
if (options_ != null) hash ^= Options.GetHashCode(); if (options_ != null) hash ^= Options.GetHashCode();
return hash; return hash;
} }
@ -1456,6 +1476,10 @@ namespace Google.Protobuf.Reflection {
output.WriteRawTag(72); output.WriteRawTag(72);
output.WriteInt32(OneofIndex); output.WriteInt32(OneofIndex);
} }
if (JsonName.Length != 0) {
output.WriteRawTag(82);
output.WriteString(JsonName);
}
} }
public int CalculateSize() { public int CalculateSize() {
@ -1484,6 +1508,9 @@ namespace Google.Protobuf.Reflection {
if (OneofIndex != 0) { if (OneofIndex != 0) {
size += 1 + pb::CodedOutputStream.ComputeInt32Size(OneofIndex); size += 1 + pb::CodedOutputStream.ComputeInt32Size(OneofIndex);
} }
if (JsonName.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(JsonName);
}
if (options_ != null) { if (options_ != null) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options);
} }
@ -1518,6 +1545,9 @@ namespace Google.Protobuf.Reflection {
if (other.OneofIndex != 0) { if (other.OneofIndex != 0) {
OneofIndex = other.OneofIndex; OneofIndex = other.OneofIndex;
} }
if (other.JsonName.Length != 0) {
JsonName = other.JsonName;
}
if (other.options_ != null) { if (other.options_ != null) {
if (options_ == null) { if (options_ == null) {
options_ = new global::Google.Protobuf.Reflection.FieldOptions(); options_ = new global::Google.Protobuf.Reflection.FieldOptions();
@ -1572,6 +1602,10 @@ namespace Google.Protobuf.Reflection {
OneofIndex = input.ReadInt32(); OneofIndex = input.ReadInt32();
break; break;
} }
case 82: {
JsonName = input.ReadString();
break;
}
} }
} }
} }

@ -344,6 +344,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (BoolValue != other.BoolValue) return false; if (BoolValue != other.BoolValue) return false;
if (!object.Equals(StructValue, other.StructValue)) return false; if (!object.Equals(StructValue, other.StructValue)) return false;
if (!object.Equals(ListValue, other.ListValue)) return false; if (!object.Equals(ListValue, other.ListValue)) return false;
if (KindCase != other.KindCase) return false;
return true; return true;
} }
@ -355,6 +356,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (kindCase_ == KindOneofCase.BoolValue) hash ^= BoolValue.GetHashCode(); if (kindCase_ == KindOneofCase.BoolValue) hash ^= BoolValue.GetHashCode();
if (kindCase_ == KindOneofCase.StructValue) hash ^= StructValue.GetHashCode(); if (kindCase_ == KindOneofCase.StructValue) hash ^= StructValue.GetHashCode();
if (kindCase_ == KindOneofCase.ListValue) hash ^= ListValue.GetHashCode(); if (kindCase_ == KindOneofCase.ListValue) hash ^= ListValue.GetHashCode();
hash ^= (int) kindCase_;
return hash; return hash;
} }

@ -323,6 +323,10 @@ void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) {
CreateFieldGeneratorInternal(descriptor_->field(i))); CreateFieldGeneratorInternal(descriptor_->field(i)));
generator->WriteEquals(printer); 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->Outdent();
printer->Print( printer->Print(
" return true;\n" " return true;\n"
@ -339,6 +343,10 @@ void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) {
CreateFieldGeneratorInternal(descriptor_->field(i))); CreateFieldGeneratorInternal(descriptor_->field(i)));
generator->WriteHash(printer); 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->Print("return hash;\n");
printer->Outdent(); printer->Outdent();
printer->Print("}\n\n"); printer->Print("}\n\n");

Loading…
Cancel
Save