diff --git a/csharp/ProtocolBuffers/AbstractBuilder.cs b/csharp/ProtocolBuffers/AbstractBuilder.cs index a76e3479b3..01088f5d96 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. /// public abstract class AbstractBuilder : IBuilder { - - public bool Initialized { - get { throw new NotImplementedException(); } - } - - public IDictionary AllFields { - get { throw new NotImplementedException(); } + #region Unimplemented members of IBuilder + public abstract bool Initialized { get; } + public abstract IDictionary 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(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(FieldDescriptor field) { + return NewBuilderForFieldImpl(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(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 e1d5f883be..18e0953845 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 52d3349b40..d39d794ed5 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 515eadc01a..d10531eba0 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 DefaultInstanceForType { - get { throw new System.NotImplementedException(); } + get { throw new NotImplementedException(); } } public IBuilder CreateBuilderForType() { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } private IDictionary GetMutableFieldMap() {