From 4ca46ede5cc838fb047bd4f86d2294db788567ad Mon Sep 17 00:00:00 2001 From: Sydney Acksman Date: Thu, 19 Apr 2018 13:57:31 -0500 Subject: Write messages to backing field in generated C# cloning code (#4440) * Edited MessageFieldGenerator to clone to backing field instead of property * Generated C# proto code --- .../TestProtos/MapUnittestProto3.cs | 2 +- .../TestProtos/TestMessagesProto3.cs | 20 +++++++++--------- .../TestProtos/UnittestCustomOptionsProto3.cs | 6 +++--- .../TestProtos/UnittestIssues.cs | 2 +- .../TestProtos/UnittestProto3.cs | 24 +++++++++++----------- .../TestProtos/UnittestWellKnownTypes.cs | 20 +++++++++--------- 6 files changed, 37 insertions(+), 37 deletions(-) (limited to 'csharp/src/Google.Protobuf.Test/TestProtos') diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs index cb1bc920..51715a0c 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs @@ -642,7 +642,7 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMapSubmessage(TestMapSubmessage other) : this() { - TestMap = other.testMap_ != null ? other.TestMap.Clone() : null; + testMap_ = other.testMap_ != null ? other.testMap_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs index a2a236d9..7353be7b 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs @@ -273,13 +273,13 @@ namespace ProtobufTestMessages.Proto3 { optionalBool_ = other.optionalBool_; optionalString_ = other.optionalString_; optionalBytes_ = other.optionalBytes_; - OptionalNestedMessage = other.optionalNestedMessage_ != null ? other.OptionalNestedMessage.Clone() : null; - OptionalForeignMessage = other.optionalForeignMessage_ != null ? other.OptionalForeignMessage.Clone() : null; + optionalNestedMessage_ = other.optionalNestedMessage_ != null ? other.optionalNestedMessage_.Clone() : null; + optionalForeignMessage_ = other.optionalForeignMessage_ != null ? other.optionalForeignMessage_.Clone() : null; optionalNestedEnum_ = other.optionalNestedEnum_; optionalForeignEnum_ = other.optionalForeignEnum_; optionalStringPiece_ = other.optionalStringPiece_; optionalCord_ = other.optionalCord_; - RecursiveMessage = other.recursiveMessage_ != null ? other.RecursiveMessage.Clone() : null; + recursiveMessage_ = other.recursiveMessage_ != null ? other.recursiveMessage_.Clone() : null; repeatedInt32_ = other.repeatedInt32_.Clone(); repeatedInt64_ = other.repeatedInt64_.Clone(); repeatedUint32_ = other.repeatedUint32_.Clone(); @@ -338,12 +338,12 @@ namespace ProtobufTestMessages.Proto3 { repeatedDoubleWrapper_ = other.repeatedDoubleWrapper_.Clone(); repeatedStringWrapper_ = other.repeatedStringWrapper_.Clone(); repeatedBytesWrapper_ = other.repeatedBytesWrapper_.Clone(); - OptionalDuration = other.optionalDuration_ != null ? other.OptionalDuration.Clone() : null; - OptionalTimestamp = other.optionalTimestamp_ != null ? other.OptionalTimestamp.Clone() : null; - OptionalFieldMask = other.optionalFieldMask_ != null ? other.OptionalFieldMask.Clone() : null; - OptionalStruct = other.optionalStruct_ != null ? other.OptionalStruct.Clone() : null; - OptionalAny = other.optionalAny_ != null ? other.OptionalAny.Clone() : null; - OptionalValue = other.optionalValue_ != null ? other.OptionalValue.Clone() : null; + optionalDuration_ = other.optionalDuration_ != null ? other.optionalDuration_.Clone() : null; + optionalTimestamp_ = other.optionalTimestamp_ != null ? other.optionalTimestamp_.Clone() : null; + optionalFieldMask_ = other.optionalFieldMask_ != null ? other.optionalFieldMask_.Clone() : null; + optionalStruct_ = other.optionalStruct_ != null ? other.optionalStruct_.Clone() : null; + optionalAny_ = other.optionalAny_ != null ? other.optionalAny_.Clone() : null; + optionalValue_ = other.optionalValue_ != null ? other.optionalValue_.Clone() : null; repeatedDuration_ = other.repeatedDuration_.Clone(); repeatedTimestamp_ = other.repeatedTimestamp_.Clone(); repeatedFieldmask_ = other.repeatedFieldmask_.Clone(); @@ -3455,7 +3455,7 @@ namespace ProtobufTestMessages.Proto3 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedMessage(NestedMessage other) : this() { a_ = other.a_; - Corecursive = other.corecursive_ != null ? other.Corecursive.Clone() : null; + corecursive_ = other.corecursive_ != null ? other.corecursive_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs index 6d02bda6..3ab5a48b 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs @@ -1740,9 +1740,9 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ComplexOptionType2(ComplexOptionType2 other) : this() { - Bar = other.bar_ != null ? other.Bar.Clone() : null; + bar_ = other.bar_ != null ? other.bar_.Clone() : null; baz_ = other.baz_; - Fred = other.fred_ != null ? other.Fred.Clone() : null; + fred_ = other.fred_ != null ? other.fred_.Clone() : null; barney_ = other.barney_.Clone(); _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -2331,7 +2331,7 @@ namespace UnitTest.Issues.TestProtos { public Aggregate(Aggregate other) : this() { i_ = other.i_; s_ = other.s_; - Sub = other.sub_ != null ? other.Sub.Clone() : null; + sub_ = other.sub_ != null ? other.sub_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs index 01a86f8f..819fc201 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs @@ -704,7 +704,7 @@ namespace UnitTest.Issues.TestProtos { public DeprecatedFieldsMessage(DeprecatedFieldsMessage other) : this() { primitiveValue_ = other.primitiveValue_; primitiveArray_ = other.primitiveArray_.Clone(); - MessageValue = other.messageValue_ != null ? other.MessageValue.Clone() : null; + messageValue_ = other.messageValue_ != null ? other.messageValue_.Clone() : null; messageArray_ = other.messageArray_.Clone(); enumValue_ = other.enumValue_; enumArray_ = other.enumArray_.Clone(); diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs index 4242c192..d5dbe866 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs @@ -280,13 +280,13 @@ namespace Google.Protobuf.TestProtos { singleBool_ = other.singleBool_; singleString_ = other.singleString_; singleBytes_ = other.singleBytes_; - SingleNestedMessage = other.singleNestedMessage_ != null ? other.SingleNestedMessage.Clone() : null; - SingleForeignMessage = other.singleForeignMessage_ != null ? other.SingleForeignMessage.Clone() : null; - SingleImportMessage = other.singleImportMessage_ != null ? other.SingleImportMessage.Clone() : null; + singleNestedMessage_ = other.singleNestedMessage_ != null ? other.singleNestedMessage_.Clone() : null; + singleForeignMessage_ = other.singleForeignMessage_ != null ? other.singleForeignMessage_.Clone() : null; + singleImportMessage_ = other.singleImportMessage_ != null ? other.singleImportMessage_.Clone() : null; singleNestedEnum_ = other.singleNestedEnum_; singleForeignEnum_ = other.singleForeignEnum_; singleImportEnum_ = other.singleImportEnum_; - SinglePublicImportMessage = other.singlePublicImportMessage_ != null ? other.SinglePublicImportMessage.Clone() : null; + singlePublicImportMessage_ = other.singlePublicImportMessage_ != null ? other.singlePublicImportMessage_.Clone() : null; repeatedInt32_ = other.repeatedInt32_.Clone(); repeatedInt64_ = other.repeatedInt64_.Clone(); repeatedUint32_ = other.repeatedUint32_.Clone(); @@ -1786,8 +1786,8 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedTestAllTypes(NestedTestAllTypes other) : this() { - Child = other.child_ != null ? other.Child.Clone() : null; - Payload = other.payload_ != null ? other.Payload.Clone() : null; + child_ = other.child_ != null ? other.child_.Clone() : null; + payload_ = other.payload_ != null ? other.payload_.Clone() : null; repeatedChild_ = other.repeatedChild_.Clone(); _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -2342,7 +2342,7 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestForeignNested(TestForeignNested other) : this() { - ForeignNested = other.foreignNested_ != null ? other.ForeignNested.Clone() : null; + foreignNested_ = other.foreignNested_ != null ? other.foreignNested_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -2641,7 +2641,7 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestRecursiveMessage(TestRecursiveMessage other) : this() { - A = other.a_ != null ? other.A.Clone() : null; + a_ = other.a_ != null ? other.a_.Clone() : null; i_ = other.i_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -2807,7 +2807,7 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMutualRecursionA(TestMutualRecursionA other) : this() { - Bb = other.bb_ != null ? other.Bb.Clone() : null; + bb_ = other.bb_ != null ? other.bb_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -2942,7 +2942,7 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMutualRecursionB(TestMutualRecursionB other) : this() { - A = other.a_ != null ? other.A.Clone() : null; + a_ = other.a_ != null ? other.a_.Clone() : null; optionalInt32_ = other.optionalInt32_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -3241,7 +3241,7 @@ namespace Google.Protobuf.TestProtos { primitiveField_ = other.primitiveField_; stringField_ = other.stringField_; enumField_ = other.enumField_; - MessageField = other.messageField_ != null ? other.MessageField.Clone() : null; + messageField_ = other.messageField_ != null ? other.messageField_.Clone() : null; repeatedPrimitiveField_ = other.repeatedPrimitiveField_.Clone(); repeatedStringField_ = other.repeatedStringField_.Clone(); repeatedEnumField_ = other.repeatedEnumField_.Clone(); @@ -3546,7 +3546,7 @@ namespace Google.Protobuf.TestProtos { myString_ = other.myString_; myInt_ = other.myInt_; myFloat_ = other.myFloat_; - SingleNestedMessage = other.singleNestedMessage_ != null ? other.SingleNestedMessage.Clone() : null; + singleNestedMessage_ = other.singleNestedMessage_ != null ? other.singleNestedMessage_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs index 2e1d2bd6..fe913802 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs @@ -204,15 +204,15 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestWellKnownTypes(TestWellKnownTypes other) : this() { - AnyField = other.anyField_ != null ? other.AnyField.Clone() : null; - ApiField = other.apiField_ != null ? other.ApiField.Clone() : null; - DurationField = other.durationField_ != null ? other.DurationField.Clone() : null; - EmptyField = other.emptyField_ != null ? other.EmptyField.Clone() : null; - FieldMaskField = other.fieldMaskField_ != null ? other.FieldMaskField.Clone() : null; - SourceContextField = other.sourceContextField_ != null ? other.SourceContextField.Clone() : null; - StructField = other.structField_ != null ? other.StructField.Clone() : null; - TimestampField = other.timestampField_ != null ? other.TimestampField.Clone() : null; - TypeField = other.typeField_ != null ? other.TypeField.Clone() : null; + anyField_ = other.anyField_ != null ? other.anyField_.Clone() : null; + apiField_ = other.apiField_ != null ? other.apiField_.Clone() : null; + durationField_ = other.durationField_ != null ? other.durationField_.Clone() : null; + emptyField_ = other.emptyField_ != null ? other.emptyField_.Clone() : null; + fieldMaskField_ = other.fieldMaskField_ != null ? other.fieldMaskField_.Clone() : null; + sourceContextField_ = other.sourceContextField_ != null ? other.sourceContextField_.Clone() : null; + structField_ = other.structField_ != null ? other.structField_.Clone() : null; + timestampField_ = other.timestampField_ != null ? other.timestampField_.Clone() : null; + typeField_ = other.typeField_ != null ? other.typeField_.Clone() : null; DoubleField = other.DoubleField; FloatField = other.FloatField; Int64Field = other.Int64Field; @@ -222,7 +222,7 @@ namespace Google.Protobuf.TestProtos { BoolField = other.BoolField; StringField = other.StringField; BytesField = other.BytesField; - ValueField = other.valueField_ != null ? other.ValueField.Clone() : null; + valueField_ = other.valueField_ != null ? other.valueField_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } -- cgit v1.2.3