Commit b83aee75 authored by Jon Skeet's avatar Jon Skeet

Fix AbstractMessage and AbstractBuilder to get the explicit interface implementation sorted

parent 621bb698
...@@ -10,44 +10,55 @@ namespace Google.ProtocolBuffers { ...@@ -10,44 +10,55 @@ namespace Google.ProtocolBuffers {
/// Implementation of the non-generic IMessage interface as far as possible. /// Implementation of the non-generic IMessage interface as far as possible.
/// </summary> /// </summary>
public abstract class AbstractBuilder : IBuilder { public abstract class AbstractBuilder : IBuilder {
#region Unimplemented members of IBuilder
public bool Initialized { public abstract bool Initialized { get; }
get { throw new NotImplementedException(); } public abstract IDictionary<FieldDescriptor, object> AllFields { get; }
} public abstract object this[FieldDescriptor field] { get; set; }
public abstract MessageDescriptor DescriptorForType { get; }
public IDictionary<FieldDescriptor, object> AllFields { public abstract int GetRepeatedFieldCount(FieldDescriptor field);
get { throw new NotImplementedException(); } 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] { public IBuilder Clone() {
get { return CloneImpl();
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
} }
public MessageDescriptor DescriptorForType { public IMessage DefaultInstanceForType {
get { throw new NotImplementedException(); } get { return DefaultInstanceForTypeImpl; }
} }
public int GetRepeatedFieldCount(FieldDescriptor field) { public IBuilder NewBuilderForField<TField>(FieldDescriptor field) {
throw new NotImplementedException(); return NewBuilderForFieldImpl<TField>(field);
} }
public object this[FieldDescriptor field, int index] { public IBuilder ClearField(FieldDescriptor field) {
get { return ClearFieldImpl();
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
} }
public bool HasField(FieldDescriptor field) { public IBuilder AddRepeatedField(FieldDescriptor field, object value) {
throw new NotImplementedException(); return AddRepeatedFieldImpl(field, value);
} }
#endregion
public IBuilder Clear() { public IBuilder Clear() {
foreach(FieldDescriptor field in AllFields.Keys) { foreach(FieldDescriptor field in AllFields.Keys) {
...@@ -95,18 +106,6 @@ namespace Google.ProtocolBuffers { ...@@ -95,18 +106,6 @@ namespace Google.ProtocolBuffers {
return this; 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) { public IBuilder MergeFrom(CodedInputStream input) {
return MergeFrom(input, ExtensionRegistry.Empty); return MergeFrom(input, ExtensionRegistry.Empty);
} }
...@@ -118,22 +117,6 @@ namespace Google.ProtocolBuffers { ...@@ -118,22 +117,6 @@ namespace Google.ProtocolBuffers {
return this; 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) { public IBuilder MergeUnknownFields(UnknownFieldSet unknownFields) {
UnknownFields = UnknownFieldSet.CreateBuilder(UnknownFields) UnknownFields = UnknownFieldSet.CreateBuilder(UnknownFields)
.MergeFrom(unknownFields) .MergeFrom(unknownFields)
...@@ -141,14 +124,7 @@ namespace Google.ProtocolBuffers { ...@@ -141,14 +124,7 @@ namespace Google.ProtocolBuffers {
return this; return this;
} }
public UnknownFieldSet UnknownFields { public UnknownFieldSet UnknownFields { get; set; }
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public IBuilder MergeFrom(ByteString data) { public IBuilder MergeFrom(ByteString data) {
CodedInputStream input = data.CreateCodedInput(); CodedInputStream input = data.CreateCodedInput();
......
...@@ -40,9 +40,20 @@ namespace Google.ProtocolBuffers { ...@@ -40,9 +40,20 @@ namespace Google.ProtocolBuffers {
public abstract int GetRepeatedFieldCount(FieldDescriptor field); public abstract int GetRepeatedFieldCount(FieldDescriptor field);
public abstract object this[FieldDescriptor field, int index] { get; } public abstract object this[FieldDescriptor field, int index] { get; }
public abstract UnknownFieldSet UnknownFields { get; } public abstract UnknownFieldSet UnknownFields { get; }
// FIXME #endregion
IMessage IMessage.DefaultInstanceForType { get { return null; } }
IBuilder IMessage.CreateBuilderForType() { return null; } #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 #endregion
public bool IsInitialized { public bool IsInitialized {
......
using System; using Google.ProtocolBuffers.Descriptors;
using System.Collections.Generic;
using System.Text;
using Google.ProtocolBuffers.Descriptors;
namespace Google.ProtocolBuffers { namespace Google.ProtocolBuffers {
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using Google.ProtocolBuffers.Descriptors; using Google.ProtocolBuffers.Descriptors;
using Google.ProtocolBuffers.FieldAccess; using Google.ProtocolBuffers.FieldAccess;
...@@ -22,12 +21,20 @@ namespace Google.ProtocolBuffers { ...@@ -22,12 +21,20 @@ namespace Google.ProtocolBuffers {
get { return InternalFieldAccessors.Descriptor; } get { return InternalFieldAccessors.Descriptor; }
} }
protected override IMessage DefaultInstanceForTypeImpl {
get { return DefaultInstanceForType; }
}
protected override IBuilder CreateBuilderForTypeImpl() {
return CreateBuilderForType();
}
public IMessage<TMessage> DefaultInstanceForType { public IMessage<TMessage> DefaultInstanceForType {
get { throw new System.NotImplementedException(); } get { throw new NotImplementedException(); }
} }
public IBuilder<TMessage> CreateBuilderForType() { public IBuilder<TMessage> CreateBuilderForType() {
throw new System.NotImplementedException(); throw new NotImplementedException();
} }
private IDictionary<FieldDescriptor, Object> GetMutableFieldMap() { private IDictionary<FieldDescriptor, Object> GetMutableFieldMap() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment