From 8c896b259ecda6160ad2839fab59fad71ae77a7c Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 23 Jun 2015 20:04:39 +0100 Subject: Implement requested changes for IMessage 1) New line at end of file 2) Make IMessage itself extend IEquatable and IDeepCloneable --- csharp/src/ProtocolBuffers/IMessage.cs | 9 +++++---- src/google/protobuf/compiler/csharp/csharp_message.cc | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/csharp/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs index 32dfcaff..5d662cfd 100644 --- a/csharp/src/ProtocolBuffers/IMessage.cs +++ b/csharp/src/ProtocolBuffers/IMessage.cs @@ -34,6 +34,7 @@ #endregion +using System; using Google.Protobuf.FieldAccess; namespace Google.Protobuf @@ -84,7 +85,7 @@ namespace Google.Protobuf /// the implementation class. /// /// The message type. - public interface IMessage : IMessage where T : IMessage + public interface IMessage : IMessage, IEquatable, IDeepCloneable where T : IMessage { /// /// Merges the given message into this one. @@ -98,8 +99,8 @@ namespace Google.Protobuf /// Generic interface for a deeply cloneable type. /// /// - /// In practice, all generated messages implement this interface. - /// However, due to the type constraint on T in , + /// All generated messages implement this interface, but so do some non-message types. + /// Additionally, due to the type constraint on T in , /// it is simpler to keep this as a separate interface. /// /// The type itself, returned by the method. @@ -111,4 +112,4 @@ namespace Google.Protobuf /// A deep clone of this object. T Clone(); } -} \ No newline at end of file +} diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 32d0a82d..39938fa3 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -179,7 +179,7 @@ void MessageGenerator::Generate(io::Printer* printer) { WriteGeneratedCodeAttributes(printer); printer->Print( vars, - "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$>, global::System.IEquatable<$class_name$>, pb::IDeepCloneable<$class_name$> {\n"); + "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$> {\n"); printer->Indent(); // All static fields and properties -- cgit v1.2.3