aboutsummaryrefslogtreecommitdiff
path: root/csharp/ProtocolBuffers/IMessage.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/ProtocolBuffers/IMessage.cs')
-rw-r--r--csharp/ProtocolBuffers/IMessage.cs40
1 files changed, 17 insertions, 23 deletions
diff --git a/csharp/ProtocolBuffers/IMessage.cs b/csharp/ProtocolBuffers/IMessage.cs
index abb29f72..1ce18a5c 100644
--- a/csharp/ProtocolBuffers/IMessage.cs
+++ b/csharp/ProtocolBuffers/IMessage.cs
@@ -21,11 +21,8 @@ using Google.ProtocolBuffers.Descriptors;
namespace Google.ProtocolBuffers {
/// <summary>
- /// Non-generic interface implemented by all Protocol Buffers messages.
- /// Some members are repeated in the generic interface but with a
- /// type-specific signature. Type-safe implementations
- /// are encouraged to implement these non-generic members explicitly,
- /// and the generic members implicitly.
+ /// Non-generic interface used for all parts of the API which don't require
+ /// any type knowledge.
/// </summary>
public interface IMessage {
/// <summary>
@@ -152,27 +149,17 @@ namespace Google.ProtocolBuffers {
void WriteTo(Stream output);
#endregion
- #region Weakly typed members
/// <summary>
- /// Returns an instance of this message type with all fields set to
- /// their default values. This may or may not be a singleton. This differs
- /// from the DefaultInstance property of each generated message class in that this
- /// method is an abstract method of IMessage whereas DefaultInstance is
- /// a static property of a specific class. They return the same thing.
+ /// Creates a builder for the type, but in a weakly typed manner. This
+ /// is typically implemented by strongly typed builders by just returning
+ /// the result of CreateBuilderForType.
/// </summary>
- IMessage DefaultInstanceForType { get; }
+ IBuilder WeakCreateBuilderForType();
- /// <summary>
- /// Constructs a new builder for a message of the same type as this message.
- /// </summary>
- IBuilder CreateBuilderForType();
- #endregion
+ IMessage WeakDefaultInstanceForType { get; }
}
- /// <summary>
- /// Type-safe interface for all generated messages to implement.
- /// </summary>
- public interface IMessage<T> : IMessage where T : IMessage<T> {
+ public interface IMessage<TMessage> : IMessage {
/// <summary>
/// Returns an instance of this message type with all fields set to
/// their default values. This may or may not be a singleton. This differs
@@ -180,13 +167,20 @@ namespace Google.ProtocolBuffers {
/// method is an abstract method of IMessage whereas DefaultInstance is
/// a static property of a specific class. They return the same thing.
/// </summary>
- new T DefaultInstanceForType { get; }
+ TMessage DefaultInstanceForType { get; }
+ }
+ /// <summary>
+ /// Type-safe interface for all generated messages to implement.
+ /// </summary>
+ public interface IMessage<TMessage, TBuilder> : IMessage<TMessage>
+ where TMessage : IMessage<TMessage, TBuilder>
+ where TBuilder : IBuilder<TMessage, TBuilder> {
#region Builders
/// <summary>
/// Constructs a new builder for a message of the same type as this message.
/// </summary>
- new IBuilder<T> CreateBuilderForType();
+ TBuilder CreateBuilderForType();
#endregion
}
}