diff options
author | Jon Skeet <jonskeet@google.com> | 2015-06-23 11:54:19 +0100 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2015-06-23 12:42:20 +0100 |
commit | 6c1fe6ea3e4e3915fc4164c43230210f9a0ac24f (patch) | |
tree | 3acd6ea7eebd05c6e12958ec3cf901d098ad9b14 /csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs | |
parent | 45b70328f218dc2b3e20191c2cfa92872ef10d04 (diff) | |
download | protobuf-6c1fe6ea3e4e3915fc4164c43230210f9a0ac24f.tar.gz protobuf-6c1fe6ea3e4e3915fc4164c43230210f9a0ac24f.tar.bz2 protobuf-6c1fe6ea3e4e3915fc4164c43230210f9a0ac24f.zip |
Implement Clone.
Fixes issue #527.
Diffstat (limited to 'csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs')
-rw-r--r-- | csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index 959b3866..df149323 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -90,7 +90,7 @@ namespace UnitTest.Issues.TestProtos { #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NegativeEnumMessage : pb::IMessage<NegativeEnumMessage>, global::System.IEquatable<NegativeEnumMessage> { + public sealed partial class NegativeEnumMessage : pb::IMessage<NegativeEnumMessage>, global::System.IEquatable<NegativeEnumMessage>, pb::IDeepCloneable<NegativeEnumMessage> { private static readonly pb::MessageParser<NegativeEnumMessage> _parser = new pb::MessageParser<NegativeEnumMessage>(() => new NegativeEnumMessage()); public static pb::MessageParser<NegativeEnumMessage> Parser { get { return _parser; } } @@ -105,9 +105,17 @@ namespace UnitTest.Issues.TestProtos { } public NegativeEnumMessage() { } + public NegativeEnumMessage(NegativeEnumMessage other) { - MergeFrom(other); + value_ = other.value_; + values_ = other.values_.Clone(); + packedValues_ = other.packedValues_.Clone(); + } + + public NegativeEnumMessage Clone() { + return new NegativeEnumMessage(this); } + public const int ValueFieldNumber = 1; private global::UnitTest.Issues.TestProtos.NegativeEnum value_ = global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO; public global::UnitTest.Issues.TestProtos.NegativeEnum Value { @@ -233,7 +241,7 @@ namespace UnitTest.Issues.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DeprecatedChild : pb::IMessage<DeprecatedChild>, global::System.IEquatable<DeprecatedChild> { + public sealed partial class DeprecatedChild : pb::IMessage<DeprecatedChild>, global::System.IEquatable<DeprecatedChild>, pb::IDeepCloneable<DeprecatedChild> { private static readonly pb::MessageParser<DeprecatedChild> _parser = new pb::MessageParser<DeprecatedChild>(() => new DeprecatedChild()); public static pb::MessageParser<DeprecatedChild> Parser { get { return _parser; } } @@ -248,9 +256,14 @@ namespace UnitTest.Issues.TestProtos { } public DeprecatedChild() { } + public DeprecatedChild(DeprecatedChild other) { - MergeFrom(other); } + + public DeprecatedChild Clone() { + return new DeprecatedChild(this); + } + public override bool Equals(object other) { return Equals(other as DeprecatedChild); } @@ -301,7 +314,7 @@ namespace UnitTest.Issues.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DeprecatedFieldsMessage : pb::IMessage<DeprecatedFieldsMessage>, global::System.IEquatable<DeprecatedFieldsMessage> { + public sealed partial class DeprecatedFieldsMessage : pb::IMessage<DeprecatedFieldsMessage>, global::System.IEquatable<DeprecatedFieldsMessage>, pb::IDeepCloneable<DeprecatedFieldsMessage> { private static readonly pb::MessageParser<DeprecatedFieldsMessage> _parser = new pb::MessageParser<DeprecatedFieldsMessage>(() => new DeprecatedFieldsMessage()); public static pb::MessageParser<DeprecatedFieldsMessage> Parser { get { return _parser; } } @@ -316,9 +329,20 @@ namespace UnitTest.Issues.TestProtos { } public DeprecatedFieldsMessage() { } + public DeprecatedFieldsMessage(DeprecatedFieldsMessage other) { - MergeFrom(other); + primitiveValue_ = other.primitiveValue_; + primitiveArray_ = other.primitiveArray_.Clone(); + MessageValue = other.messageValue_ != null ? other.MessageValue.Clone() : null; + messageArray_ = other.messageArray_.Clone(); + enumValue_ = other.enumValue_; + enumArray_ = other.enumArray_.Clone(); + } + + public DeprecatedFieldsMessage Clone() { + return new DeprecatedFieldsMessage(this); } + public const int PrimitiveValueFieldNumber = 1; private int primitiveValue_; [global::System.ObsoleteAttribute()] @@ -525,7 +549,7 @@ namespace UnitTest.Issues.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ItemField : pb::IMessage<ItemField>, global::System.IEquatable<ItemField> { + public sealed partial class ItemField : pb::IMessage<ItemField>, global::System.IEquatable<ItemField>, pb::IDeepCloneable<ItemField> { private static readonly pb::MessageParser<ItemField> _parser = new pb::MessageParser<ItemField>(() => new ItemField()); public static pb::MessageParser<ItemField> Parser { get { return _parser; } } @@ -540,9 +564,15 @@ namespace UnitTest.Issues.TestProtos { } public ItemField() { } + public ItemField(ItemField other) { - MergeFrom(other); + item_ = other.item_; + } + + public ItemField Clone() { + return new ItemField(this); } + public const int ItemFieldNumber = 1; private int item_; public int Item { |