aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtocolBuffers/IMessage.cs
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2015-06-23 11:54:19 +0100
committerJon Skeet <jonskeet@google.com>2015-06-23 12:42:20 +0100
commit6c1fe6ea3e4e3915fc4164c43230210f9a0ac24f (patch)
tree3acd6ea7eebd05c6e12958ec3cf901d098ad9b14 /csharp/src/ProtocolBuffers/IMessage.cs
parent45b70328f218dc2b3e20191c2cfa92872ef10d04 (diff)
downloadprotobuf-6c1fe6ea3e4e3915fc4164c43230210f9a0ac24f.tar.gz
protobuf-6c1fe6ea3e4e3915fc4164c43230210f9a0ac24f.tar.bz2
protobuf-6c1fe6ea3e4e3915fc4164c43230210f9a0ac24f.zip
Implement Clone.
Fixes issue #527.
Diffstat (limited to 'csharp/src/ProtocolBuffers/IMessage.cs')
-rw-r--r--csharp/src/ProtocolBuffers/IMessage.cs18
1 files changed, 18 insertions, 0 deletions
diff --git a/csharp/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs
index 9c2a2d85..32dfcaff 100644
--- a/csharp/src/ProtocolBuffers/IMessage.cs
+++ b/csharp/src/ProtocolBuffers/IMessage.cs
@@ -93,4 +93,22 @@ namespace Google.Protobuf
/// <param name="message">The message to merge with this one. Must not be null.</param>
void MergeFrom(T message);
}
+
+ /// <summary>
+ /// Generic interface for a deeply cloneable type.
+ /// <summary>
+ /// <remarks>
+ /// In practice, all generated messages implement this interface.
+ /// However, due to the type constraint on <c>T</c> in <see cref="IMessage{T}"/>,
+ /// it is simpler to keep this as a separate interface.
+ /// </remarks>
+ /// <typeparam name="T">The type itself, returned by the <see cref="Clone"/> method.</typeparam>
+ public interface IDeepCloneable<T>
+ {
+ /// <summary>
+ /// Creates a deep clone of this object.
+ /// </summary>
+ /// <returns>A deep clone of this object.</returns>
+ T Clone();
+ }
} \ No newline at end of file