aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Skeet <skeet@pobox.com>2008-08-14 20:33:33 +0100
committerJon Skeet <skeet@pobox.com>2008-08-14 20:33:33 +0100
commitb83aee759acd079c5cd42c77c36697771de15118 (patch)
tree3fe4e7d9d624b2e3d3b62c603fe91262858ce931
parent621bb698e54a7e0d2fdf74ab1f380183461ce7fa (diff)
downloadprotobuf-b83aee759acd079c5cd42c77c36697771de15118.tar.gz
protobuf-b83aee759acd079c5cd42c77c36697771de15118.tar.bz2
protobuf-b83aee759acd079c5cd42c77c36697771de15118.zip
Fix AbstractMessage and AbstractBuilder to get the explicit interface implementation sorted
-rw-r--r--csharp/ProtocolBuffers/AbstractBuilder.cs104
-rw-r--r--csharp/ProtocolBuffers/AbstractMessage.cs17
-rw-r--r--csharp/ProtocolBuffers/GeneratedExtension.cs5
-rw-r--r--csharp/ProtocolBuffers/GeneratedMessage.cs13
4 files changed, 65 insertions, 74 deletions
diff --git a/csharp/ProtocolBuffers/AbstractBuilder.cs b/csharp/ProtocolBuffers/AbstractBuilder.cs
index a76e3479..01088f5d 100644
--- a/csharp/ProtocolBuffers/AbstractBuilder.cs
+++ b/csharp/ProtocolBuffers/AbstractBuilder.cs
@@ -10,44 +10,55 @@ namespace Google.ProtocolBuffers {
/// Implementation of the non-generic IMessage interface as far as possible.
/// </summary>
public abstract class AbstractBuilder : IBuilder {
-
- public bool Initialized {
- get { throw new NotImplementedException(); }
- }
-
- public IDictionary<FieldDescriptor, object> AllFields {
- get { throw new NotImplementedException(); }
+ #region Unimplemented members of IBuilder
+ public abstract bool Initialized { get; }
+ public abstract IDictionary<FieldDescriptor, object> AllFields { get; }
+ public abstract object this[FieldDescriptor field] { get; set; }
+ public abstract MessageDescriptor DescriptorForType { get; }
+ public abstract int GetRepeatedFieldCount(FieldDescriptor field);
+ public abstract object this[FieldDescriptor field, int index] { get; set; }
+ public abstract bool HasField(FieldDescriptor field);
+ #endregion
+
+ #region New abstract methods to be overridden by implementations, allow explicit interface implementation
+ protected abstract IMessage BuildImpl();
+ protected abstract IMessage BuildPartialImpl();
+ protected abstract IBuilder CloneImpl();
+ protected abstract IMessage DefaultInstanceForTypeImpl { get; }
+ protected abstract IBuilder NewBuilderForFieldImpl<TField>(FieldDescriptor field);
+ protected abstract IBuilder ClearFieldImpl();
+ protected abstract IBuilder AddRepeatedFieldImpl(FieldDescriptor field, object value);
+ #endregion
+
+ #region Methods simply proxying to the "Impl" methods, explicitly implementing IBuilder
+ IMessage IBuilder.Build() {
+ return BuildImpl();
+ }
+
+ IMessage IBuilder.BuildPartial() {
+ return BuildPartialImpl();
}
- public object this[FieldDescriptor field] {
- get {
- throw new NotImplementedException();
- }
- set {
- throw new NotImplementedException();
- }
+ public IBuilder Clone() {
+ return CloneImpl();
}
-
- public MessageDescriptor DescriptorForType {
- get { throw new NotImplementedException(); }
+
+ public IMessage DefaultInstanceForType {
+ get { return DefaultInstanceForTypeImpl; }
}
- public int GetRepeatedFieldCount(FieldDescriptor field) {
- throw new NotImplementedException();
+ public IBuilder NewBuilderForField<TField>(FieldDescriptor field) {
+ return NewBuilderForFieldImpl<TField>(field);
}
- public object this[FieldDescriptor field, int index] {
- get {
- throw new NotImplementedException();
- }
- set {
- throw new NotImplementedException();
- }
+ public IBuilder ClearField(FieldDescriptor field) {
+ return ClearFieldImpl();
}
- public bool HasField(FieldDescriptor field) {
- throw new NotImplementedException();
+ public IBuilder AddRepeatedField(FieldDescriptor field, object value) {
+ return AddRepeatedFieldImpl(field, value);
}
+ #endregion
public IBuilder Clear() {
foreach(FieldDescriptor field in AllFields.Keys) {
@@ -95,18 +106,6 @@ namespace Google.ProtocolBuffers {
return this;
}
- public IMessage Build() {
- throw new NotImplementedException();
- }
-
- public IMessage BuildPartial() {
- throw new NotImplementedException();
- }
-
- public IBuilder Clone() {
- throw new NotImplementedException();
- }
-
public IBuilder MergeFrom(CodedInputStream input) {
return MergeFrom(input, ExtensionRegistry.Empty);
}
@@ -118,22 +117,6 @@ namespace Google.ProtocolBuffers {
return this;
}
- public IMessage DefaultInstanceForType {
- get { throw new NotImplementedException(); }
- }
-
- public IBuilder NewBuilderForField<TField>(FieldDescriptor field) {
- throw new NotImplementedException();
- }
-
- public IBuilder ClearField(FieldDescriptor field) {
- throw new NotImplementedException();
- }
-
- public IBuilder AddRepeatedField(FieldDescriptor field, object value) {
- throw new NotImplementedException();
- }
-
public IBuilder MergeUnknownFields(UnknownFieldSet unknownFields) {
UnknownFields = UnknownFieldSet.CreateBuilder(UnknownFields)
.MergeFrom(unknownFields)
@@ -141,14 +124,7 @@ namespace Google.ProtocolBuffers {
return this;
}
- public UnknownFieldSet UnknownFields {
- get {
- throw new NotImplementedException();
- }
- set {
- throw new NotImplementedException();
- }
- }
+ public UnknownFieldSet UnknownFields { get; set; }
public IBuilder MergeFrom(ByteString data) {
CodedInputStream input = data.CreateCodedInput();
diff --git a/csharp/ProtocolBuffers/AbstractMessage.cs b/csharp/ProtocolBuffers/AbstractMessage.cs
index e1d5f883..18e09538 100644
--- a/csharp/ProtocolBuffers/AbstractMessage.cs
+++ b/csharp/ProtocolBuffers/AbstractMessage.cs
@@ -40,9 +40,20 @@ namespace Google.ProtocolBuffers {
public abstract int GetRepeatedFieldCount(FieldDescriptor field);
public abstract object this[FieldDescriptor field, int index] { get; }
public abstract UnknownFieldSet UnknownFields { get; }
- // FIXME
- IMessage IMessage.DefaultInstanceForType { get { return null; } }
- IBuilder IMessage.CreateBuilderForType() { return null; }
+ #endregion
+
+ #region New abstract methods to be overridden by implementations, allow explicit interface implementation
+ protected abstract IMessage DefaultInstanceForTypeImpl { get; }
+ protected abstract IBuilder CreateBuilderForTypeImpl();
+ #endregion
+
+ #region Methods simply proxying to the "Impl" methods, explicitly implementing IMessage
+ IMessage IMessage.DefaultInstanceForType {
+ get { return DefaultInstanceForTypeImpl; }
+ }
+ IBuilder IMessage.CreateBuilderForType() {
+ return CreateBuilderForTypeImpl();
+ }
#endregion
public bool IsInitialized {
diff --git a/csharp/ProtocolBuffers/GeneratedExtension.cs b/csharp/ProtocolBuffers/GeneratedExtension.cs
index 52d3349b..d39d794e 100644
--- a/csharp/ProtocolBuffers/GeneratedExtension.cs
+++ b/csharp/ProtocolBuffers/GeneratedExtension.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Google.ProtocolBuffers.Descriptors;
+using Google.ProtocolBuffers.Descriptors;
namespace Google.ProtocolBuffers {
diff --git a/csharp/ProtocolBuffers/GeneratedMessage.cs b/csharp/ProtocolBuffers/GeneratedMessage.cs
index 515eadc0..d10531eb 100644
--- a/csharp/ProtocolBuffers/GeneratedMessage.cs
+++ b/csharp/ProtocolBuffers/GeneratedMessage.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Text;
using Google.ProtocolBuffers.Descriptors;
using Google.ProtocolBuffers.FieldAccess;
@@ -22,12 +21,20 @@ namespace Google.ProtocolBuffers {
get { return InternalFieldAccessors.Descriptor; }
}
+ protected override IMessage DefaultInstanceForTypeImpl {
+ get { return DefaultInstanceForType; }
+ }
+
+ protected override IBuilder CreateBuilderForTypeImpl() {
+ return CreateBuilderForType();
+ }
+
public IMessage<TMessage> DefaultInstanceForType {
- get { throw new System.NotImplementedException(); }
+ get { throw new NotImplementedException(); }
}
public IBuilder<TMessage> CreateBuilderForType() {
- throw new System.NotImplementedException();
+ throw new NotImplementedException();
}
private IDictionary<FieldDescriptor, Object> GetMutableFieldMap() {