diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2015-06-19 12:59:07 -0700 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2015-06-19 12:59:07 -0700 |
commit | 45b70328f218dc2b3e20191c2cfa92872ef10d04 (patch) | |
tree | 8c4441b6abee41b5e960e7013e5aeb6761616a22 /csharp/src/ProtocolBuffers | |
parent | 5b3a8e76356ef2dcb4a87c3fa7323bdec01cf7ce (diff) | |
parent | 50a3a809e849fad5a53be5ccbaefaa02a106b535 (diff) | |
download | protobuf-45b70328f218dc2b3e20191c2cfa92872ef10d04.tar.gz protobuf-45b70328f218dc2b3e20191c2cfa92872ef10d04.tar.bz2 protobuf-45b70328f218dc2b3e20191c2cfa92872ef10d04.zip |
Merge pull request #515 from jskeet/proto3-only
Proto3 experimental C# fork
Diffstat (limited to 'csharp/src/ProtocolBuffers')
96 files changed, 4129 insertions, 23438 deletions
diff --git a/csharp/src/ProtocolBuffers/AbstractBuilder.cs b/csharp/src/ProtocolBuffers/AbstractBuilder.cs deleted file mode 100644 index 8e33e931..00000000 --- a/csharp/src/ProtocolBuffers/AbstractBuilder.cs +++ /dev/null @@ -1,274 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Implementation of the non-generic IMessage interface as far as possible.
- /// </summary>
- public abstract partial class AbstractBuilder<TMessage, TBuilder> : AbstractBuilderLite<TMessage, TBuilder>,
- IBuilder<TMessage, TBuilder>
- where TMessage : AbstractMessage<TMessage, TBuilder>
- where TBuilder : AbstractBuilder<TMessage, TBuilder>
- {
- #region Unimplemented members of IBuilder
-
- public abstract UnknownFieldSet UnknownFields { get; set; }
- 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);
- public abstract bool HasOneof(OneofDescriptor oneof);
- public abstract FieldDescriptor OneofFieldDescriptor(OneofDescriptor oneof);
- public abstract IBuilder CreateBuilderForField(FieldDescriptor field);
- public abstract TBuilder ClearField(FieldDescriptor field);
- public abstract TBuilder ClearOneof(OneofDescriptor oneof);
- public abstract TBuilder AddRepeatedField(FieldDescriptor field, object value);
-
- #endregion
-
- public TBuilder SetUnknownFields(UnknownFieldSet fields)
- {
- UnknownFields = fields;
- return ThisBuilder;
- }
-
- public override TBuilder Clear()
- {
- foreach (FieldDescriptor field in AllFields.Keys)
- {
- ClearField(field);
- }
- return ThisBuilder;
- }
-
- public override sealed TBuilder MergeFrom(IMessageLite other)
- {
- if (other is IMessage)
- {
- return MergeFrom((IMessage) other);
- }
- throw new ArgumentException("MergeFrom(Message) can only merge messages of the same type.");
- }
-
- /// <summary>
- /// Merge the specified other message into the message being
- /// built. Merging occurs as follows. For each field:
- /// For singular primitive fields, if the field is set in <paramref name="other"/>,
- /// then <paramref name="other"/>'s value overwrites the value in this message.
- /// For singular message fields, if the field is set in <paramref name="other"/>,
- /// it is merged into the corresponding sub-message of this message using the same
- /// merging rules.
- /// For repeated fields, the elements in <paramref name="other"/> are concatenated
- /// with the elements in this message.
- /// </summary>
- /// <param name="other"></param>
- /// <returns></returns>
- public abstract TBuilder MergeFrom(TMessage other);
-
- public virtual TBuilder MergeFrom(IMessage other)
- {
- if (other.DescriptorForType != DescriptorForType)
- {
- throw new ArgumentException("MergeFrom(IMessage) can only merge messages of the same type.");
- }
-
- // Note: We don't attempt to verify that other's fields have valid
- // types. Doing so would be a losing battle. We'd have to verify
- // all sub-messages as well, and we'd have to make copies of all of
- // them to insure that they don't change after verification (since
- // the Message interface itself cannot enforce immutability of
- // implementations).
- // TODO(jonskeet): Provide a function somewhere called MakeDeepCopy()
- // which allows people to make secure deep copies of messages.
- foreach (KeyValuePair<FieldDescriptor, object> entry in other.AllFields)
- {
- FieldDescriptor field = entry.Key;
- if (field.IsRepeated)
- {
- // Concatenate repeated fields
- foreach (object element in (IEnumerable) entry.Value)
- {
- AddRepeatedField(field, element);
- }
- }
- else if (field.MappedType == MappedType.Message)
- {
- // Merge singular messages
- IMessageLite existingValue = (IMessageLite) this[field];
- if (existingValue == existingValue.WeakDefaultInstanceForType)
- {
- this[field] = entry.Value;
- }
- else
- {
- this[field] = existingValue.WeakCreateBuilderForType()
- .WeakMergeFrom(existingValue)
- .WeakMergeFrom((IMessageLite) entry.Value)
- .WeakBuild();
- }
- }
- else
- {
- // Overwrite simple values
- this[field] = entry.Value;
- }
- }
-
- //Fix for unknown fields not merging, see java's AbstractMessage.Builder<T> line 236
- MergeUnknownFields(other.UnknownFields);
-
- return ThisBuilder;
- }
-
- public override TBuilder MergeFrom(ICodedInputStream input, ExtensionRegistry extensionRegistry)
- {
- UnknownFieldSet.Builder unknownFields = UnknownFieldSet.CreateBuilder(UnknownFields);
- unknownFields.MergeFrom(input, extensionRegistry, this);
- UnknownFields = unknownFields.Build();
- return ThisBuilder;
- }
-
- public virtual TBuilder MergeUnknownFields(UnknownFieldSet unknownFields)
- {
- UnknownFields = UnknownFieldSet.CreateBuilder(UnknownFields)
- .MergeFrom(unknownFields)
- .Build();
- return ThisBuilder;
- }
-
- public virtual IBuilder SetField(FieldDescriptor field, object value)
- {
- this[field] = value;
- return ThisBuilder;
- }
-
- public virtual IBuilder SetRepeatedField(FieldDescriptor field, int index, object value)
- {
- this[field, index] = value;
- return ThisBuilder;
- }
-
- #region Explicit Implementations
-
- IMessage IBuilder.WeakBuild()
- {
- return Build();
- }
-
- IBuilder IBuilder.WeakAddRepeatedField(FieldDescriptor field, object value)
- {
- return AddRepeatedField(field, value);
- }
-
- IBuilder IBuilder.WeakClear()
- {
- return Clear();
- }
-
- IBuilder IBuilder.WeakMergeFrom(IMessage message)
- {
- return MergeFrom(message);
- }
-
- IBuilder IBuilder.WeakMergeFrom(ICodedInputStream input)
- {
- return MergeFrom(input);
- }
-
- IBuilder IBuilder.WeakMergeFrom(ICodedInputStream input, ExtensionRegistry registry)
- {
- return MergeFrom(input, registry);
- }
-
- IBuilder IBuilder.WeakMergeFrom(ByteString data)
- {
- return MergeFrom(data);
- }
-
- IBuilder IBuilder.WeakMergeFrom(ByteString data, ExtensionRegistry registry)
- {
- return MergeFrom(data, registry);
- }
-
- IMessage IBuilder.WeakBuildPartial()
- {
- return BuildPartial();
- }
-
- IBuilder IBuilder.WeakClone()
- {
- return Clone();
- }
-
- IMessage IBuilder.WeakDefaultInstanceForType
- {
- get { return DefaultInstanceForType; }
- }
-
- IBuilder IBuilder.WeakClearField(FieldDescriptor field)
- {
- return ClearField(field);
- }
-
- IBuilder IBuilder.WeakClearOneof(OneofDescriptor oneof)
- {
- return ClearOneof(oneof);
- }
-
- #endregion
-
- /// <summary>
- /// Converts this builder to a string using <see cref="TextFormat" />.
- /// </summary>
- /// <remarks>
- /// This method is not sealed (in the way that it is in <see cref="AbstractMessage{TMessage, TBuilder}" />
- /// as it was added after earlier releases; some other implementations may already be overriding the
- /// method.
- /// </remarks>
- public override string ToString()
- {
- return TextFormat.PrintToString(this);
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/AbstractBuilderLite.cs b/csharp/src/ProtocolBuffers/AbstractBuilderLite.cs deleted file mode 100644 index a7fedeae..00000000 --- a/csharp/src/ProtocolBuffers/AbstractBuilderLite.cs +++ /dev/null @@ -1,264 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.IO;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Implementation of the non-generic IMessage interface as far as possible.
- /// </summary>
- public abstract partial class AbstractBuilderLite<TMessage, TBuilder> : IBuilderLite<TMessage, TBuilder>
- where TMessage : AbstractMessageLite<TMessage, TBuilder>
- where TBuilder : AbstractBuilderLite<TMessage, TBuilder>
- {
- protected abstract TBuilder ThisBuilder { get; }
-
- public abstract bool IsInitialized { get; }
-
- public abstract TBuilder Clear();
-
- public abstract TBuilder Clone();
-
- public abstract TMessage Build();
-
- public abstract TMessage BuildPartial();
-
- public abstract TBuilder MergeFrom(IMessageLite other);
-
- public abstract TBuilder MergeFrom(ICodedInputStream input, ExtensionRegistry extensionRegistry);
-
- public abstract TMessage DefaultInstanceForType { get; }
-
- #region IBuilderLite<TMessage,TBuilder> Members
-
- public virtual TBuilder MergeFrom(ICodedInputStream input)
- {
- return MergeFrom(input, ExtensionRegistry.CreateInstance());
- }
-
- public TBuilder MergeDelimitedFrom(Stream input)
- {
- return MergeDelimitedFrom(input, ExtensionRegistry.CreateInstance());
- }
-
- public TBuilder MergeDelimitedFrom(Stream input, ExtensionRegistry extensionRegistry)
- {
- int size = (int) CodedInputStream.ReadRawVarint32(input);
- Stream limitedStream = new LimitedInputStream(input, size);
- return MergeFrom(limitedStream, extensionRegistry);
- }
-
- public TBuilder MergeFrom(ByteString data)
- {
- return MergeFrom(data, ExtensionRegistry.CreateInstance());
- }
-
- public TBuilder MergeFrom(ByteString data, ExtensionRegistry extensionRegistry)
- {
- CodedInputStream input = data.CreateCodedInput();
- MergeFrom(input, extensionRegistry);
- input.CheckLastTagWas(0);
- return ThisBuilder;
- }
-
- public TBuilder MergeFrom(byte[] data)
- {
- CodedInputStream input = CodedInputStream.CreateInstance(data);
- MergeFrom(input);
- input.CheckLastTagWas(0);
- return ThisBuilder;
- }
-
- public TBuilder MergeFrom(byte[] data, ExtensionRegistry extensionRegistry)
- {
- CodedInputStream input = CodedInputStream.CreateInstance(data);
- MergeFrom(input, extensionRegistry);
- input.CheckLastTagWas(0);
- return ThisBuilder;
- }
-
- public TBuilder MergeFrom(Stream input)
- {
- CodedInputStream codedInput = CodedInputStream.CreateInstance(input);
- MergeFrom(codedInput);
- codedInput.CheckLastTagWas(0);
- return ThisBuilder;
- }
-
- public TBuilder MergeFrom(Stream input, ExtensionRegistry extensionRegistry)
- {
- CodedInputStream codedInput = CodedInputStream.CreateInstance(input);
- MergeFrom(codedInput, extensionRegistry);
- codedInput.CheckLastTagWas(0);
- return ThisBuilder;
- }
-
- #endregion
-
- #region Explicit definitions
-
- IBuilderLite IBuilderLite.WeakClear()
- {
- return Clear();
- }
-
- IBuilderLite IBuilderLite.WeakMergeFrom(IMessageLite message)
- {
- return MergeFrom(message);
- }
-
- IBuilderLite IBuilderLite.WeakMergeFrom(ByteString data)
- {
- return MergeFrom(data);
- }
-
- IBuilderLite IBuilderLite.WeakMergeFrom(ByteString data, ExtensionRegistry registry)
- {
- return MergeFrom(data, registry);
- }
-
- IBuilderLite IBuilderLite.WeakMergeFrom(ICodedInputStream input)
- {
- return MergeFrom(input);
- }
-
- IBuilderLite IBuilderLite.WeakMergeFrom(ICodedInputStream input, ExtensionRegistry registry)
- {
- return MergeFrom(input, registry);
- }
-
- IMessageLite IBuilderLite.WeakBuild()
- {
- return Build();
- }
-
- IMessageLite IBuilderLite.WeakBuildPartial()
- {
- return BuildPartial();
- }
-
- IBuilderLite IBuilderLite.WeakClone()
- {
- return Clone();
- }
-
- IMessageLite IBuilderLite.WeakDefaultInstanceForType
- {
- get { return DefaultInstanceForType; }
- }
-
- #endregion
-
- #region LimitedInputStream
-
- /// <summary>
- /// Stream implementation which proxies another stream, only allowing a certain amount
- /// of data to be read. Note that this is only used to read delimited streams, so it
- /// doesn't attempt to implement everything.
- /// </summary>
- private class LimitedInputStream : Stream
- {
- private readonly Stream proxied;
- private int bytesLeft;
-
- internal LimitedInputStream(Stream proxied, int size)
- {
- this.proxied = proxied;
- bytesLeft = size;
- }
-
- public override bool CanRead
- {
- get { return true; }
- }
-
- public override bool CanSeek
- {
- get { return false; }
- }
-
- public override bool CanWrite
- {
- get { return false; }
- }
-
- public override void Flush()
- {
- }
-
- public override long Length
- {
- get { throw new NotSupportedException(); }
- }
-
- public override long Position
- {
- get { throw new NotSupportedException(); }
- set { throw new NotSupportedException(); }
- }
-
- public override int Read(byte[] buffer, int offset, int count)
- {
- if (bytesLeft > 0)
- {
- int bytesRead = proxied.Read(buffer, offset, Math.Min(bytesLeft, count));
- bytesLeft -= bytesRead;
- return bytesRead;
- }
- return 0;
- }
-
- public override long Seek(long offset, SeekOrigin origin)
- {
- throw new NotSupportedException();
- }
-
- public override void SetLength(long value)
- {
- throw new NotSupportedException();
- }
-
- public override void Write(byte[] buffer, int offset, int count)
- {
- throw new NotSupportedException();
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/AbstractMessage.cs b/csharp/src/ProtocolBuffers/AbstractMessage.cs deleted file mode 100644 index ef057e6f..00000000 --- a/csharp/src/ProtocolBuffers/AbstractMessage.cs +++ /dev/null @@ -1,293 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-using Google.ProtocolBuffers.Collections;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Implementation of the non-generic IMessage interface as far as possible.
- /// </summary>
- public abstract partial class AbstractMessage<TMessage, TBuilder> : AbstractMessageLite<TMessage, TBuilder>,
- IMessage<TMessage, TBuilder>
- where TMessage : AbstractMessage<TMessage, TBuilder>
- where TBuilder : AbstractBuilder<TMessage, TBuilder>
- {
- /// <summary>
- /// The serialized size if it's already been computed, or null
- /// if we haven't computed it yet.
- /// </summary>
- private int? memoizedSize = null;
-
- #region Unimplemented members of IMessage
-
- public abstract MessageDescriptor DescriptorForType { get; }
- public abstract IDictionary<FieldDescriptor, object> AllFields { get; }
- public abstract bool HasField(FieldDescriptor field);
- public abstract bool HasOneof(OneofDescriptor oneof);
- public abstract FieldDescriptor OneofFieldDescriptor(OneofDescriptor oneof);
- public abstract object this[FieldDescriptor field] { get; }
- public abstract int GetRepeatedFieldCount(FieldDescriptor field);
- public abstract object this[FieldDescriptor field, int index] { get; }
- public abstract UnknownFieldSet UnknownFields { get; }
-
- #endregion
-
- /// <summary>
- /// Returns true iff all required fields in the message and all embedded
- /// messages are set.
- /// </summary>
- public override bool IsInitialized
- {
- get
- {
- // Check that all required fields are present.
- foreach (FieldDescriptor field in DescriptorForType.Fields)
- {
- if (field.IsRequired && !HasField(field))
- {
- return false;
- }
- }
-
- // Check that embedded messages are initialized.
- foreach (KeyValuePair<FieldDescriptor, object> entry in AllFields)
- {
- FieldDescriptor field = entry.Key;
- if (field.MappedType == MappedType.Message)
- {
- if (field.IsRepeated)
- {
- // We know it's an IList<T>, but not the exact type - so
- // IEnumerable is the best we can do. (C# generics aren't covariant yet.)
- foreach (IMessageLite element in (IEnumerable) entry.Value)
- {
- if (!element.IsInitialized)
- {
- return false;
- }
- }
- }
- else
- {
- if (!((IMessageLite) entry.Value).IsInitialized)
- {
- return false;
- }
- }
- }
- }
- return true;
- }
- }
-
- public override sealed string ToString()
- {
- return TextFormat.PrintToString(this);
- }
-
- public override sealed void PrintTo(TextWriter writer)
- {
- TextFormat.Print(this, writer);
- }
-
- /// <summary>
- /// Serializes the message and writes it to the given output stream.
- /// This does not flush or close the stream.
- /// </summary>
- /// <remarks>
- /// Protocol Buffers are not self-delimiting. Therefore, if you write
- /// any more data to the stream after the message, you must somehow ensure
- /// that the parser on the receiving end does not interpret this as being
- /// part of the protocol message. One way of doing this is by writing the size
- /// of the message before the data, then making sure you limit the input to
- /// that size when receiving the data. Alternatively, use WriteDelimitedTo(Stream).
- /// </remarks>
- public override void WriteTo(ICodedOutputStream output)
- {
- foreach (KeyValuePair<FieldDescriptor, object> entry in AllFields)
- {
- FieldDescriptor field = entry.Key;
- if (field.IsRepeated)
- {
- // We know it's an IList<T>, but not the exact type - so
- // IEnumerable is the best we can do. (C# generics aren't covariant yet.)
- IEnumerable valueList = (IEnumerable) entry.Value;
- if (field.IsPacked)
- {
- output.WritePackedArray(field.FieldType, field.FieldNumber, field.Name, valueList);
- }
- else
- {
- output.WriteArray(field.FieldType, field.FieldNumber, field.Name, valueList);
- }
- }
- else
- {
- output.WriteField(field.FieldType, field.FieldNumber, field.Name, entry.Value);
- }
- }
-
- UnknownFieldSet unknownFields = UnknownFields;
- if (DescriptorForType.Options.MessageSetWireFormat)
- {
- unknownFields.WriteAsMessageSetTo(output);
- }
- else
- {
- unknownFields.WriteTo(output);
- }
- }
-
- /// <summary>
- /// Returns the number of bytes required to encode this message.
- /// The result is only computed on the first call and memoized after that.
- /// </summary>
- public override int SerializedSize
- {
- get
- {
- if (memoizedSize != null)
- {
- return memoizedSize.Value;
- }
-
- int size = 0;
- foreach (KeyValuePair<FieldDescriptor, object> entry in AllFields)
- {
- FieldDescriptor field = entry.Key;
- if (field.IsRepeated)
- {
- IEnumerable valueList = (IEnumerable) entry.Value;
- if (field.IsPacked)
- {
- int dataSize = 0;
- foreach (object element in valueList)
- {
- dataSize += CodedOutputStream.ComputeFieldSizeNoTag(field.FieldType, element);
- }
- size += dataSize;
- size += CodedOutputStream.ComputeTagSize(field.FieldNumber);
- size += CodedOutputStream.ComputeRawVarint32Size((uint) dataSize);
- }
- else
- {
- foreach (object element in valueList)
- {
- size += CodedOutputStream.ComputeFieldSize(field.FieldType, field.FieldNumber, element);
- }
- }
- }
- else
- {
- size += CodedOutputStream.ComputeFieldSize(field.FieldType, field.FieldNumber, entry.Value);
- }
- }
-
- UnknownFieldSet unknownFields = UnknownFields;
- if (DescriptorForType.Options.MessageSetWireFormat)
- {
- size += unknownFields.SerializedSizeAsMessageSet;
- }
- else
- {
- size += unknownFields.SerializedSize;
- }
-
- memoizedSize = size;
- return size;
- }
- }
-
- /// <summary>
- /// Compares the specified object with this message for equality.
- /// Returns true iff the given object is a message of the same type
- /// (as defined by DescriptorForType) and has identical values
- /// for all its fields.
- /// </summary>
- public override bool Equals(object other)
- {
- if (other == this)
- {
- return true;
- }
- IMessage otherMessage = other as IMessage;
- if (otherMessage == null || otherMessage.DescriptorForType != DescriptorForType)
- {
- return false;
- }
- return Dictionaries.Equals(AllFields, otherMessage.AllFields) &&
- UnknownFields.Equals(otherMessage.UnknownFields);
- }
-
- /// <summary>
- /// Returns the hash code value for this message.
- /// TODO(jonskeet): Specify the hash algorithm, but better than the Java one!
- /// </summary>
- public override int GetHashCode()
- {
- int hash = 41;
- hash = (19*hash) + DescriptorForType.GetHashCode();
- hash = (53*hash) + Dictionaries.GetHashCode(AllFields);
- hash = (29*hash) + UnknownFields.GetHashCode();
- return hash;
- }
-
- #region Explicit Members
-
- IBuilder IMessage.WeakCreateBuilderForType()
- {
- return CreateBuilderForType();
- }
-
- IBuilder IMessage.WeakToBuilder()
- {
- return ToBuilder();
- }
-
- IMessage IMessage.WeakDefaultInstanceForType
- {
- get { return DefaultInstanceForType; }
- }
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/AbstractMessageLite.cs b/csharp/src/ProtocolBuffers/AbstractMessageLite.cs deleted file mode 100644 index 1cdead2e..00000000 --- a/csharp/src/ProtocolBuffers/AbstractMessageLite.cs +++ /dev/null @@ -1,140 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System.IO;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Implementation of the non-generic IMessage interface as far as possible.
- /// </summary>
- public abstract partial class AbstractMessageLite<TMessage, TBuilder> : IMessageLite<TMessage, TBuilder>
- where TMessage : AbstractMessageLite<TMessage, TBuilder>
- where TBuilder : AbstractBuilderLite<TMessage, TBuilder>
- {
- public abstract TBuilder CreateBuilderForType();
-
- public abstract TBuilder ToBuilder();
-
- public abstract TMessage DefaultInstanceForType { get; }
-
- public abstract bool IsInitialized { get; }
-
- public abstract void WriteTo(ICodedOutputStream output);
-
- public abstract int SerializedSize { get; }
-
- //public override bool Equals(object other) {
- //}
-
- //public override int GetHashCode() {
- //}
-
- public abstract void PrintTo(TextWriter writer);
-
- #region IMessageLite<TMessage,TBuilder> Members
-
- /// <summary>
- /// Serializes the message to a ByteString. This is a trivial wrapper
- /// around WriteTo(ICodedOutputStream).
- /// </summary>
- public ByteString ToByteString()
- {
- ByteString.CodedBuilder output = new ByteString.CodedBuilder(SerializedSize);
- WriteTo(output.CodedOutput);
- return output.Build();
- }
-
- /// <summary>
- /// Serializes the message to a byte array. This is a trivial wrapper
- /// around WriteTo(ICodedOutputStream).
- /// </summary>
- public byte[] ToByteArray()
- {
- byte[] result = new byte[SerializedSize];
- CodedOutputStream output = CodedOutputStream.CreateInstance(result);
- WriteTo(output);
- output.CheckNoSpaceLeft();
- return result;
- }
-
- /// <summary>
- /// Serializes the message and writes it to the given stream.
- /// This is just a wrapper around WriteTo(CodedOutputStream). This
- /// does not flush or close the stream.
- /// </summary>
- /// <param name="output"></param>
- public void WriteTo(Stream output)
- {
- CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output);
- WriteTo(codedOutput);
- codedOutput.Flush();
- }
-
- /// <summary>
- /// Like WriteTo(Stream) but writes the size of the message as a varint before
- /// writing the data. This allows more data to be written to the stream after the
- /// message without the need to delimit the message data yourself. Use
- /// IBuilder.MergeDelimitedFrom(Stream) or the static method
- /// YourMessageType.ParseDelimitedFrom(Stream) to parse messages written by this method.
- /// </summary>
- /// <param name="output"></param>
- public void WriteDelimitedTo(Stream output)
- {
- CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output);
- codedOutput.WriteRawVarint32((uint) SerializedSize);
- WriteTo(codedOutput);
- codedOutput.Flush();
- }
-
- IBuilderLite IMessageLite.WeakCreateBuilderForType()
- {
- return CreateBuilderForType();
- }
-
- IBuilderLite IMessageLite.WeakToBuilder()
- {
- return ToBuilder();
- }
-
- IMessageLite IMessageLite.WeakDefaultInstanceForType
- {
- get { return DefaultInstanceForType; }
- }
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ByteArray.cs b/csharp/src/ProtocolBuffers/ByteArray.cs index 3c51b7b0..211a0e11 100644 --- a/csharp/src/ProtocolBuffers/ByteArray.cs +++ b/csharp/src/ProtocolBuffers/ByteArray.cs @@ -36,7 +36,7 @@ using System;
-namespace Google.ProtocolBuffers
+namespace Google.Protobuf
{
/// <summary>
/// Provides a utility routine to copy small arrays much more quickly than Buffer.BlockCopy
@@ -51,7 +51,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Determines which copy routine to use based on the number of bytes to be copied.
/// </summary>
- public static void Copy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count)
+ internal static void Copy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count)
{
if (count > CopyThreshold)
{
@@ -66,7 +66,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Copy the bytes provided with a for loop, faster when there are only a few bytes to copy
/// </summary>
- public static void ByteCopy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count)
+ internal static void ByteCopy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count)
{
int stop = srcOffset + count;
for (int i = srcOffset; i < stop; i++)
@@ -78,12 +78,11 @@ namespace Google.ProtocolBuffers /// <summary>
/// Reverses the order of bytes in the array
/// </summary>
- public static void Reverse(byte[] bytes)
+ internal static void Reverse(byte[] bytes)
{
- byte temp;
for (int first = 0, last = bytes.Length - 1; first < last; first++, last--)
{
- temp = bytes[first];
+ byte temp = bytes[first];
bytes[first] = bytes[last];
bytes[last] = temp;
}
diff --git a/csharp/src/ProtocolBuffers/ByteString.cs b/csharp/src/ProtocolBuffers/ByteString.cs index 434865b7..000914f0 100644 --- a/csharp/src/ProtocolBuffers/ByteString.cs +++ b/csharp/src/ProtocolBuffers/ByteString.cs @@ -40,7 +40,7 @@ using System.Collections.Generic; using System.IO;
using System.Text;
-namespace Google.ProtocolBuffers
+namespace Google.Protobuf
{
/// <summary>
/// Immutable array of bytes.
@@ -208,6 +208,24 @@ namespace Google.ProtocolBuffers return CodedInputStream.CreateInstance(bytes);
}
+ public static bool operator ==(ByteString lhs, ByteString rhs)
+ {
+ if (ReferenceEquals(lhs, rhs))
+ {
+ return true;
+ }
+ if (ReferenceEquals(lhs, null))
+ {
+ return false;
+ }
+ return lhs.Equals(rhs);
+ }
+
+ public static bool operator !=(ByteString lhs, ByteString rhs)
+ {
+ return !(lhs == rhs);
+ }
+
// TODO(jonskeet): CopyTo if it turns out to be required
public override bool Equals(object obj)
diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs index 37774d01..905cdb9d 100644 --- a/csharp/src/ProtocolBuffers/CodedInputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs @@ -37,10 +37,9 @@ using System;
using System.Collections.Generic;
using System.IO;
-using System.Text;
-using Google.ProtocolBuffers.Descriptors;
+using Google.Protobuf.Collections;
-namespace Google.ProtocolBuffers
+namespace Google.Protobuf
{
/// <summary>
/// Readings and decodes protocol message fields.
@@ -58,7 +57,7 @@ namespace Google.ProtocolBuffers /// TODO(jonskeet): Consider whether recursion and size limits shouldn't be readonly,
/// set at construction time.
/// </remarks>
- public sealed class CodedInputStream : ICodedInputStream
+ public sealed class CodedInputStream
{
private readonly byte[] buffer;
private int bufferSize;
@@ -173,10 +172,6 @@ namespace Google.ProtocolBuffers }
}
-
- void ICodedInputStream.ReadMessageStart() { }
- void ICodedInputStream.ReadMessageEnd() { }
-
#region Validation
/// <summary>
@@ -186,7 +181,7 @@ namespace Google.ProtocolBuffers /// </summary>
/// <exception cref="InvalidProtocolBufferException">The last
/// tag read was not the one specified</exception>
- public void CheckLastTagWas(uint value)
+ internal void CheckLastTagWas(uint value)
{
if (lastTag != value)
{
@@ -201,17 +196,16 @@ namespace Google.ProtocolBuffers /// <summary>
/// Attempt to peek at the next field tag.
/// </summary>
- public bool PeekNextTag(out uint fieldTag, out string fieldName)
+ public bool PeekNextTag(out uint fieldTag)
{
if (hasNextTag)
{
- fieldName = null;
fieldTag = nextTag;
return true;
}
uint savedLast = lastTag;
- hasNextTag = ReadTag(out nextTag, out fieldName);
+ hasNextTag = ReadTag(out nextTag);
lastTag = savedLast;
fieldTag = nextTag;
return hasNextTag;
@@ -222,12 +216,9 @@ namespace Google.ProtocolBuffers /// of the input data.
/// </summary>
/// <param name="fieldTag">The 'tag' of the field (id * 8 + wire-format)</param>
- /// <param name="fieldName">Not Supported - For protobuffer streams, this parameter is always null</param>
/// <returns>true if the next fieldTag was read</returns>
- public bool ReadTag(out uint fieldTag, out string fieldName)
+ public bool ReadTag(out uint fieldTag)
{
- fieldName = null;
-
if (hasNextTag)
{
fieldTag = nextTag;
@@ -256,21 +247,21 @@ namespace Google.ProtocolBuffers /// <summary>
/// Read a double field from the stream.
/// </summary>
- public bool ReadDouble(ref double value)
+ public double ReadDouble()
{
- value = FrameworkPortability.Int64ToDouble((long) ReadRawLittleEndian64());
- return true;
+ return BitConverter.Int64BitsToDouble((long) ReadRawLittleEndian64());
}
/// <summary>
/// Read a float field from the stream.
/// </summary>
- public bool ReadFloat(ref float value)
+ public float ReadFloat()
{
if (BitConverter.IsLittleEndian && 4 <= bufferSize - bufferPos)
{
- value = BitConverter.ToSingle(buffer, bufferPos);
+ float ret = BitConverter.ToSingle(buffer, bufferPos);
bufferPos += 4;
+ return ret;
}
else
{
@@ -279,128 +270,85 @@ namespace Google.ProtocolBuffers {
ByteArray.Reverse(rawBytes);
}
- value = BitConverter.ToSingle(rawBytes, 0);
+ return BitConverter.ToSingle(rawBytes, 0);
}
- return true;
}
/// <summary>
/// Read a uint64 field from the stream.
/// </summary>
- public bool ReadUInt64(ref ulong value)
+ public ulong ReadUInt64()
{
- value = ReadRawVarint64();
- return true;
+ return ReadRawVarint64();
}
/// <summary>
/// Read an int64 field from the stream.
/// </summary>
- public bool ReadInt64(ref long value)
+ public long ReadInt64()
{
- value = (long) ReadRawVarint64();
- return true;
+ return (long) ReadRawVarint64();
}
/// <summary>
/// Read an int32 field from the stream.
/// </summary>
- public bool ReadInt32(ref int value)
+ public int ReadInt32()
{
- value = (int) ReadRawVarint32();
- return true;
+ return (int) ReadRawVarint32();
}
/// <summary>
/// Read a fixed64 field from the stream.
/// </summary>
- public bool ReadFixed64(ref ulong value)
+ public ulong ReadFixed64()
{
- value = ReadRawLittleEndian64();
- return true;
+ return ReadRawLittleEndian64();
}
/// <summary>
/// Read a fixed32 field from the stream.
/// </summary>
- public bool ReadFixed32(ref uint value)
+ public uint ReadFixed32()
{
- value = ReadRawLittleEndian32();
- return true;
+ return ReadRawLittleEndian32();
}
/// <summary>
/// Read a bool field from the stream.
/// </summary>
- public bool ReadBool(ref bool value)
+ public bool ReadBool()
{
- value = ReadRawVarint32() != 0;
- return true;
+ return ReadRawVarint32() != 0;
}
/// <summary>
/// Reads a string field from the stream.
/// </summary>
- public bool ReadString(ref string value)
+ public string ReadString()
{
int size = (int) ReadRawVarint32();
// No need to read any data for an empty string.
if (size == 0)
{
- value = "";
- return true;
+ return "";
}
if (size <= bufferSize - bufferPos)
{
// Fast path: We already have the bytes in a contiguous buffer, so
// just copy directly from it.
- String result = Encoding.UTF8.GetString(buffer, bufferPos, size);
+ String result = CodedOutputStream.Utf8Encoding.GetString(buffer, bufferPos, size);
bufferPos += size;
- value = result;
- return true;
+ return result;
}
// Slow path: Build a byte array first then copy it.
- value = Encoding.UTF8.GetString(ReadRawBytes(size), 0, size);
- return true;
- }
-
- /// <summary>
- /// Reads a group field value from the stream.
- /// </summary>
- public void ReadGroup(int fieldNumber, IBuilderLite builder,
- ExtensionRegistry extensionRegistry)
- {
- if (recursionDepth >= recursionLimit)
- {
- throw InvalidProtocolBufferException.RecursionLimitExceeded();
- }
- ++recursionDepth;
- builder.WeakMergeFrom(this, extensionRegistry);
- CheckLastTagWas(WireFormat.MakeTag(fieldNumber, WireFormat.WireType.EndGroup));
- --recursionDepth;
- }
-
- /// <summary>
- /// Reads a group field value from the stream and merges it into the given
- /// UnknownFieldSet.
- /// </summary>
- [Obsolete]
- public void ReadUnknownGroup(int fieldNumber, IBuilderLite builder)
- {
- if (recursionDepth >= recursionLimit)
- {
- throw InvalidProtocolBufferException.RecursionLimitExceeded();
- }
- ++recursionDepth;
- builder.WeakMergeFrom(this);
- CheckLastTagWas(WireFormat.MakeTag(fieldNumber, WireFormat.WireType.EndGroup));
- --recursionDepth;
+ return CodedOutputStream.Utf8Encoding.GetString(ReadRawBytes(size), 0, size);
}
/// <summary>
/// Reads an embedded message field value from the stream.
/// </summary>
- public void ReadMessage(IBuilderLite builder, ExtensionRegistry extensionRegistry)
+ public void ReadMessage(IMessage builder)
{
int length = (int) ReadRawVarint32();
if (recursionDepth >= recursionLimit)
@@ -409,7 +357,7 @@ namespace Google.ProtocolBuffers }
int oldLimit = PushLimit(length);
++recursionDepth;
- builder.WeakMergeFrom(this, extensionRegistry);
+ builder.MergeFrom(this);
CheckLastTagWas(0);
--recursionDepth;
PopLimit(oldLimit);
@@ -418,7 +366,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Reads a bytes field value from the stream.
/// </summary>
- public bool ReadBytes(ref ByteString value)
+ public ByteString ReadBytes()
{
int size = (int) ReadRawVarint32();
if (size <= bufferSize - bufferPos && size > 0)
@@ -427,42 +375,21 @@ namespace Google.ProtocolBuffers // just copy directly from it.
ByteString result = ByteString.CopyFrom(buffer, bufferPos, size);
bufferPos += size;
- value = result;
- return true;
+ return result;
}
else
{
// Slow path: Build a byte array and attach it to a new ByteString.
- value = ByteString.AttachBytes(ReadRawBytes(size));
- return true;
+ return ByteString.AttachBytes(ReadRawBytes(size));
}
}
/// <summary>
/// Reads a uint32 field value from the stream.
/// </summary>
- public bool ReadUInt32(ref uint value)
- {
- value = ReadRawVarint32();
- return true;
- }
-
- /// <summary>
- /// Reads an enum field value from the stream. The caller is responsible
- /// for converting the numeric value to an actual enum.
- /// </summary>
- public bool ReadEnum(ref IEnumLite value, out object unknown, IEnumLiteMap mapping)
+ public uint ReadUInt32()
{
- int rawValue = (int) ReadRawVarint32();
-
- value = mapping.FindValueByNumber(rawValue);
- if (value != null)
- {
- unknown = null;
- return true;
- }
- unknown = rawValue;
- return false;
+ return ReadRawVarint32();
}
/// <summary>
@@ -470,53 +397,42 @@ namespace Google.ProtocolBuffers /// then the ref value is set and it returns true. Otherwise the unknown output
/// value is set and this method returns false.
/// </summary>
- public bool ReadEnum<T>(ref T value, out object unknown)
- where T : struct, IComparable, IFormattable
+ public int ReadEnum()
{
- int number = (int) ReadRawVarint32();
- if (EnumParser<T>.TryConvert(number, ref value))
- {
- unknown = null;
- return true;
- }
- unknown = number;
- return false;
+ // Currently just a pass-through, but it's nice to separate it logically from WriteInt32.
+ return (int) ReadRawVarint32();
}
/// <summary>
/// Reads an sfixed32 field value from the stream.
/// </summary>
- public bool ReadSFixed32(ref int value)
+ public int ReadSFixed32()
{
- value = (int) ReadRawLittleEndian32();
- return true;
+ return (int) ReadRawLittleEndian32();
}
/// <summary>
/// Reads an sfixed64 field value from the stream.
/// </summary>
- public bool ReadSFixed64(ref long value)
+ public long ReadSFixed64()
{
- value = (long) ReadRawLittleEndian64();
- return true;
+ return (long) ReadRawLittleEndian64();
}
/// <summary>
/// Reads an sint32 field value from the stream.
/// </summary>
- public bool ReadSInt32(ref int value)
+ public int ReadSInt32()
{
- value = DecodeZigZag32(ReadRawVarint32());
- return true;
+ return DecodeZigZag32(ReadRawVarint32());
}
/// <summary>
/// Reads an sint64 field value from the stream.
/// </summary>
- public bool ReadSInt64(ref long value)
+ public long ReadSInt64()
{
- value = DecodeZigZag64(ReadRawVarint64());
- return true;
+ return DecodeZigZag64(ReadRawVarint64());
}
private bool BeginArray(uint fieldTag, out bool isPacked, out int oldLimit)
@@ -544,9 +460,8 @@ namespace Google.ProtocolBuffers /// </summary>
private bool ContinueArray(uint currentTag)
{
- string ignore;
uint next;
- if (PeekNextTag(out next, out ignore))
+ if (PeekNextTag(out next))
{
if (next == currentTag)
{
@@ -572,9 +487,8 @@ namespace Google.ProtocolBuffers return true;
}
- string ignore;
uint next;
- if (PeekNextTag(out next, out ignore))
+ if (PeekNextTag(out next))
{
if (next == currentTag)
{
@@ -585,311 +499,217 @@ namespace Google.ProtocolBuffers return false;
}
- public void ReadPrimitiveArray(FieldType fieldType, uint fieldTag, string fieldName, ICollection<object> list)
- {
- WireFormat.WireType normal = WireFormat.GetWireType(fieldType);
- WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag);
-
- // 2.3 allows packed form even if the field is not declared packed.
- if (normal != wformat && wformat == WireFormat.WireType.LengthDelimited)
- {
- int length = (int) (ReadRawVarint32() & int.MaxValue);
- int limit = PushLimit(length);
- while (!ReachedLimit)
- {
- Object value = null;
- if (ReadPrimitiveField(fieldType, ref value))
- {
- list.Add(value);
- }
- }
- PopLimit(limit);
- }
- else
- {
- Object value = null;
- do
- {
- if (ReadPrimitiveField(fieldType, ref value))
- {
- list.Add(value);
- }
- } while (ContinueArray(fieldTag));
- }
- }
-
- public void ReadStringArray(uint fieldTag, string fieldName, ICollection<string> list)
+ /// <summary>
+ /// Reads a string array.
+ /// </summary>
+ /// <remarks>The stream is assumed to be positioned after a tag indicating the field
+ /// repeated string value. A string is read, and then if the next tag is the same,
+ /// the process is repeated, until the next tag is a different one.</remarks>
+ /// <param name="list"></param>
+ public void ReadStringArray(ICollection<string> list)
{
- string tmp = null;
+ uint fieldTag = lastTag;
do
{
- ReadString(ref tmp);
- list.Add(tmp);
+ list.Add(ReadString());
} while (ContinueArray(fieldTag));
}
- public void ReadBytesArray(uint fieldTag, string fieldName, ICollection<ByteString> list)
+ public void ReadBytesArray(ICollection<ByteString> list)
{
- ByteString tmp = null;
+ uint fieldTag = lastTag;
do
{
- ReadBytes(ref tmp);
- list.Add(tmp);
+ list.Add(ReadBytes());
} while (ContinueArray(fieldTag));
}
- public void ReadBoolArray(uint fieldTag, string fieldName, ICollection<bool> list)
+ public void ReadBoolArray(ICollection<bool> list)
{
+ uint fieldTag = lastTag;
bool isPacked;
int holdLimit;
if (BeginArray(fieldTag, out isPacked, out holdLimit))
{
- bool tmp = false;
do
{
- ReadBool(ref tmp);
- list.Add(tmp);
+ list.Add(ReadBool());
} while (ContinueArray(fieldTag, isPacked, holdLimit));
}
}
- public void ReadInt32Array(uint fieldTag, string fieldName, ICollection<int> list)
+ public void ReadInt32Array(ICollection<int> list)
{
+ uint fieldTag = lastTag;
bool isPacked;
int holdLimit;
if (BeginArray(fieldTag, out isPacked, out holdLimit))
{
- int tmp = 0;
do
{
- ReadInt32(ref tmp);
- list.Add(tmp);
+ list.Add(ReadInt32());
} while (ContinueArray(fieldTag, isPacked, holdLimit));
}
}
- public void ReadSInt32Array(uint fieldTag, string fieldName, ICollection<int> list)
+ public void ReadSInt32Array(ICollection<int> list)
{
+ uint fieldTag = lastTag;
bool isPacked;
int holdLimit;
if (BeginArray(fieldTag, out isPacked, out holdLimit))
{
- int tmp = 0;
do
{
- ReadSInt32(ref tmp);
- list.Add(tmp);
+ list.Add(ReadSInt32());
} while (ContinueArray(fieldTag, isPacked, holdLimit));
}
}
- public void ReadUInt32Array(uint fieldTag, string fieldName, ICollection<uint> list)
+ public void ReadUInt32Array(ICollection<uint> list)
{
+ uint fieldTag = lastTag;
bool isPacked;
int holdLimit;
if (BeginArray(fieldTag, out isPacked, out holdLimit))
{
- uint tmp = 0;
do
{
- ReadUInt32(ref tmp);
- list.Add(tmp);
+ list.Add(ReadUInt32());
} while (ContinueArray(fieldTag, isPacked, holdLimit));
}
}
- public void ReadFixed32Array(uint fieldTag, string fieldName, ICollection<uint> list)
+ public void ReadFixed32Array(ICollection<uint> list)
{
+ uint fieldTag = lastTag;
bool isPacked;
int holdLimit;
if (BeginArray(fieldTag, out isPacked, out holdLimit))
{
- uint tmp = 0;
do
{
- ReadFixed32(ref tmp);
- list.Add(tmp);
+ list.Add(ReadFixed32());
} while (ContinueArray(fieldTag, isPacked, holdLimit));
}
}
- public void ReadSFixed32Array(uint fieldTag, string fieldName, ICollection<int> list)
+ public void ReadSFixed32Array(ICollection<int> list)
{
+ uint fieldTag = lastTag;
bool isPacked;
int holdLimit;
if (BeginArray(fieldTag, out isPacked, out holdLimit))
{
- int tmp = 0;
do
{
- ReadSFixed32(ref tmp);
- list.Add(tmp);
+ list.Add(ReadSFixed32());
} while (ContinueArray(fieldTag, isPacked, holdLimit));
}
}
- public void ReadInt64Array(uint fieldTag, string fieldName, ICollection<long> list)
+ public void ReadInt64Array(ICollection<long> list)
{
+ uint fieldTag = lastTag;
bool isPacked;
int holdLimit;
if (BeginArray(fieldTag, out isPacked, out holdLimit))
{
- long tmp = 0;
do
{
- ReadInt64(ref tmp);
- list.Add(tmp);
+ list.Add(ReadInt64());
} while (ContinueArray(fieldTag, isPacked, holdLimit));
}
}
- public void ReadSInt64Array(uint fieldTag, string fieldName, ICollection<long> list)
+ public void ReadSInt64Array(ICollection<long> list)
{
+ uint fieldTag = lastTag;
bool isPacked;
int holdLimit;
if (BeginArray(fieldTag, out isPacked, out holdLimit))
{
- long tmp = 0;
do
{
- ReadSInt64(ref tmp);
- list.Add(tmp);
+ list.Add(ReadSInt64());
} while (ContinueArray(fieldTag, isPacked, holdLimit));
}
}
- public void ReadUInt64Array(uint fieldTag, string fieldName, ICollection<ulong> list)
+ public void ReadUInt64Array(ICollection<ulong> list)
{
+ uint fieldTag = lastTag;
bool isPacked;
int holdLimit;
if (BeginArray(fieldTag, out isPacked, out holdLimit))
{
- ulong tmp = 0;
do
{
- ReadUInt64(ref tmp);
- list.Add(tmp);
+ list.Add(ReadUInt64());
} while (ContinueArray(fieldTag, isPacked, holdLimit));
}
}
- public void ReadFixed64Array(uint fieldTag, string fieldName, ICollection<ulong> list)
+ public void ReadFixed64Array(ICollection<ulong> list)
{
+ uint fieldTag = lastTag;
bool isPacked;
int holdLimit;
if (BeginArray(fieldTag, out isPacked, out holdLimit))
{
- ulong tmp = 0;
do
{
- ReadFixed64(ref tmp);
- list.Add(tmp);
+ list.Add(ReadFixed64());
} while (ContinueArray(fieldTag, isPacked, holdLimit));
}
}
- public void ReadSFixed64Array(uint fieldTag, string fieldName, ICollection<long> list)
+ public void ReadSFixed64Array(ICollection<long> list)
{
+ uint fieldTag = lastTag;
bool isPacked;
int holdLimit;
if (BeginArray(fieldTag, out isPacked, out holdLimit))
{
- long tmp = 0;
do
{
- ReadSFixed64(ref tmp);
- list.Add(tmp);
+ list.Add(ReadSFixed64());
} while (ContinueArray(fieldTag, isPacked, holdLimit));
}
}
- public void ReadDoubleArray(uint fieldTag, string fieldName, ICollection<double> list)
+ public void ReadDoubleArray(ICollection<double> list)
{
+ uint fieldTag = lastTag;
bool isPacked;
int holdLimit;
if (BeginArray(fieldTag, out isPacked, out holdLimit))
{
- double tmp = 0;
do
{
- ReadDouble(ref tmp);
- list.Add(tmp);
+ list.Add(ReadDouble());
} while (ContinueArray(fieldTag, isPacked, holdLimit));
}
}
- public void ReadFloatArray(uint fieldTag, string fieldName, ICollection<float> list)
+ public void ReadFloatArray(ICollection<float> list)
{
+ uint fieldTag = lastTag;
bool isPacked;
int holdLimit;
if (BeginArray(fieldTag, out isPacked, out holdLimit))
{
- float tmp = 0;
do
{
- ReadFloat(ref tmp);
- list.Add(tmp);
+ list.Add(ReadFloat());
} while (ContinueArray(fieldTag, isPacked, holdLimit));
}
}
- public void ReadEnumArray(uint fieldTag, string fieldName, ICollection<IEnumLite> list,
- out ICollection<object> unknown, IEnumLiteMap mapping)
- {
- unknown = null;
- object unkval;
- IEnumLite value = null;
- WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag);
-
- // 2.3 allows packed form even if the field is not declared packed.
- if (wformat == WireFormat.WireType.LengthDelimited)
- {
- int length = (int) (ReadRawVarint32() & int.MaxValue);
- int limit = PushLimit(length);
- while (!ReachedLimit)
- {
- if (ReadEnum(ref value, out unkval, mapping))
- {
- list.Add(value);
- }
- else
- {
- if (unknown == null)
- {
- unknown = new List<object>();
- }
- unknown.Add(unkval);
- }
- }
- PopLimit(limit);
- }
- else
- {
- do
- {
- if (ReadEnum(ref value, out unkval, mapping))
- {
- list.Add(value);
- }
- else
- {
- if (unknown == null)
- {
- unknown = new List<object>();
- }
- unknown.Add(unkval);
- }
- } while (ContinueArray(fieldTag));
- }
- }
-
- public void ReadEnumArray<T>(uint fieldTag, string fieldName, ICollection<T> list,
- out ICollection<object> unknown)
+ public void ReadEnumArray<T>(RepeatedField<T> list)
where T : struct, IComparable, IFormattable
{
- unknown = null;
- object unkval;
- T value = default(T);
+ uint fieldTag = lastTag;
WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag);
// 2.3 allows packed form even if the field is not declared packed.
@@ -899,18 +719,8 @@ namespace Google.ProtocolBuffers int limit = PushLimit(length);
while (!ReachedLimit)
{
- if (ReadEnum<T>(ref value, out unkval))
- {
- list.Add(value);
- }
- else
- {
- if (unknown == null)
- {
- unknown = new List<object>();
- }
- unknown.Add(unkval);
- }
+ // Ghastly hack, but it works...
+ list.AddInt32(ReadEnum());
}
PopLimit(limit);
}
@@ -918,215 +728,22 @@ namespace Google.ProtocolBuffers {
do
{
- if (ReadEnum(ref value, out unkval))
- {
- list.Add(value);
- }
- else
- {
- if (unknown == null)
- {
- unknown = new List<object>();
- }
- unknown.Add(unkval);
- }
+ list.Add((T)(object) ReadEnum());
} while (ContinueArray(fieldTag));
}
}
- public void ReadMessageArray<T>(uint fieldTag, string fieldName, ICollection<T> list, T messageType,
- ExtensionRegistry registry) where T : IMessageLite
+ public void ReadMessageArray<T>(ICollection<T> list, MessageParser<T> messageParser)
+ where T : IMessage<T>
{
+ uint fieldTag = lastTag;
do
{
- IBuilderLite builder = messageType.WeakCreateBuilderForType();
- ReadMessage(builder, registry);
- list.Add((T) builder.WeakBuildPartial());
+ T message = messageParser.CreateTemplate();
+ ReadMessage(message);
+ list.Add(message);
} while (ContinueArray(fieldTag));
}
-
- public void ReadGroupArray<T>(uint fieldTag, string fieldName, ICollection<T> list, T messageType,
- ExtensionRegistry registry) where T : IMessageLite
- {
- do
- {
- IBuilderLite builder = messageType.WeakCreateBuilderForType();
- ReadGroup(WireFormat.GetTagFieldNumber(fieldTag), builder, registry);
- list.Add((T) builder.WeakBuildPartial());
- } while (ContinueArray(fieldTag));
- }
-
- /// <summary>
- /// Reads a field of any primitive type. Enums, groups and embedded
- /// messages are not handled by this method.
- /// </summary>
- public bool ReadPrimitiveField(FieldType fieldType, ref object value)
- {
- switch (fieldType)
- {
- case FieldType.Double:
- {
- double tmp = 0;
- if (ReadDouble(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.Float:
- {
- float tmp = 0;
- if (ReadFloat(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.Int64:
- {
- long tmp = 0;
- if (ReadInt64(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.UInt64:
- {
- ulong tmp = 0;
- if (ReadUInt64(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.Int32:
- {
- int tmp = 0;
- if (ReadInt32(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.Fixed64:
- {
- ulong tmp = 0;
- if (ReadFixed64(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.Fixed32:
- {
- uint tmp = 0;
- if (ReadFixed32(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.Bool:
- {
- bool tmp = false;
- if (ReadBool(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.String:
- {
- string tmp = null;
- if (ReadString(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.Bytes:
- {
- ByteString tmp = null;
- if (ReadBytes(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.UInt32:
- {
- uint tmp = 0;
- if (ReadUInt32(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.SFixed32:
- {
- int tmp = 0;
- if (ReadSFixed32(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.SFixed64:
- {
- long tmp = 0;
- if (ReadSFixed64(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.SInt32:
- {
- int tmp = 0;
- if (ReadSInt32(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.SInt64:
- {
- long tmp = 0;
- if (ReadSInt64(ref tmp))
- {
- value = tmp;
- return true;
- }
- return false;
- }
- case FieldType.Group:
- throw new ArgumentException("ReadPrimitiveField() cannot handle nested groups.");
- case FieldType.Message:
- throw new ArgumentException("ReadPrimitiveField() cannot handle embedded messages.");
- // We don't handle enums because we don't know what to do if the
- // value is not recognized.
- case FieldType.Enum:
- throw new ArgumentException("ReadPrimitiveField() cannot handle enums.");
- default:
- throw new ArgumentOutOfRangeException("Invalid field type " + fieldType);
- }
- }
-
#endregion
#region Underlying reading primitives
@@ -1734,8 +1351,7 @@ namespace Google.ProtocolBuffers public void SkipMessage()
{
uint tag;
- string name;
- while (ReadTag(out tag, out name))
+ while (ReadTag(out tag))
{
if (!SkipField())
{
@@ -1810,10 +1426,10 @@ namespace Google.ProtocolBuffers }
else
{
- byte[] skipBuffer = new byte[1024];
+ byte[] skipBuffer = new byte[Math.Min(1024, amountToSkip)];
while (amountToSkip > 0)
{
- int bytesRead = input.Read(skipBuffer, 0, skipBuffer.Length);
+ int bytesRead = input.Read(skipBuffer, 0, Math.Min(skipBuffer.Length, amountToSkip));
if (bytesRead <= 0)
{
throw InvalidProtocolBufferException.TruncatedMessage();
diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs index 99d82fce..ef1f4c0c 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs @@ -37,9 +37,9 @@ using System;
using System.Globalization;
using System.Text;
-using Google.ProtocolBuffers.Descriptors;
+using Google.Protobuf.Descriptors;
-namespace Google.ProtocolBuffers
+namespace Google.Protobuf
{
// This part of CodedOutputStream provides all the static entry points that are used
// by generated code and internally to compute the size of messages prior to being
@@ -47,201 +47,13 @@ namespace Google.ProtocolBuffers public sealed partial class CodedOutputStream
{
private const int LittleEndian64Size = 8;
- private const int LittleEndian32Size = 4;
+ private const int LittleEndian32Size = 4;
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// double field, including the tag.
/// </summary>
- public static int ComputeDoubleSize(int fieldNumber, double value)
- {
- return ComputeTagSize(fieldNumber) + LittleEndian64Size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// float field, including the tag.
- /// </summary>
- public static int ComputeFloatSize(int fieldNumber, float value)
- {
- return ComputeTagSize(fieldNumber) + LittleEndian32Size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// uint64 field, including the tag.
- /// </summary>
- public static int ComputeUInt64Size(int fieldNumber, ulong value)
- {
- return ComputeTagSize(fieldNumber) + ComputeRawVarint64Size(value);
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// int64 field, including the tag.
- /// </summary>
- public static int ComputeInt64Size(int fieldNumber, long value)
- {
- return ComputeTagSize(fieldNumber) + ComputeRawVarint64Size((ulong) value);
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// int32 field, including the tag.
- /// </summary>
- public static int ComputeInt32Size(int fieldNumber, int value)
- {
- if (value >= 0)
- {
- return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size((uint) value);
- }
- else
- {
- // Must sign-extend.
- return ComputeTagSize(fieldNumber) + 10;
- }
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// fixed64 field, including the tag.
- /// </summary>
- public static int ComputeFixed64Size(int fieldNumber, ulong value)
- {
- return ComputeTagSize(fieldNumber) + LittleEndian64Size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// fixed32 field, including the tag.
- /// </summary>
- public static int ComputeFixed32Size(int fieldNumber, uint value)
- {
- return ComputeTagSize(fieldNumber) + LittleEndian32Size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// bool field, including the tag.
- /// </summary>
- public static int ComputeBoolSize(int fieldNumber, bool value)
- {
- return ComputeTagSize(fieldNumber) + 1;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// string field, including the tag.
- /// </summary>
- public static int ComputeStringSize(int fieldNumber, String value)
- {
- int byteArraySize = Encoding.UTF8.GetByteCount(value);
- return ComputeTagSize(fieldNumber) +
- ComputeRawVarint32Size((uint) byteArraySize) +
- byteArraySize;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// group field, including the tag.
- /// </summary>
- public static int ComputeGroupSize(int fieldNumber, IMessageLite value)
- {
- return ComputeTagSize(fieldNumber)*2 + value.SerializedSize;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// group field represented by an UnknownFieldSet, including the tag.
- /// </summary>
- [Obsolete]
- public static int ComputeUnknownGroupSize(int fieldNumber,
- IMessageLite value)
- {
- return ComputeTagSize(fieldNumber)*2 + value.SerializedSize;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// embedded message field, including the tag.
- /// </summary>
- public static int ComputeMessageSize(int fieldNumber, IMessageLite value)
- {
- int size = value.SerializedSize;
- return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size((uint) size) + size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// bytes field, including the tag.
- /// </summary>
- public static int ComputeBytesSize(int fieldNumber, ByteString value)
- {
- return ComputeTagSize(fieldNumber) +
- ComputeRawVarint32Size((uint) value.Length) +
- value.Length;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// uint32 field, including the tag.
- /// </summary>
- public static int ComputeUInt32Size(int fieldNumber, uint value)
- {
- return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size(value);
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// enum field, including the tag. The caller is responsible for
- /// converting the enum value to its numeric value.
- /// </summary>
- public static int ComputeEnumSize(int fieldNumber, int value)
- {
- return ComputeTagSize(fieldNumber) + ComputeEnumSizeNoTag(value);
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// sfixed32 field, including the tag.
- /// </summary>
- public static int ComputeSFixed32Size(int fieldNumber, int value)
- {
- return ComputeTagSize(fieldNumber) + LittleEndian32Size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// sfixed64 field, including the tag.
- /// </summary>
- public static int ComputeSFixed64Size(int fieldNumber, long value)
- {
- return ComputeTagSize(fieldNumber) + LittleEndian64Size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// sint32 field, including the tag.
- /// </summary>
- public static int ComputeSInt32Size(int fieldNumber, int value)
- {
- return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size(EncodeZigZag32(value));
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// sint64 field, including the tag.
- /// </summary>
- public static int ComputeSInt64Size(int fieldNumber, long value)
- {
- return ComputeTagSize(fieldNumber) + ComputeRawVarint64Size(EncodeZigZag64(value));
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// double field, including the tag.
- /// </summary>
- public static int ComputeDoubleSizeNoTag(double value)
+ public static int ComputeDoubleSize(double value)
{
return LittleEndian64Size;
}
@@ -250,7 +62,7 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode a
/// float field, including the tag.
/// </summary>
- public static int ComputeFloatSizeNoTag(float value)
+ public static int ComputeFloatSize(float value)
{
return LittleEndian32Size;
}
@@ -259,7 +71,7 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode a
/// uint64 field, including the tag.
/// </summary>
- public static int ComputeUInt64SizeNoTag(ulong value)
+ public static int ComputeUInt64Size(ulong value)
{
return ComputeRawVarint64Size(value);
}
@@ -268,7 +80,7 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode an
/// int64 field, including the tag.
/// </summary>
- public static int ComputeInt64SizeNoTag(long value)
+ public static int ComputeInt64Size(long value)
{
return ComputeRawVarint64Size((ulong) value);
}
@@ -277,7 +89,7 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode an
/// int32 field, including the tag.
/// </summary>
- public static int ComputeInt32SizeNoTag(int value)
+ public static int ComputeInt32Size(int value)
{
if (value >= 0)
{
@@ -294,7 +106,7 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode a
/// fixed64 field, including the tag.
/// </summary>
- public static int ComputeFixed64SizeNoTag(ulong value)
+ public static int ComputeFixed64Size(ulong value)
{
return LittleEndian64Size;
}
@@ -303,7 +115,7 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode a
/// fixed32 field, including the tag.
/// </summary>
- public static int ComputeFixed32SizeNoTag(uint value)
+ public static int ComputeFixed32Size(uint value)
{
return LittleEndian32Size;
}
@@ -312,7 +124,7 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode a
/// bool field, including the tag.
/// </summary>
- public static int ComputeBoolSizeNoTag(bool value)
+ public static int ComputeBoolSize(bool value)
{
return 1;
}
@@ -321,9 +133,9 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode a
/// string field, including the tag.
/// </summary>
- public static int ComputeStringSizeNoTag(String value)
+ public static int ComputeStringSize(String value)
{
- int byteArraySize = Encoding.UTF8.GetByteCount(value);
+ int byteArraySize = Utf8Encoding.GetByteCount(value);
return ComputeRawVarint32Size((uint) byteArraySize) +
byteArraySize;
}
@@ -332,28 +144,18 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode a
/// group field, including the tag.
/// </summary>
- public static int ComputeGroupSizeNoTag(IMessageLite value)
- {
- return value.SerializedSize;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// group field represented by an UnknownFieldSet, including the tag.
- /// </summary>
- [Obsolete]
- public static int ComputeUnknownGroupSizeNoTag(IMessageLite value)
+ public static int ComputeGroupSize(IMessage value)
{
- return value.SerializedSize;
+ return value.CalculateSize();
}
/// <summary>
/// Compute the number of bytes that would be needed to encode an
/// embedded message field, including the tag.
/// </summary>
- public static int ComputeMessageSizeNoTag(IMessageLite value)
+ public static int ComputeMessageSize(IMessage value)
{
- int size = value.SerializedSize;
+ int size = value.CalculateSize();
return ComputeRawVarint32Size((uint) size) + size;
}
@@ -361,7 +163,7 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode a
/// bytes field, including the tag.
/// </summary>
- public static int ComputeBytesSizeNoTag(ByteString value)
+ public static int ComputeBytesSize(ByteString value)
{
return ComputeRawVarint32Size((uint) value.Length) +
value.Length;
@@ -371,7 +173,7 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode a
/// uint32 field, including the tag.
/// </summary>
- public static int ComputeUInt32SizeNoTag(uint value)
+ public static int ComputeUInt32Size(uint value)
{
return ComputeRawVarint32Size(value);
}
@@ -381,16 +183,17 @@ namespace Google.ProtocolBuffers /// enum field, including the tag. The caller is responsible for
/// converting the enum value to its numeric value.
/// </summary>
- public static int ComputeEnumSizeNoTag(int value)
+ public static int ComputeEnumSize(int value)
{
- return ComputeInt32SizeNoTag(value);
+ // Currently just a pass-through, but it's nice to separate it logically.
+ return ComputeInt32Size(value);
}
/// <summary>
/// Compute the number of bytes that would be needed to encode an
/// sfixed32 field, including the tag.
/// </summary>
- public static int ComputeSFixed32SizeNoTag(int value)
+ public static int ComputeSFixed32Size(int value)
{
return LittleEndian32Size;
}
@@ -399,7 +202,7 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode an
/// sfixed64 field, including the tag.
/// </summary>
- public static int ComputeSFixed64SizeNoTag(long value)
+ public static int ComputeSFixed64Size(long value)
{
return LittleEndian64Size;
}
@@ -408,7 +211,7 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode an
/// sint32 field, including the tag.
/// </summary>
- public static int ComputeSInt32SizeNoTag(int value)
+ public static int ComputeSInt32Size(int value)
{
return ComputeRawVarint32Size(EncodeZigZag32(value));
}
@@ -417,41 +220,11 @@ namespace Google.ProtocolBuffers /// Compute the number of bytes that would be needed to encode an
/// sint64 field, including the tag.
/// </summary>
- public static int ComputeSInt64SizeNoTag(long value)
+ public static int ComputeSInt64Size(long value)
{
return ComputeRawVarint64Size(EncodeZigZag64(value));
}
- /*
- * Compute the number of bytes that would be needed to encode a
- * MessageSet extension to the stream. For historical reasons,
- * the wire format differs from normal fields.
- */
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// MessageSet extension to the stream. For historical reasons,
- /// the wire format differs from normal fields.
- /// </summary>
- public static int ComputeMessageSetExtensionSize(int fieldNumber, IMessageLite value)
- {
- return ComputeTagSize(WireFormat.MessageSetField.Item)*2 +
- ComputeUInt32Size(WireFormat.MessageSetField.TypeID, (uint) fieldNumber) +
- ComputeMessageSize(WireFormat.MessageSetField.Message, value);
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// unparsed MessageSet extension field to the stream. For
- /// historical reasons, the wire format differs from normal fields.
- /// </summary>
- public static int ComputeRawMessageSetExtensionSize(int fieldNumber, ByteString value)
- {
- return ComputeTagSize(WireFormat.MessageSetField.Item)*2 +
- ComputeUInt32Size(WireFormat.MessageSetField.TypeID, (uint) fieldNumber) +
- ComputeBytesSize(WireFormat.MessageSetField.Message, value);
- }
-
/// <summary>
/// Compute the number of bytes that would be needed to encode a varint.
/// </summary>
@@ -521,118 +294,6 @@ namespace Google.ProtocolBuffers }
/// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// field of arbitrary type, including the tag, to the stream.
- /// </summary>
- public static int ComputeFieldSize(FieldType fieldType, int fieldNumber, Object value)
- {
- switch (fieldType)
- {
- case FieldType.Double:
- return ComputeDoubleSize(fieldNumber, (double) value);
- case FieldType.Float:
- return ComputeFloatSize(fieldNumber, (float) value);
- case FieldType.Int64:
- return ComputeInt64Size(fieldNumber, (long) value);
- case FieldType.UInt64:
- return ComputeUInt64Size(fieldNumber, (ulong) value);
- case FieldType.Int32:
- return ComputeInt32Size(fieldNumber, (int) value);
- case FieldType.Fixed64:
- return ComputeFixed64Size(fieldNumber, (ulong) value);
- case FieldType.Fixed32:
- return ComputeFixed32Size(fieldNumber, (uint) value);
- case FieldType.Bool:
- return ComputeBoolSize(fieldNumber, (bool) value);
- case FieldType.String:
- return ComputeStringSize(fieldNumber, (string) value);
- case FieldType.Group:
- return ComputeGroupSize(fieldNumber, (IMessageLite) value);
- case FieldType.Message:
- return ComputeMessageSize(fieldNumber, (IMessageLite) value);
- case FieldType.Bytes:
- return ComputeBytesSize(fieldNumber, (ByteString) value);
- case FieldType.UInt32:
- return ComputeUInt32Size(fieldNumber, (uint) value);
- case FieldType.SFixed32:
- return ComputeSFixed32Size(fieldNumber, (int) value);
- case FieldType.SFixed64:
- return ComputeSFixed64Size(fieldNumber, (long) value);
- case FieldType.SInt32:
- return ComputeSInt32Size(fieldNumber, (int) value);
- case FieldType.SInt64:
- return ComputeSInt64Size(fieldNumber, (long) value);
- case FieldType.Enum:
- if (value is Enum)
- {
- return ComputeEnumSize(fieldNumber, Convert.ToInt32(value));
- }
- else
- {
- return ComputeEnumSize(fieldNumber, ((IEnumLite) value).Number);
- }
- default:
- throw new ArgumentOutOfRangeException("Invalid field type " + fieldType);
- }
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// field of arbitrary type, excluding the tag, to the stream.
- /// </summary>
- public static int ComputeFieldSizeNoTag(FieldType fieldType, Object value)
- {
- switch (fieldType)
- {
- case FieldType.Double:
- return ComputeDoubleSizeNoTag((double) value);
- case FieldType.Float:
- return ComputeFloatSizeNoTag((float) value);
- case FieldType.Int64:
- return ComputeInt64SizeNoTag((long) value);
- case FieldType.UInt64:
- return ComputeUInt64SizeNoTag((ulong) value);
- case FieldType.Int32:
- return ComputeInt32SizeNoTag((int) value);
- case FieldType.Fixed64:
- return ComputeFixed64SizeNoTag((ulong) value);
- case FieldType.Fixed32:
- return ComputeFixed32SizeNoTag((uint) value);
- case FieldType.Bool:
- return ComputeBoolSizeNoTag((bool) value);
- case FieldType.String:
- return ComputeStringSizeNoTag((string) value);
- case FieldType.Group:
- return ComputeGroupSizeNoTag((IMessageLite) value);
- case FieldType.Message:
- return ComputeMessageSizeNoTag((IMessageLite) value);
- case FieldType.Bytes:
- return ComputeBytesSizeNoTag((ByteString) value);
- case FieldType.UInt32:
- return ComputeUInt32SizeNoTag((uint) value);
- case FieldType.SFixed32:
- return ComputeSFixed32SizeNoTag((int) value);
- case FieldType.SFixed64:
- return ComputeSFixed64SizeNoTag((long) value);
- case FieldType.SInt32:
- return ComputeSInt32SizeNoTag((int) value);
- case FieldType.SInt64:
- return ComputeSInt64SizeNoTag((long) value);
- case FieldType.Enum:
- if (value is Enum)
- {
- return ComputeEnumSizeNoTag(Convert.ToInt32(value));
- }
- else
- {
- return ComputeEnumSizeNoTag(((IEnumLite) value).Number);
- }
- default:
- throw new ArgumentOutOfRangeException("Invalid field type " + fieldType);
- }
- }
-
- /// <summary>
/// Compute the number of bytes that would be needed to encode a tag.
/// </summary>
public static int ComputeTagSize(int fieldNumber)
diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index c37fcc18..e56ce789 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -35,14 +35,11 @@ #endregion
using System;
-using System.Collections;
-using System.Collections.Generic;
using System.IO;
using System.Text;
-using Google.ProtocolBuffers.Collections;
-using Google.ProtocolBuffers.Descriptors;
+using Google.Protobuf.Collections;
-namespace Google.ProtocolBuffers
+namespace Google.Protobuf
{
/// <summary>
/// Encodes and writes protocol message fields.
@@ -57,8 +54,11 @@ namespace Google.ProtocolBuffers /// methods are taken from the protocol buffer type names, not .NET types.
/// (Hence WriteFloat instead of WriteSingle, and WriteBool instead of WriteBoolean.)
/// </remarks>
- public sealed partial class CodedOutputStream : ICodedOutputStream
+ public sealed partial class CodedOutputStream
{
+ // "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a difference.)
+ internal static readonly Encoding Utf8Encoding = Encoding.UTF8;
+
/// <summary>
/// The buffer size used by CreateInstance(Stream).
/// </summary>
@@ -141,378 +141,20 @@ namespace Google.ProtocolBuffers }
}
- void ICodedOutputStream.WriteMessageStart() { }
- void ICodedOutputStream.WriteMessageEnd() { Flush(); }
-
- #region Writing of unknown fields
-
- [Obsolete]
- public void WriteUnknownGroup(int fieldNumber, IMessageLite value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.StartGroup);
- value.WriteTo(this);
- WriteTag(fieldNumber, WireFormat.WireType.EndGroup);
- }
-
- public void WriteUnknownBytes(int fieldNumber, ByteString value)
- {
- WriteBytes(fieldNumber, null /*not used*/, value);
- }
-
- public void WriteUnknownField(int fieldNumber, WireFormat.WireType wireType, ulong value)
- {
- if (wireType == WireFormat.WireType.Varint)
- {
- WriteUInt64(fieldNumber, null /*not used*/, value);
- }
- else if (wireType == WireFormat.WireType.Fixed32)
- {
- WriteFixed32(fieldNumber, null /*not used*/, (uint) value);
- }
- else if (wireType == WireFormat.WireType.Fixed64)
- {
- WriteFixed64(fieldNumber, null /*not used*/, value);
- }
- else
- {
- throw InvalidProtocolBufferException.InvalidWireType();
- }
- }
-
- #endregion
-
- #region Writing of tags and fields
-
- public void WriteField(FieldType fieldType, int fieldNumber, string fieldName, object value)
- {
- switch (fieldType)
- {
- case FieldType.String:
- WriteString(fieldNumber, fieldName, (string) value);
- break;
- case FieldType.Message:
- WriteMessage(fieldNumber, fieldName, (IMessageLite) value);
- break;
- case FieldType.Group:
- WriteGroup(fieldNumber, fieldName, (IMessageLite) value);
- break;
- case FieldType.Bytes:
- WriteBytes(fieldNumber, fieldName, (ByteString) value);
- break;
- case FieldType.Bool:
- WriteBool(fieldNumber, fieldName, (bool) value);
- break;
- case FieldType.Enum:
- if (value is Enum)
- {
- WriteEnum(fieldNumber, fieldName, (int) value, null /*not used*/);
- }
- else
- {
- WriteEnum(fieldNumber, fieldName, ((IEnumLite) value).Number, null /*not used*/);
- }
- break;
- case FieldType.Int32:
- WriteInt32(fieldNumber, fieldName, (int) value);
- break;
- case FieldType.Int64:
- WriteInt64(fieldNumber, fieldName, (long) value);
- break;
- case FieldType.UInt32:
- WriteUInt32(fieldNumber, fieldName, (uint) value);
- break;
- case FieldType.UInt64:
- WriteUInt64(fieldNumber, fieldName, (ulong) value);
- break;
- case FieldType.SInt32:
- WriteSInt32(fieldNumber, fieldName, (int) value);
- break;
- case FieldType.SInt64:
- WriteSInt64(fieldNumber, fieldName, (long) value);
- break;
- case FieldType.Fixed32:
- WriteFixed32(fieldNumber, fieldName, (uint) value);
- break;
- case FieldType.Fixed64:
- WriteFixed64(fieldNumber, fieldName, (ulong) value);
- break;
- case FieldType.SFixed32:
- WriteSFixed32(fieldNumber, fieldName, (int) value);
- break;
- case FieldType.SFixed64:
- WriteSFixed64(fieldNumber, fieldName, (long) value);
- break;
- case FieldType.Double:
- WriteDouble(fieldNumber, fieldName, (double) value);
- break;
- case FieldType.Float:
- WriteFloat(fieldNumber, fieldName, (float) value);
- break;
- }
- }
-
- /// <summary>
- /// Writes a double field value, including tag, to the stream.
- /// </summary>
- public void WriteDouble(int fieldNumber, string fieldName, double value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
- WriteDoubleNoTag(value);
- }
-
- /// <summary>
- /// Writes a float field value, including tag, to the stream.
- /// </summary>
- public void WriteFloat(int fieldNumber, string fieldName, float value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
- WriteFloatNoTag(value);
- }
-
- /// <summary>
- /// Writes a uint64 field value, including tag, to the stream.
- /// </summary>
- public void WriteUInt64(int fieldNumber, string fieldName, ulong value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteRawVarint64(value);
- }
-
- /// <summary>
- /// Writes an int64 field value, including tag, to the stream.
- /// </summary>
- public void WriteInt64(int fieldNumber, string fieldName, long value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteRawVarint64((ulong) value);
- }
-
- /// <summary>
- /// Writes an int32 field value, including tag, to the stream.
- /// </summary>
- public void WriteInt32(int fieldNumber, string fieldName, int value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- if (value >= 0)
- {
- WriteRawVarint32((uint) value);
- }
- else
- {
- // Must sign-extend.
- WriteRawVarint64((ulong) value);
- }
- }
-
- /// <summary>
- /// Writes a fixed64 field value, including tag, to the stream.
- /// </summary>
- public void WriteFixed64(int fieldNumber, string fieldName, ulong value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
- WriteRawLittleEndian64(value);
- }
-
- /// <summary>
- /// Writes a fixed32 field value, including tag, to the stream.
- /// </summary>
- public void WriteFixed32(int fieldNumber, string fieldName, uint value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
- WriteRawLittleEndian32(value);
- }
-
- /// <summary>
- /// Writes a bool field value, including tag, to the stream.
- /// </summary>
- public void WriteBool(int fieldNumber, string fieldName, bool value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteRawByte(value ? (byte) 1 : (byte) 0);
- }
-
- /// <summary>
- /// Writes a string field value, including tag, to the stream.
- /// </summary>
- public void WriteString(int fieldNumber, string fieldName, string value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- // Optimise the case where we have enough space to write
- // the string directly to the buffer, which should be common.
- int length = Encoding.UTF8.GetByteCount(value);
- WriteRawVarint32((uint) length);
- if (limit - position >= length)
- {
- Encoding.UTF8.GetBytes(value, 0, value.Length, buffer, position);
- position += length;
- }
- else
- {
- byte[] bytes = Encoding.UTF8.GetBytes(value);
- WriteRawBytes(bytes);
- }
- }
-
- /// <summary>
- /// Writes a group field value, including tag, to the stream.
- /// </summary>
- public void WriteGroup(int fieldNumber, string fieldName, IMessageLite value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.StartGroup);
- value.WriteTo(this);
- WriteTag(fieldNumber, WireFormat.WireType.EndGroup);
- }
-
- public void WriteMessage(int fieldNumber, string fieldName, IMessageLite value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) value.SerializedSize);
- value.WriteTo(this);
- }
-
- public void WriteBytes(int fieldNumber, string fieldName, ByteString value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) value.Length);
- value.WriteRawBytesTo(this);
- }
-
- public void WriteUInt32(int fieldNumber, string fieldName, uint value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteRawVarint32(value);
- }
-
- public void WriteEnum(int fieldNumber, string fieldName, int value, object rawValue)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteInt32NoTag(value);
- }
-
- public void WriteSFixed32(int fieldNumber, string fieldName, int value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
- WriteRawLittleEndian32((uint) value);
- }
-
- public void WriteSFixed64(int fieldNumber, string fieldName, long value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
- WriteRawLittleEndian64((ulong) value);
- }
-
- public void WriteSInt32(int fieldNumber, string fieldName, int value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteRawVarint32(EncodeZigZag32(value));
- }
-
- public void WriteSInt64(int fieldNumber, string fieldName, long value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteRawVarint64(EncodeZigZag64(value));
- }
-
- public void WriteMessageSetExtension(int fieldNumber, string fieldName, IMessageLite value)
- {
- WriteTag(WireFormat.MessageSetField.Item, WireFormat.WireType.StartGroup);
- WriteUInt32(WireFormat.MessageSetField.TypeID, "type_id", (uint) fieldNumber);
- WriteMessage(WireFormat.MessageSetField.Message, "message", value);
- WriteTag(WireFormat.MessageSetField.Item, WireFormat.WireType.EndGroup);
- }
-
- public void WriteMessageSetExtension(int fieldNumber, string fieldName, ByteString value)
- {
- WriteTag(WireFormat.MessageSetField.Item, WireFormat.WireType.StartGroup);
- WriteUInt32(WireFormat.MessageSetField.TypeID, "type_id", (uint) fieldNumber);
- WriteBytes(WireFormat.MessageSetField.Message, "message", value);
- WriteTag(WireFormat.MessageSetField.Item, WireFormat.WireType.EndGroup);
- }
-
- #endregion
-
#region Writing of values without tags
- public void WriteFieldNoTag(FieldType fieldType, object value)
- {
- switch (fieldType)
- {
- case FieldType.String:
- WriteStringNoTag((string) value);
- break;
- case FieldType.Message:
- WriteMessageNoTag((IMessageLite) value);
- break;
- case FieldType.Group:
- WriteGroupNoTag((IMessageLite) value);
- break;
- case FieldType.Bytes:
- WriteBytesNoTag((ByteString) value);
- break;
- case FieldType.Bool:
- WriteBoolNoTag((bool) value);
- break;
- case FieldType.Enum:
- if (value is Enum)
- {
- WriteEnumNoTag((int) value);
- }
- else
- {
- WriteEnumNoTag(((IEnumLite) value).Number);
- }
- break;
- case FieldType.Int32:
- WriteInt32NoTag((int) value);
- break;
- case FieldType.Int64:
- WriteInt64NoTag((long) value);
- break;
- case FieldType.UInt32:
- WriteUInt32NoTag((uint) value);
- break;
- case FieldType.UInt64:
- WriteUInt64NoTag((ulong) value);
- break;
- case FieldType.SInt32:
- WriteSInt32NoTag((int) value);
- break;
- case FieldType.SInt64:
- WriteSInt64NoTag((long) value);
- break;
- case FieldType.Fixed32:
- WriteFixed32NoTag((uint) value);
- break;
- case FieldType.Fixed64:
- WriteFixed64NoTag((ulong) value);
- break;
- case FieldType.SFixed32:
- WriteSFixed32NoTag((int) value);
- break;
- case FieldType.SFixed64:
- WriteSFixed64NoTag((long) value);
- break;
- case FieldType.Double:
- WriteDoubleNoTag((double) value);
- break;
- case FieldType.Float:
- WriteFloatNoTag((float) value);
- break;
- }
- }
-
/// <summary>
/// Writes a double field value, including tag, to the stream.
/// </summary>
- public void WriteDoubleNoTag(double value)
+ public void WriteDouble(double value)
{
- WriteRawLittleEndian64((ulong)FrameworkPortability.DoubleToInt64(value));
+ WriteRawLittleEndian64((ulong)BitConverter.DoubleToInt64Bits(value));
}
/// <summary>
/// Writes a float field value, without a tag, to the stream.
/// </summary>
- public void WriteFloatNoTag(float value)
+ public void WriteFloat(float value)
{
byte[] rawBytes = BitConverter.GetBytes(value);
if (!BitConverter.IsLittleEndian)
@@ -536,7 +178,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Writes a uint64 field value, without a tag, to the stream.
/// </summary>
- public void WriteUInt64NoTag(ulong value)
+ public void WriteUInt64(ulong value)
{
WriteRawVarint64(value);
}
@@ -544,7 +186,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Writes an int64 field value, without a tag, to the stream.
/// </summary>
- public void WriteInt64NoTag(long value)
+ public void WriteInt64(long value)
{
WriteRawVarint64((ulong) value);
}
@@ -552,7 +194,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Writes an int32 field value, without a tag, to the stream.
/// </summary>
- public void WriteInt32NoTag(int value)
+ public void WriteInt32(int value)
{
if (value >= 0)
{
@@ -568,7 +210,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Writes a fixed64 field value, without a tag, to the stream.
/// </summary>
- public void WriteFixed64NoTag(ulong value)
+ public void WriteFixed64(ulong value)
{
WriteRawLittleEndian64(value);
}
@@ -576,7 +218,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Writes a fixed32 field value, without a tag, to the stream.
/// </summary>
- public void WriteFixed32NoTag(uint value)
+ public void WriteFixed32(uint value)
{
WriteRawLittleEndian32(value);
}
@@ -584,7 +226,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Writes a bool field value, without a tag, to the stream.
/// </summary>
- public void WriteBoolNoTag(bool value)
+ public void WriteBool(bool value)
{
WriteRawByte(value ? (byte) 1 : (byte) 0);
}
@@ -592,478 +234,464 @@ namespace Google.ProtocolBuffers /// <summary>
/// Writes a string field value, without a tag, to the stream.
/// </summary>
- public void WriteStringNoTag(string value)
+ public void WriteString(string value)
{
// Optimise the case where we have enough space to write
// the string directly to the buffer, which should be common.
- int length = Encoding.UTF8.GetByteCount(value);
- WriteRawVarint32((uint) length);
+ int length = Utf8Encoding.GetByteCount(value);
+ WriteRawVarint32((uint)length);
if (limit - position >= length)
{
- Encoding.UTF8.GetBytes(value, 0, value.Length, buffer, position);
+ if (length == value.Length) // Must be all ASCII...
+ {
+ for (int i = 0; i < length; i++)
+ {
+ buffer[position + i] = (byte)value[i];
+ }
+ }
+ else
+ {
+ Utf8Encoding.GetBytes(value, 0, value.Length, buffer, position);
+ }
position += length;
}
else
{
- byte[] bytes = Encoding.UTF8.GetBytes(value);
+ byte[] bytes = Utf8Encoding.GetBytes(value);
WriteRawBytes(bytes);
}
}
- /// <summary>
- /// Writes a group field value, without a tag, to the stream.
- /// </summary>
- public void WriteGroupNoTag(IMessageLite value)
+ public void WriteMessage(IMessage value)
{
+ WriteRawVarint32((uint) value.CalculateSize());
value.WriteTo(this);
}
- public void WriteMessageNoTag(IMessageLite value)
- {
- WriteRawVarint32((uint) value.SerializedSize);
- value.WriteTo(this);
- }
-
- public void WriteBytesNoTag(ByteString value)
+ public void WriteBytes(ByteString value)
{
WriteRawVarint32((uint) value.Length);
value.WriteRawBytesTo(this);
}
- public void WriteUInt32NoTag(uint value)
+ public void WriteUInt32(uint value)
{
WriteRawVarint32(value);
}
- public void WriteEnumNoTag(int value)
+ public void WriteEnum(int value)
{
- WriteInt32NoTag(value);
+ WriteInt32(value);
}
- public void WriteSFixed32NoTag(int value)
+ public void WriteSFixed32(int value)
{
WriteRawLittleEndian32((uint) value);
}
- public void WriteSFixed64NoTag(long value)
+ public void WriteSFixed64(long value)
{
WriteRawLittleEndian64((ulong) value);
}
- public void WriteSInt32NoTag(int value)
+ public void WriteSInt32(int value)
{
WriteRawVarint32(EncodeZigZag32(value));
}
- public void WriteSInt64NoTag(long value)
+ public void WriteSInt64(long value)
{
WriteRawVarint64(EncodeZigZag64(value));
}
#endregion
- #region Write array members
-
- public void WriteArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list)
+ #region Write array members, with fields.
+ public void WriteMessageArray<T>(int fieldNumber, RepeatedField<T> list)
+ where T : IMessage
{
- foreach (object element in list)
+ foreach (T value in list)
{
- WriteField(fieldType, fieldNumber, fieldName, element);
+ WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
+ WriteMessage(value);
}
}
- public void WriteGroupArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
- where T : IMessageLite
- {
- foreach (IMessageLite value in list)
- {
- WriteGroup(fieldNumber, fieldName, value);
- }
- }
-
- public void WriteMessageArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
- where T : IMessageLite
- {
- foreach (IMessageLite value in list)
- {
- WriteMessage(fieldNumber, fieldName, value);
- }
- }
-
- public void WriteStringArray(int fieldNumber, string fieldName, IEnumerable<string> list)
+ public void WriteStringArray(int fieldNumber, RepeatedField<string> list)
{
foreach (var value in list)
{
- WriteString(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
+ WriteString(value);
}
}
- public void WriteBytesArray(int fieldNumber, string fieldName, IEnumerable<ByteString> list)
+ public void WriteBytesArray(int fieldNumber, RepeatedField<ByteString> list)
{
foreach (var value in list)
{
- WriteBytes(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
+ WriteBytes(value);
}
}
- public void WriteBoolArray(int fieldNumber, string fieldName, IEnumerable<bool> list)
+ public void WriteBoolArray(int fieldNumber, RepeatedField<bool> list)
{
foreach (var value in list)
{
- WriteBool(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteBool(value);
}
}
- public void WriteInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list)
+ public void WriteInt32Array(int fieldNumber, RepeatedField<int> list)
{
foreach (var value in list)
{
- WriteInt32(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteInt32(value);
}
}
- public void WriteSInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list)
+ public void WriteSInt32Array(int fieldNumber, RepeatedField<int> list)
{
foreach (var value in list)
{
- WriteSInt32(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteSInt32(value);
}
}
- public void WriteUInt32Array(int fieldNumber, string fieldName, IEnumerable<uint> list)
+ public void WriteUInt32Array(int fieldNumber, RepeatedField<uint> list)
{
foreach (var value in list)
{
- WriteUInt32(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteUInt32(value);
}
}
- public void WriteFixed32Array(int fieldNumber, string fieldName, IEnumerable<uint> list)
+ public void WriteFixed32Array(int fieldNumber, RepeatedField<uint> list)
{
foreach (var value in list)
{
- WriteFixed32(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
+ WriteFixed32(value);
}
}
- public void WriteSFixed32Array(int fieldNumber, string fieldName, IEnumerable<int> list)
+ public void WriteSFixed32Array(int fieldNumber, RepeatedField<int> list)
{
foreach (var value in list)
{
- WriteSFixed32(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
+ WriteSFixed32(value);
}
}
- public void WriteInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list)
+ public void WriteInt64Array(int fieldNumber, RepeatedField<long> list)
{
foreach (var value in list)
{
- WriteInt64(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
+ WriteInt64(value);
}
}
- public void WriteSInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list)
+ public void WriteSInt64Array(int fieldNumber, RepeatedField<long> list)
{
foreach (var value in list)
{
- WriteSInt64(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteSInt64(value);
}
}
- public void WriteUInt64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list)
+ public void WriteUInt64Array(int fieldNumber, RepeatedField<ulong> list)
{
foreach (var value in list)
{
- WriteUInt64(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteUInt64(value);
}
}
- public void WriteFixed64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list)
+ public void WriteFixed64Array(int fieldNumber, RepeatedField<ulong> list)
{
foreach (var value in list)
{
- WriteFixed64(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
+ WriteFixed64(value);
}
}
- public void WriteSFixed64Array(int fieldNumber, string fieldName, IEnumerable<long> list)
+ public void WriteSFixed64Array(int fieldNumber, RepeatedField<long> list)
{
foreach (var value in list)
{
- WriteSFixed64(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
+ WriteSFixed64(value);
}
}
- public void WriteDoubleArray(int fieldNumber, string fieldName, IEnumerable<double> list)
+ public void WriteDoubleArray(int fieldNumber, RepeatedField<double> list)
{
foreach (var value in list)
{
- WriteDouble(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
+ WriteDouble(value);
}
}
- public void WriteFloatArray(int fieldNumber, string fieldName, IEnumerable<float> list)
+ public void WriteFloatArray(int fieldNumber, RepeatedField<float> list)
{
foreach (var value in list)
{
- WriteFloat(fieldNumber, fieldName, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
+ WriteFloat(value);
}
}
- public void WriteEnumArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
+ public void WriteEnumArray<T>(int fieldNumber, RepeatedField<T> list)
where T : struct, IComparable, IFormattable
{
- if (list is ICastArray)
- {
- foreach (int value in ((ICastArray) list).CastArray<int>())
- {
- WriteEnum(fieldNumber, fieldName, value, null /*unused*/);
- }
- }
- else
+ // Bit of a hack, to access the values as ints
+ var iterator = list.GetInt32Enumerator();
+ while (iterator.MoveNext())
{
- foreach (object value in list)
- {
- WriteEnum(fieldNumber, fieldName, (int) value, null /*unused*/);
- }
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteEnum(iterator.Current);
}
}
#endregion
- #region Write packed array members
-
- public void WritePackedArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list)
+ #region Raw tag writing
+ /// <summary>
+ /// Encodes and writes a tag.
+ /// </summary>
+ public void WriteTag(int fieldNumber, WireFormat.WireType type)
{
- int calculatedSize = 0;
- foreach (object element in list)
- {
- calculatedSize += ComputeFieldSizeNoTag(fieldType, element);
- }
-
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type));
+ }
- foreach (object element in list)
- {
- WriteFieldNoTag(fieldType, element);
- }
+ /// <summary>
+ /// Writes the given single-byte tag directly to the stream.
+ /// </summary>
+ public void WriteRawTag(byte b1)
+ {
+ WriteRawByte(b1);
}
- public void WritePackedGroupArray<T>(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<T> list)
- where T : IMessageLite
+ /// <summary>
+ /// Writes the given two-byte tag directly to the stream.
+ /// </summary>
+ public void WriteRawTag(byte b1, byte b2)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
- foreach (IMessageLite value in list)
- {
- WriteGroupNoTag(value);
- }
+ WriteRawByte(b1);
+ WriteRawByte(b2);
}
- public void WritePackedMessageArray<T>(int fieldNumber, string fieldName, int calculatedSize,
- IEnumerable<T> list)
- where T : IMessageLite
+ /// <summary>
+ /// Writes the given three-byte tag directly to the stream.
+ /// </summary>
+ public void WriteRawTag(byte b1, byte b2, byte b3)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
- foreach (IMessageLite value in list)
- {
- WriteMessageNoTag(value);
- }
+ WriteRawByte(b1);
+ WriteRawByte(b2);
+ WriteRawByte(b3);
}
- public void WritePackedStringArray(int fieldNumber, string fieldName, int calculatedSize,
- IEnumerable<string> list)
+ /// <summary>
+ /// Writes the given four-byte tag directly to the stream.
+ /// </summary>
+ public void WriteRawTag(byte b1, byte b2, byte b3, byte b4)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
- foreach (var value in list)
- {
- WriteStringNoTag(value);
- }
+ WriteRawByte(b1);
+ WriteRawByte(b2);
+ WriteRawByte(b3);
+ WriteRawByte(b4);
}
- public void WritePackedBytesArray(int fieldNumber, string fieldName, int calculatedSize,
- IEnumerable<ByteString> list)
+ /// <summary>
+ /// Writes the given five-byte tag directly to the stream.
+ /// </summary>
+ public void WriteRawTag(byte b1, byte b2, byte b3, byte b4, byte b5)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
- foreach (var value in list)
- {
- WriteBytesNoTag(value);
- }
+ WriteRawByte(b1);
+ WriteRawByte(b2);
+ WriteRawByte(b3);
+ WriteRawByte(b4);
+ WriteRawByte(b5);
}
+ #endregion
- public void WritePackedBoolArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<bool> list)
+ #region Write packed array members
+ // TODO(jonskeet): A lot of these are really inefficient, due to method group conversions. Fix!
+ // (Alternatively, add extension methods to RepeatedField, accepting the Write* methods via delegates too.)
+ public void WritePackedBoolArray(RepeatedField<bool> list)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ uint size = (uint)list.Count;
+ WriteRawVarint32(size);
foreach (var value in list)
{
- WriteBoolNoTag(value);
+ WriteBool(value);
}
}
- public void WritePackedInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list)
+ public void WritePackedInt32Array(RepeatedField<int> list)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ uint size = list.CalculateSize(ComputeInt32Size);
+ WriteRawVarint32(size);
foreach (var value in list)
{
- WriteInt32NoTag(value);
+ WriteInt32(value);
}
}
- public void WritePackedSInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list)
+ public void WritePackedSInt32Array(RepeatedField<int> list)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ uint size = list.CalculateSize(ComputeSInt32Size);
+ WriteRawVarint32(size);
foreach (var value in list)
{
- WriteSInt32NoTag(value);
+ WriteSInt32(value);
}
}
- public void WritePackedUInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<uint> list)
+ public void WritePackedUInt32Array(RepeatedField<uint> list)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ uint size = list.CalculateSize(ComputeUInt32Size);
+ WriteRawVarint32(size);
foreach (var value in list)
{
- WriteUInt32NoTag(value);
+ WriteUInt32(value);
}
}
- public void WritePackedFixed32Array(int fieldNumber, string fieldName, int calculatedSize,
- IEnumerable<uint> list)
+ public void WritePackedFixed32Array(RepeatedField<uint> list)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ uint size = (uint) list.Count * 4;
+ WriteRawVarint32(size);
foreach (var value in list)
{
- WriteFixed32NoTag(value);
+ WriteFixed32(value);
}
}
- public void WritePackedSFixed32Array(int fieldNumber, string fieldName, int calculatedSize,
- IEnumerable<int> list)
+ public void WritePackedSFixed32Array(RepeatedField<int> list)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ uint size = (uint) list.Count * 4;
+ WriteRawVarint32(size);
foreach (var value in list)
{
- WriteSFixed32NoTag(value);
+ WriteSFixed32(value);
}
}
- public void WritePackedInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list)
+ public void WritePackedInt64Array(RepeatedField<long> list)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ uint size = list.CalculateSize(ComputeInt64Size);
+ WriteRawVarint32(size);
foreach (var value in list)
{
- WriteInt64NoTag(value);
+ WriteInt64(value);
}
}
- public void WritePackedSInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list)
+ public void WritePackedSInt64Array(RepeatedField<long> list)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ uint size = list.CalculateSize(ComputeSInt64Size);
+ WriteRawVarint32(size);
foreach (var value in list)
{
- WriteSInt64NoTag(value);
+ WriteSInt64(value);
}
}
- public void WritePackedUInt64Array(int fieldNumber, string fieldName, int calculatedSize,
- IEnumerable<ulong> list)
+ public void WritePackedUInt64Array(RepeatedField<ulong> list)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ if (list.Count == 0)
+ {
+ return;
+ }
+ uint size = list.CalculateSize(ComputeUInt64Size);
+ WriteRawVarint32(size);
foreach (var value in list)
{
- WriteUInt64NoTag(value);
+ WriteUInt64(value);
}
}
- public void WritePackedFixed64Array(int fieldNumber, string fieldName, int calculatedSize,
- IEnumerable<ulong> list)
+ public void WritePackedFixed64Array(RepeatedField<ulong> list)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ uint size = (uint) list.Count * 8;
+ WriteRawVarint32(size);
foreach (var value in list)
{
- WriteFixed64NoTag(value);
+ WriteFixed64(value);
}
}
- public void WritePackedSFixed64Array(int fieldNumber, string fieldName, int calculatedSize,
- IEnumerable<long> list)
+ public void WritePackedSFixed64Array(RepeatedField<long> list)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ uint size = (uint) list.Count * 8;
+ WriteRawVarint32(size);
foreach (var value in list)
{
- WriteSFixed64NoTag(value);
+ WriteSFixed64(value);
}
}
- public void WritePackedDoubleArray(int fieldNumber, string fieldName, int calculatedSize,
- IEnumerable<double> list)
+ public void WritePackedDoubleArray(RepeatedField<double> list)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ uint size = (uint) list.Count * 8;
+ WriteRawVarint32(size);
foreach (var value in list)
{
- WriteDoubleNoTag(value);
+ WriteDouble(value);
}
}
- public void WritePackedFloatArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<float> list)
+ public void WritePackedFloatArray(RepeatedField<float> list)
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
+ if (list.Count == 0)
+ {
+ return;
+ }
+ uint size = (uint) list.Count * 4;
+ WriteRawVarint32(size);
foreach (var value in list)
{
- WriteFloatNoTag(value);
+ WriteFloat(value);
}
}
- public void WritePackedEnumArray<T>(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<T> list)
+ public void WritePackedEnumArray<T>(RepeatedField<T> list)
where T : struct, IComparable, IFormattable
{
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
- if (list is ICastArray)
+ if (list.Count == 0)
{
- foreach (int value in ((ICastArray) list).CastArray<int>())
- {
- WriteEnumNoTag(value);
- }
+ return;
}
- else
+ // Bit of a hack, to access the values as ints
+ var iterator = list.GetInt32Enumerator();
+ uint size = 0;
+ while (iterator.MoveNext())
{
- foreach (object value in list)
- {
- WriteEnumNoTag((int) value);
- }
+ size += (uint) ComputeEnumSize(iterator.Current);
+ }
+ iterator.Reset();
+ WriteRawVarint32(size);
+ while (iterator.MoveNext())
+ {
+ WriteEnum(iterator.Current);
}
}
#endregion
#region Underlying writing primitives
-
- /// <summary>
- /// Encodes and writes a tag.
- /// </summary>
- public void WriteTag(int fieldNumber, WireFormat.WireType type)
- {
- WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type));
- }
-
/// <summary>
/// Writes a 32 bit value as a varint. The fast route is taken when
/// there's enough buffer space left to whizz through without checking
@@ -1071,6 +699,13 @@ namespace Google.ProtocolBuffers /// </summary>
public void WriteRawVarint32(uint value)
{
+ // Optimize for the common case of a single byte value
+ if (value < 128 && position < limit)
+ {
+ buffer[position++] = (byte)value;
+ return;
+ }
+
while (value > 127 && position < limit)
{
buffer[position++] = (byte) ((value & 0x7F) | 0x80);
diff --git a/csharp/src/ProtocolBuffers/Collections/Dictionaries.cs b/csharp/src/ProtocolBuffers/Collections/Dictionaries.cs index 1f3791b1..22fe90a6 100644 --- a/csharp/src/ProtocolBuffers/Collections/Dictionaries.cs +++ b/csharp/src/ProtocolBuffers/Collections/Dictionaries.cs @@ -33,7 +33,7 @@ using System; using System.Collections;
using System.Collections.Generic;
-namespace Google.ProtocolBuffers.Collections
+namespace Google.Protobuf.Collections
{
/// <summary>
/// Utility class for dictionaries.
diff --git a/csharp/src/ProtocolBuffers/Collections/Enumerables.cs b/csharp/src/ProtocolBuffers/Collections/Enumerables.cs index 7ad9a832..217aefd7 100644 --- a/csharp/src/ProtocolBuffers/Collections/Enumerables.cs +++ b/csharp/src/ProtocolBuffers/Collections/Enumerables.cs @@ -32,7 +32,7 @@ using System;
using System.Collections;
-namespace Google.ProtocolBuffers.Collections
+namespace Google.Protobuf.Collections
{
/// <summary>
/// Utility class for IEnumerable (and potentially the generic version in the future).
diff --git a/csharp/src/ProtocolBuffers/Collections/IPopsicleList.cs b/csharp/src/ProtocolBuffers/Collections/IPopsicleList.cs deleted file mode 100644 index a1a75815..00000000 --- a/csharp/src/ProtocolBuffers/Collections/IPopsicleList.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-using System.Collections.Generic;
-
-namespace Google.ProtocolBuffers.Collections
-{
- /// <summary>
- /// A list which has an Add method which accepts an IEnumerable[T].
- /// This allows whole collections to be added easily using collection initializers.
- /// It causes a potential overload confusion if T : IEnumerable[T], but in
- /// practice that won't happen in protocol buffers.
- /// </summary>
- /// <remarks>This is only currently implemented by PopsicleList, and it's likely
- /// to stay that way - hence the name. More genuinely descriptive names are
- /// horribly ugly. (At least, the ones the author could think of...)</remarks>
- /// <typeparam name="T">The element type of the list</typeparam>
- public interface IPopsicleList<T> : IList<T>
- {
- void Add(IEnumerable<T> collection);
- }
-
- /// <summary>
- /// Used to efficiently cast the elements of enumerations
- /// </summary>
- internal interface ICastArray
- {
- IEnumerable<TItemType> CastArray<TItemType>();
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Collections/Lists.cs b/csharp/src/ProtocolBuffers/Collections/Lists.cs index a24e1d9b..cf681767 100644 --- a/csharp/src/ProtocolBuffers/Collections/Lists.cs +++ b/csharp/src/ProtocolBuffers/Collections/Lists.cs @@ -32,7 +32,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
-namespace Google.ProtocolBuffers.Collections
+namespace Google.Protobuf.Collections
{
/// <summary>
/// Utility non-generic class for calling into Lists{T} using type inference.
diff --git a/csharp/src/ProtocolBuffers/Collections/PopsicleList.cs b/csharp/src/ProtocolBuffers/Collections/PopsicleList.cs deleted file mode 100644 index 3de97f89..00000000 --- a/csharp/src/ProtocolBuffers/Collections/PopsicleList.cs +++ /dev/null @@ -1,208 +0,0 @@ -// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace Google.ProtocolBuffers.Collections
-{
- /// <summary>
- /// Proxies calls to a <see cref="List{T}" />, but allows the list
- /// to be made read-only (with the <see cref="MakeReadOnly" /> method),
- /// after which any modifying methods throw <see cref="NotSupportedException" />.
- /// </summary>
- public sealed class PopsicleList<T> : IPopsicleList<T>, ICastArray
- {
- private static readonly bool CheckForNull = default(T) == null;
- private static readonly T[] EmptySet = new T[0];
-
- private List<T> items;
- private bool readOnly;
-
- /// <summary>
- /// Makes this list read-only ("freezes the popsicle"). From this
- /// point on, mutating methods (Clear, Add etc) will throw a
- /// NotSupportedException. There is no way of "defrosting" the list afterwards.
- /// </summary>
- public void MakeReadOnly()
- {
- readOnly = true;
- }
-
- public int IndexOf(T item)
- {
- return items == null ? -1 : items.IndexOf(item);
- }
-
- public void Insert(int index, T item)
- {
- ValidateModification();
- if (CheckForNull)
- {
- ThrowHelper.ThrowIfNull(item);
- }
- items.Insert(index, item);
- }
-
- public void RemoveAt(int index)
- {
- ValidateModification();
- items.RemoveAt(index);
- }
-
- public T this[int index]
- {
- get
- {
- if (items == null)
- {
- throw new ArgumentOutOfRangeException();
- }
- return items[index];
- }
- set
- {
- ValidateModification();
- if (CheckForNull)
- {
- ThrowHelper.ThrowIfNull(value);
- }
- items[index] = value;
- }
- }
-
- public void Add(T item)
- {
- ValidateModification();
- if (CheckForNull)
- {
- ThrowHelper.ThrowIfNull(item);
- }
- items.Add(item);
- }
-
- public void Clear()
- {
- ValidateModification();
- items.Clear();
- }
-
- public bool Contains(T item)
- {
- return items == null ? false : items.Contains(item);
- }
-
- public void CopyTo(T[] array, int arrayIndex)
- {
- if (items != null)
- {
- items.CopyTo(array, arrayIndex);
- }
- }
-
- public int Count
- {
- get { return items == null ? 0 : items.Count; }
- }
-
- public bool IsReadOnly
- {
- get { return readOnly; }
- }
-
- public bool Remove(T item)
- {
- ValidateModification();
- return items.Remove(item);
- }
-
- public IEnumerator<T> GetEnumerator()
- {
- IEnumerable<T> tenum = (IEnumerable<T>)items ?? EmptySet;
- return tenum.GetEnumerator();
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- public void Add(IEnumerable<T> collection)
- {
- ValidateModification();
- ThrowHelper.ThrowIfNull(collection);
-
- if (!CheckForNull || collection is PopsicleList<T>)
- {
- items.AddRange(collection);
- }
- else
- {
- // Assumption, it's ok to enumerate collections more than once.
- if (collection is ICollection<T>)
- {
- ThrowHelper.ThrowIfAnyNull(collection);
- items.AddRange(collection);
- }
- else
- {
- foreach (T item in collection)
- {
- ThrowHelper.ThrowIfNull(item);
- items.Add(item);
- }
- }
- }
- }
-
- private void ValidateModification()
- {
- if (readOnly)
- {
- throw new NotSupportedException("List is read-only");
- }
- if (items == null)
- {
- items = new List<T>();
- }
- }
-
- IEnumerable<TItemType> ICastArray.CastArray<TItemType>()
- {
- if (items == null)
- {
- return PopsicleList<TItemType>.EmptySet;
- }
- return (TItemType[]) (object) items.ToArray();
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs b/csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs index b0bc55ff..031ebd02 100644 --- a/csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs +++ b/csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs @@ -33,7 +33,7 @@ using System; using System.Collections;
using System.Collections.Generic;
-namespace Google.ProtocolBuffers.Collections
+namespace Google.Protobuf.Collections
{
/// <summary>
/// Read-only wrapper around another dictionary.
diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs new file mode 100644 index 00000000..25651784 --- /dev/null +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -0,0 +1,329 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Google.Protobuf.Collections +{ + public sealed class RepeatedField<T> : IList<T>, IEquatable<RepeatedField<T>> + { + private static readonly T[] EmptyArray = new T[0]; + + private const int MinArraySize = 8; + private T[] array = EmptyArray; + private int count = 0; + + private void EnsureSize(int size) + { + size = Math.Max(size, MinArraySize); + if (array.Length < size) + { + int newSize = Math.Max(array.Length * 2, size); + var tmp = new T[newSize]; + Array.Copy(array, 0, tmp, 0, array.Length); + array = tmp; + } + } + + public void Add(T item) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + EnsureSize(count + 1); + array[count++] = item; + } + + /// <summary> + /// Hack to allow us to add enums easily... will only work with int-based types. + /// </summary> + /// <param name="readEnum"></param> + internal void AddInt32(int item) + { + EnsureSize(count + 1); + int[] castArray = (int[]) (object) array; + castArray[count++] = item; + } + + public void Clear() + { + array = EmptyArray; + count = 0; + } + + public bool Contains(T item) + { + return IndexOf(item) != -1; + } + + public void CopyTo(T[] array, int arrayIndex) + { + Array.Copy(this.array, 0, array, arrayIndex, count); + } + + public bool Remove(T item) + { + int index = IndexOf(item); + if (index == -1) + { + return false; + } + Array.Copy(array, index + 1, array, index, count - index - 1); + count--; + array[count] = default(T); + return true; + } + + public int Count { get { return count; } } + + // TODO(jonskeet): If we implement freezing, make this reflect it. + public bool IsReadOnly { get { return false; } } + + public void Add(RepeatedField<T> values) + { + if (values == null) + { + throw new ArgumentNullException("values"); + } + EnsureSize(count + values.count); + // We know that all the values will be valid, because it's a RepeatedField. + Array.Copy(values.array, 0, array, count, values.count); + count += values.count; + } + + public void Add(IEnumerable<T> values) + { + if (values == null) + { + throw new ArgumentNullException("values"); + } + // TODO: Check for ICollection and get the Count? + foreach (T item in values) + { + Add(item); + } + } + + public RepeatedField<T>.Enumerator GetEnumerator() + { + return new Enumerator(this); + } + + IEnumerator<T> IEnumerable<T>.GetEnumerator() + { + return GetEnumerator(); + } + + public override bool Equals(object obj) + { + return Equals(obj as RepeatedField<T>); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// <summary> + /// Returns an enumerator of the values in this list as integers. + /// Used for enum types. + /// </summary> + internal Int32Enumerator GetInt32Enumerator() + { + return new Int32Enumerator((int[])(object)array, count); + } + + public override int GetHashCode() + { + int hash = 23; + for (int i = 0; i < count; i++) + { + hash = hash * 31 + array[i].GetHashCode(); + } + return hash; + } + + public bool Equals(RepeatedField<T> other) + { + if (ReferenceEquals(other, null)) + { + return false; + } + if (ReferenceEquals(other, this)) + { + return true; + } + if (other.Count != this.Count) + { + return false; + } + // TODO(jonskeet): Does this box for enums? + EqualityComparer<T> comparer = EqualityComparer<T>.Default; + for (int i = 0; i < count; i++) + { + if (!comparer.Equals(array[i], other.array[i])) + { + return false; + } + } + return true; + } + + public int IndexOf(T item) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + // TODO(jonskeet): Does this box for enums? + EqualityComparer<T> comparer = EqualityComparer<T>.Default; + for (int i = 0; i < count; i++) + { + if (comparer.Equals(array[i], item)) + { + return i; + } + } + return -1; + } + + public void Insert(int index, T item) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + if (index < 0 || index > count) + { + throw new ArgumentOutOfRangeException("index"); + } + EnsureSize(count + 1); + Array.Copy(array, index, array, index + 1, count - index); + count++; + } + + public void RemoveAt(int index) + { + if (index < 0 || index >= count) + { + throw new ArgumentOutOfRangeException("index"); + } + Array.Copy(array, index + 1, array, index, count - index - 1); + count--; + array[count] = default(T); + } + + public T this[int index] + { + get + { + if (index < 0 || index >= count) + { + throw new ArgumentOutOfRangeException("index"); + } + return array[index]; + } + set + { + if (index < 0 || index >= count) + { + throw new ArgumentOutOfRangeException("index"); + } + if (value == null) + { + throw new ArgumentNullException("value"); + } + array[index] = value; + } + } + + public struct Enumerator : IEnumerator<T> + { + private int index; + private readonly RepeatedField<T> field; + + public Enumerator(RepeatedField<T> field) + { + this.field = field; + this.index = -1; + } + + public bool MoveNext() + { + if (index + 1 >= field.Count) + { + return false; + } + index++; + return true; + } + + public void Reset() + { + index = -1; + } + + public T Current + { + get + { + if (index == -1 || index >= field.count) + { + throw new InvalidOperationException(); + } + return field.array[index]; + } + } + + object IEnumerator.Current + { + get { return Current; } + } + + public void Dispose() + { + } + } + + internal struct Int32Enumerator : IEnumerator<int> + { + private int index; + private readonly int[] array; + private readonly int count; + + public Int32Enumerator(int[] array, int count) + { + this.array = array; + this.index = -1; + this.count = count; + } + + public bool MoveNext() + { + if (index + 1 >= count) + { + return false; + } + index++; + return true; + } + + public void Reset() + { + index = -1; + } + + // No guard here, as we're only going to use this internally... + public int Current { get { return array[index]; } } + + object IEnumerator.Current + { + get { return Current; } + } + + public void Dispose() + { + } + } + } +} diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedFieldExtensions.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedFieldExtensions.cs new file mode 100644 index 00000000..c5a934a1 --- /dev/null +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedFieldExtensions.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Google.Protobuf.Collections +{ + public static class RepeatedFieldExtensions + { + internal static uint CalculateSize<T>(this RepeatedField<T> list, Func<T, int> sizeComputer) + { + int size = 0; + foreach (var item in list) + { + size += sizeComputer(item); + } + return (uint)size; + } + + /* + /// <summary> + /// Calculates the serialized data size, including one tag per value. + /// </summary> + public static int CalculateTotalSize<T>(this RepeatedField<T> list, int tagSize, Func<T, int> sizeComputer) + { + if (list.Count == 0) + { + return 0; + } + return (int)(dataSize + tagSize * list.Count); + } + + /// <summary> + /// Calculates the serialized data size, as a packed array (tag, length, data). + /// </summary> + public static int CalculateTotalPackedSize(int tagSize) + { + if (Count == 0) + { + return 0; + } + uint dataSize = CalculateSize(); + return tagSize + CodedOutputStream.ComputeRawVarint32Size(dataSize) + (int)dataSize; + } + */ + } +} diff --git a/csharp/src/ProtocolBuffers/Delegates.cs b/csharp/src/ProtocolBuffers/Delegates.cs deleted file mode 100644 index 3b62bc0c..00000000 --- a/csharp/src/ProtocolBuffers/Delegates.cs +++ /dev/null @@ -1,54 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System.IO;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Delegate to return a stream when asked, used by MessageStreamIterator.
- /// </summary>
- public delegate Stream StreamProvider();
-
- // These delegate declarations mirror the ones in .NET 3.5 for the sake of familiarity.
- internal delegate TResult Func<TResult>();
-
- internal delegate TResult Func<T, TResult>(T arg);
-
- internal delegate TResult Func<T1, T2, TResult>(T1 arg1, T2 arg2);
-
- internal delegate void Action<T1, T2>(T1 arg1, T2 arg2);
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index 9361711b..7b7abd8e 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -3,64 +3,60 @@ #pragma warning disable 1591, 0612, 3021 #region Designer generated code -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbd = global::Google.Protobuf.Descriptors; using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.DescriptorProtos { +namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class DescriptorProtoFile { - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - } - #endregion #region Static variables internal static pbd::MessageDescriptor internal__static_google_protobuf_FileDescriptorSet__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorSet, global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorSet.Builder> internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FileDescriptorSet> internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_FileDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto.Builder> internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_DescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Builder> internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.DescriptorProto> internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Builder> internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange> internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange.Builder> internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange> internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_FieldDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder> internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_OneofDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto.Builder> internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto> internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_EnumDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.Builder> internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto.Builder> internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_ServiceDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto.Builder> internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto> internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_MethodDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto.Builder> internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_FileOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.FileOptions, global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Builder> internal__static_google_protobuf_FileOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FileOptions> internal__static_google_protobuf_FileOptions__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_MessageOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions, global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.Builder> internal__static_google_protobuf_MessageOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.MessageOptions> internal__static_google_protobuf_MessageOptions__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_FieldOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions, global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Builder> internal__static_google_protobuf_FieldOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FieldOptions> internal__static_google_protobuf_FieldOptions__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_EnumOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions, global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.Builder> internal__static_google_protobuf_EnumOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumOptions> internal__static_google_protobuf_EnumOptions__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_EnumValueOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions, global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.Builder> internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumValueOptions> internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_ServiceOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions, global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.Builder> internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.ServiceOptions> internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_MethodOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions, global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.Builder> internal__static_google_protobuf_MethodOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.MethodOptions> internal__static_google_protobuf_MethodOptions__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_UninterpretedOption__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder> internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart.Builder> internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_SourceCodeInfo__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo, global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Builder> internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo> internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location, global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location.Builder> internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; #endregion #region Descriptor public static pbd::FileDescriptor Descriptor { @@ -179,102 +175,99 @@ namespace Google.ProtocolBuffers.DescriptorProtos { "LkxvY2F0aW9uGoYBCghMb2NhdGlvbhIQCgRwYXRoGAEgAygFQgIQARIQCgRz", "cGFuGAIgAygFQgIQARIYChBsZWFkaW5nX2NvbW1lbnRzGAMgASgJEhkKEXRy", "YWlsaW5nX2NvbW1lbnRzGAQgASgJEiEKGWxlYWRpbmdfZGV0YWNoZWRfY29t", - "bWVudHMYBiADKAlCWQoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRv", - "clByb3Rvc0gBogIDR1BCqgInR29vZ2xlLlByb3RvY29sQnVmZmVycy5EZXNj", - "cmlwdG9yUHJvdG9z")); + "bWVudHMYBiADKAlCXgoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRv", + "clByb3Rvc0gBWgpkZXNjcmlwdG9yogIDR1BCqgIgR29vZ2xlLlByb3RvYnVm", + "LkRlc2NyaXB0b3JQcm90b3M=")); pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { descriptor = root; internal__static_google_protobuf_FileDescriptorSet__Descriptor = Descriptor.MessageTypes[0]; internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorSet, global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorSet.Builder>(internal__static_google_protobuf_FileDescriptorSet__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FileDescriptorSet>(internal__static_google_protobuf_FileDescriptorSet__Descriptor, new string[] { "File", }); internal__static_google_protobuf_FileDescriptorProto__Descriptor = Descriptor.MessageTypes[1]; internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto.Builder>(internal__static_google_protobuf_FileDescriptorProto__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto>(internal__static_google_protobuf_FileDescriptorProto__Descriptor, new string[] { "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax", }); internal__static_google_protobuf_DescriptorProto__Descriptor = Descriptor.MessageTypes[2]; internal__static_google_protobuf_DescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Builder>(internal__static_google_protobuf_DescriptorProto__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.DescriptorProto>(internal__static_google_protobuf_DescriptorProto__Descriptor, new string[] { "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName", }); internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor = internal__static_google_protobuf_DescriptorProto__Descriptor.NestedTypes[0]; internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Builder>(internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange>(internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor, new string[] { "Start", "End", }); internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor = internal__static_google_protobuf_DescriptorProto__Descriptor.NestedTypes[1]; internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange.Builder>(internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange>(internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor, new string[] { "Start", "End", }); internal__static_google_protobuf_FieldDescriptorProto__Descriptor = Descriptor.MessageTypes[3]; internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder>(internal__static_google_protobuf_FieldDescriptorProto__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto>(internal__static_google_protobuf_FieldDescriptorProto__Descriptor, new string[] { "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "Options", }); internal__static_google_protobuf_OneofDescriptorProto__Descriptor = Descriptor.MessageTypes[4]; internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto.Builder>(internal__static_google_protobuf_OneofDescriptorProto__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto>(internal__static_google_protobuf_OneofDescriptorProto__Descriptor, new string[] { "Name", }); internal__static_google_protobuf_EnumDescriptorProto__Descriptor = Descriptor.MessageTypes[5]; internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.Builder>(internal__static_google_protobuf_EnumDescriptorProto__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto>(internal__static_google_protobuf_EnumDescriptorProto__Descriptor, new string[] { "Name", "Value", "Options", }); internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor = Descriptor.MessageTypes[6]; internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto.Builder>(internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto>(internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor, new string[] { "Name", "Number", "Options", }); internal__static_google_protobuf_ServiceDescriptorProto__Descriptor = Descriptor.MessageTypes[7]; internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto.Builder>(internal__static_google_protobuf_ServiceDescriptorProto__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto>(internal__static_google_protobuf_ServiceDescriptorProto__Descriptor, new string[] { "Name", "Method", "Options", }); internal__static_google_protobuf_MethodDescriptorProto__Descriptor = Descriptor.MessageTypes[8]; internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto, global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto.Builder>(internal__static_google_protobuf_MethodDescriptorProto__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto>(internal__static_google_protobuf_MethodDescriptorProto__Descriptor, new string[] { "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming", }); internal__static_google_protobuf_FileOptions__Descriptor = Descriptor.MessageTypes[9]; internal__static_google_protobuf_FileOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.FileOptions, global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Builder>(internal__static_google_protobuf_FileOptions__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FileOptions>(internal__static_google_protobuf_FileOptions__Descriptor, new string[] { "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption", }); internal__static_google_protobuf_MessageOptions__Descriptor = Descriptor.MessageTypes[10]; internal__static_google_protobuf_MessageOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions, global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.Builder>(internal__static_google_protobuf_MessageOptions__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.MessageOptions>(internal__static_google_protobuf_MessageOptions__Descriptor, new string[] { "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption", }); internal__static_google_protobuf_FieldOptions__Descriptor = Descriptor.MessageTypes[11]; internal__static_google_protobuf_FieldOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions, global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Builder>(internal__static_google_protobuf_FieldOptions__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.FieldOptions>(internal__static_google_protobuf_FieldOptions__Descriptor, new string[] { "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption", }); internal__static_google_protobuf_EnumOptions__Descriptor = Descriptor.MessageTypes[12]; internal__static_google_protobuf_EnumOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions, global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.Builder>(internal__static_google_protobuf_EnumOptions__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumOptions>(internal__static_google_protobuf_EnumOptions__Descriptor, new string[] { "AllowAlias", "Deprecated", "UninterpretedOption", }); internal__static_google_protobuf_EnumValueOptions__Descriptor = Descriptor.MessageTypes[13]; internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions, global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.Builder>(internal__static_google_protobuf_EnumValueOptions__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.EnumValueOptions>(internal__static_google_protobuf_EnumValueOptions__Descriptor, new string[] { "Deprecated", "UninterpretedOption", }); internal__static_google_protobuf_ServiceOptions__Descriptor = Descriptor.MessageTypes[14]; internal__static_google_protobuf_ServiceOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions, global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.Builder>(internal__static_google_protobuf_ServiceOptions__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.ServiceOptions>(internal__static_google_protobuf_ServiceOptions__Descriptor, new string[] { "Deprecated", "UninterpretedOption", }); internal__static_google_protobuf_MethodOptions__Descriptor = Descriptor.MessageTypes[15]; internal__static_google_protobuf_MethodOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions, global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.Builder>(internal__static_google_protobuf_MethodOptions__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.MethodOptions>(internal__static_google_protobuf_MethodOptions__Descriptor, new string[] { "Deprecated", "UninterpretedOption", }); internal__static_google_protobuf_UninterpretedOption__Descriptor = Descriptor.MessageTypes[16]; internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder>(internal__static_google_protobuf_UninterpretedOption__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(internal__static_google_protobuf_UninterpretedOption__Descriptor, new string[] { "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue", }); internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor = internal__static_google_protobuf_UninterpretedOption__Descriptor.NestedTypes[0]; internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart.Builder>(internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart>(internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor, new string[] { "NamePart_", "IsExtension", }); internal__static_google_protobuf_SourceCodeInfo__Descriptor = Descriptor.MessageTypes[17]; internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo, global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Builder>(internal__static_google_protobuf_SourceCodeInfo__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo>(internal__static_google_protobuf_SourceCodeInfo__Descriptor, new string[] { "Location", }); internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor = internal__static_google_protobuf_SourceCodeInfo__Descriptor.NestedTypes[0]; internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location, global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location.Builder>(internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor, + new pb::FieldAccess.FieldAccessorTable<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location>(internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor, new string[] { "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments", }); - pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance(); - RegisterAllExtensions(registry); - return registry; }; pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, new pbd::FileDescriptor[] { @@ -285,10763 +278,4044 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileDescriptorSet : pb::GeneratedMessage<FileDescriptorSet, FileDescriptorSet.Builder> { - private FileDescriptorSet() { } - private static readonly FileDescriptorSet defaultInstance = new FileDescriptorSet().MakeReadOnly(); - private static readonly string[] _fileDescriptorSetFieldNames = new string[] { "file" }; - private static readonly uint[] _fileDescriptorSetFieldTags = new uint[] { 10 }; - public static FileDescriptorSet DefaultInstance { - get { return defaultInstance; } - } - - public override FileDescriptorSet DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FileDescriptorSet ThisMessage { - get { return this; } - } + public sealed partial class FileDescriptorSet : pb::IMessage<FileDescriptorSet>, global::System.IEquatable<FileDescriptorSet> { + private static readonly pb::MessageParser<FileDescriptorSet> _parser = new pb::MessageParser<FileDescriptorSet>(() => new FileDescriptorSet()); + public static pb::MessageParser<FileDescriptorSet> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "file" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<FileDescriptorSet, FileDescriptorSet.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<FileDescriptorSet> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; } } + public FileDescriptorSet() { } + public FileDescriptorSet(FileDescriptorSet other) { + MergeFrom(other); + } public const int FileFieldNumber = 1; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto> file_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto> FileList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> file_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> File { get { return file_; } } - public int FileCount { - get { return file_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto GetFile(int index) { - return file_[index]; + + public override bool Equals(object other) { + return Equals(other as FileDescriptorSet); } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto element in FileList) { - if (!element.IsInitialized) return false; - } + public bool Equals(FileDescriptorSet other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { return true; } + if(!file_.Equals(other.file_)) return false; + return true; } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fileDescriptorSetFieldNames; - if (file_.Count > 0) { - output.WriteMessageArray(1, field_names[0], file_); - } - UnknownFields.WriteTo(output); + public override int GetHashCode() { + int hash = 0; + hash ^= file_.GetHashCode(); + return hash; } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); + public void WriteTo(pb::CodedOutputStream output) { + if (file_.Count > 0) { + output.WriteMessageArray(1, file_); } } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto element in FileList) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); + public int CalculateSize() { + int size = 0; + if (file_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.FileDescriptorProto element in file_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); + } + size += 1 * file_.Count; } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; return size; } - public static FileDescriptorSet ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FileDescriptorSet ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FileDescriptorSet ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FileDescriptorSet ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FileDescriptorSet ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FileDescriptorSet ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FileDescriptorSet ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FileDescriptorSet ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FileDescriptorSet ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FileDescriptorSet ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FileDescriptorSet MakeReadOnly() { - file_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FileDescriptorSet prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<FileDescriptorSet, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FileDescriptorSet cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FileDescriptorSet result; - - private FileDescriptorSet PrepareBuilder() { - if (resultIsReadOnly) { - FileDescriptorSet original = result; - result = new FileDescriptorSet(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FileDescriptorSet MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorSet.Descriptor; } - } - - public override FileDescriptorSet DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorSet.DefaultInstance; } - } - - public override FileDescriptorSet BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FileDescriptorSet) { - return MergeFrom((FileDescriptorSet) other); - } else { - base.MergeFrom(other); - return this; - } + public void MergeFrom(FileDescriptorSet other) { + if (other == null) { + return; } + file_.Add(other.file_); + } - public override Builder MergeFrom(FileDescriptorSet other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorSet.DefaultInstance) return this; - PrepareBuilder(); - if (other.file_.Count != 0) { - result.file_.Add(other.file_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fileDescriptorSetFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fileDescriptorSetFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - input.ReadMessageArray(tag, field_name, result.file_, global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto.DefaultInstance, extensionRegistry); - break; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 10: { + input.ReadMessageArray(file_, global::Google.Protobuf.DescriptorProtos.FileDescriptorProto.Parser); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto> FileList { - get { return PrepareBuilder().file_; } - } - public int FileCount { - get { return result.FileCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto GetFile(int index) { - return result.GetFile(index); - } - public Builder SetFile(int index, global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.file_[index] = value; - return this; - } - public Builder SetFile(int index, global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.file_[index] = builderForValue.Build(); - return this; - } - public Builder AddFile(global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.file_.Add(value); - return this; - } - public Builder AddFile(global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.file_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeFile(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto> values) { - PrepareBuilder(); - result.file_.Add(values); - return this; - } - public Builder ClearFile() { - PrepareBuilder(); - result.file_.Clear(); - return this; } } - static FileDescriptorSet() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); - } + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileDescriptorProto : pb::GeneratedMessage<FileDescriptorProto, FileDescriptorProto.Builder> { - private FileDescriptorProto() { } - private static readonly FileDescriptorProto defaultInstance = new FileDescriptorProto().MakeReadOnly(); - private static readonly string[] _fileDescriptorProtoFieldNames = new string[] { "dependency", "enum_type", "extension", "message_type", "name", "options", "package", "public_dependency", "service", "source_code_info", "syntax", "weak_dependency" }; - private static readonly uint[] _fileDescriptorProtoFieldTags = new uint[] { 26, 42, 58, 34, 10, 66, 18, 80, 50, 74, 98, 88 }; - public static FileDescriptorProto DefaultInstance { - get { return defaultInstance; } - } - - public override FileDescriptorProto DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FileDescriptorProto ThisMessage { - get { return this; } - } + public sealed partial class FileDescriptorProto : pb::IMessage<FileDescriptorProto>, global::System.IEquatable<FileDescriptorProto> { + private static readonly pb::MessageParser<FileDescriptorProto> _parser = new pb::MessageParser<FileDescriptorProto>(() => new FileDescriptorProto()); + public static pb::MessageParser<FileDescriptorProto> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "dependency", "enum_type", "extension", "message_type", "name", "options", "package", "public_dependency", "service", "source_code_info", "syntax", "weak_dependency" }; + private static readonly uint[] _fieldTags = new uint[] { 26, 42, 58, 34, 10, 66, 18, 80, 50, 74, 98, 88 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<FileDescriptorProto, FileDescriptorProto.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<FileDescriptorProto> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; } } + public FileDescriptorProto() { } + public FileDescriptorProto(FileDescriptorProto other) { + MergeFrom(other); + } public const int NameFieldNumber = 1; - private bool hasName; private string name_ = ""; - public bool HasName { - get { return hasName; } - } public string Name { get { return name_; } + set { name_ = value ?? ""; } } + public const int PackageFieldNumber = 2; - private bool hasPackage; private string package_ = ""; - public bool HasPackage { - get { return hasPackage; } - } public string Package { get { return package_; } + set { package_ = value ?? ""; } } + public const int DependencyFieldNumber = 3; - private pbc::PopsicleList<string> dependency_ = new pbc::PopsicleList<string>(); - public scg::IList<string> DependencyList { - get { return pbc::Lists.AsReadOnly(dependency_); } - } - public int DependencyCount { - get { return dependency_.Count; } - } - public string GetDependency(int index) { - return dependency_[index]; + private readonly pbc::RepeatedField<string> dependency_ = new pbc::RepeatedField<string>(); + public pbc::RepeatedField<string> Dependency { + get { return dependency_; } } public const int PublicDependencyFieldNumber = 10; - private pbc::PopsicleList<int> publicDependency_ = new pbc::PopsicleList<int>(); - public scg::IList<int> PublicDependencyList { - get { return pbc::Lists.AsReadOnly(publicDependency_); } - } - public int PublicDependencyCount { - get { return publicDependency_.Count; } - } - public int GetPublicDependency(int index) { - return publicDependency_[index]; + private readonly pbc::RepeatedField<int> publicDependency_ = new pbc::RepeatedField<int>(); + public pbc::RepeatedField<int> PublicDependency { + get { return publicDependency_; } } public const int WeakDependencyFieldNumber = 11; - private pbc::PopsicleList<int> weakDependency_ = new pbc::PopsicleList<int>(); - public scg::IList<int> WeakDependencyList { - get { return pbc::Lists.AsReadOnly(weakDependency_); } - } - public int WeakDependencyCount { - get { return weakDependency_.Count; } - } - public int GetWeakDependency(int index) { - return weakDependency_[index]; + private readonly pbc::RepeatedField<int> weakDependency_ = new pbc::RepeatedField<int>(); + public pbc::RepeatedField<int> WeakDependency { + get { return weakDependency_; } } public const int MessageTypeFieldNumber = 4; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> messageType_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> MessageTypeList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> messageType_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> MessageType { get { return messageType_; } } - public int MessageTypeCount { - get { return messageType_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto GetMessageType(int index) { - return messageType_[index]; - } public const int EnumTypeFieldNumber = 5; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> enumType_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> EnumTypeList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> enumType_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> EnumType { get { return enumType_; } } - public int EnumTypeCount { - get { return enumType_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto GetEnumType(int index) { - return enumType_[index]; - } public const int ServiceFieldNumber = 6; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto> service_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto> ServiceList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto> service_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto> Service { get { return service_; } } - public int ServiceCount { - get { return service_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto GetService(int index) { - return service_[index]; - } public const int ExtensionFieldNumber = 7; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> extension_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> ExtensionList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> extension_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Extension { get { return extension_; } } - public int ExtensionCount { - get { return extension_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto GetExtension(int index) { - return extension_[index]; - } public const int OptionsFieldNumber = 8; - private bool hasOptions; - private global::Google.ProtocolBuffers.DescriptorProtos.FileOptions options_; - public bool HasOptions { - get { return hasOptions; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FileOptions Options { - get { return options_ ?? global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.DefaultInstance; } + private global::Google.Protobuf.DescriptorProtos.FileOptions options_; + public global::Google.Protobuf.DescriptorProtos.FileOptions Options { + get { return options_; } + set { options_ = value; } } public const int SourceCodeInfoFieldNumber = 9; - private bool hasSourceCodeInfo; - private global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo sourceCodeInfo_; - public bool HasSourceCodeInfo { - get { return hasSourceCodeInfo; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo SourceCodeInfo { - get { return sourceCodeInfo_ ?? global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.DefaultInstance; } + private global::Google.Protobuf.DescriptorProtos.SourceCodeInfo sourceCodeInfo_; + public global::Google.Protobuf.DescriptorProtos.SourceCodeInfo SourceCodeInfo { + get { return sourceCodeInfo_; } + set { sourceCodeInfo_ = value; } } public const int SyntaxFieldNumber = 12; - private bool hasSyntax; private string syntax_ = ""; - public bool HasSyntax { - get { return hasSyntax; } - } public string Syntax { get { return syntax_; } + set { syntax_ = value ?? ""; } } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto element in MessageTypeList) { - if (!element.IsInitialized) return false; - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto element in EnumTypeList) { - if (!element.IsInitialized) return false; - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto element in ServiceList) { - if (!element.IsInitialized) return false; - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto element in ExtensionList) { - if (!element.IsInitialized) return false; - } - if (HasOptions) { - if (!Options.IsInitialized) return false; - } - return true; - } + + public override bool Equals(object other) { + return Equals(other as FileDescriptorProto); } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fileDescriptorProtoFieldNames; - if (hasName) { - output.WriteString(1, field_names[4], Name); + public bool Equals(FileDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; } - if (hasPackage) { - output.WriteString(2, field_names[6], Package); + if (Name != other.Name) return false; + if (Package != other.Package) return false; + if(!dependency_.Equals(other.dependency_)) return false; + if(!publicDependency_.Equals(other.publicDependency_)) return false; + if(!weakDependency_.Equals(other.weakDependency_)) return false; + if(!messageType_.Equals(other.messageType_)) return false; + if(!enumType_.Equals(other.enumType_)) return false; + if(!service_.Equals(other.service_)) return false; + if(!extension_.Equals(other.extension_)) return false; + if (!object.Equals(Options, other.Options)) return false;if (!object.Equals(SourceCodeInfo, other.SourceCodeInfo)) return false;if (Syntax != other.Syntax) return false; + return true; + } + + public override int GetHashCode() { + int hash = 0; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (Package.Length != 0) hash ^= Package.GetHashCode(); + hash ^= dependency_.GetHashCode(); + hash ^= publicDependency_.GetHashCode(); + hash ^= weakDependency_.GetHashCode(); + hash ^= messageType_.GetHashCode(); + hash ^= enumType_.GetHashCode(); + hash ^= service_.GetHashCode(); + hash ^= extension_.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + if (sourceCodeInfo_ != null) hash ^= SourceCodeInfo.GetHashCode(); + if (Syntax.Length != 0) hash ^= Syntax.GetHashCode(); + return hash; + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (Package.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Package); } if (dependency_.Count > 0) { - output.WriteStringArray(3, field_names[0], dependency_); + output.WriteStringArray(3, dependency_); } if (messageType_.Count > 0) { - output.WriteMessageArray(4, field_names[3], messageType_); + output.WriteMessageArray(4, messageType_); } if (enumType_.Count > 0) { - output.WriteMessageArray(5, field_names[1], enumType_); + output.WriteMessageArray(5, enumType_); } if (service_.Count > 0) { - output.WriteMessageArray(6, field_names[8], service_); + output.WriteMessageArray(6, service_); } if (extension_.Count > 0) { - output.WriteMessageArray(7, field_names[2], extension_); + output.WriteMessageArray(7, extension_); } - if (hasOptions) { - output.WriteMessage(8, field_names[5], Options); + if (options_ != null) { + output.WriteRawTag(66); + output.WriteMessage(Options); } - if (hasSourceCodeInfo) { - output.WriteMessage(9, field_names[9], SourceCodeInfo); + if (sourceCodeInfo_ != null) { + output.WriteRawTag(74); + output.WriteMessage(SourceCodeInfo); } if (publicDependency_.Count > 0) { - output.WriteInt32Array(10, field_names[7], publicDependency_); + output.WriteInt32Array(10, publicDependency_); } if (weakDependency_.Count > 0) { - output.WriteInt32Array(11, field_names[11], weakDependency_); + output.WriteInt32Array(11, weakDependency_); } - if (hasSyntax) { - output.WriteString(12, field_names[10], Syntax); + if (Syntax.Length != 0) { + output.WriteRawTag(98); + output.WriteString(Syntax); } - UnknownFields.WriteTo(output); } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); - } - if (hasPackage) { - size += pb::CodedOutputStream.ComputeStringSize(2, Package); + if (Package.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Package); } - { + if (dependency_.Count > 0) { int dataSize = 0; - foreach (string element in DependencyList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + foreach (string element in dependency_) { + dataSize += pb::CodedOutputStream.ComputeStringSize(element); } size += dataSize; size += 1 * dependency_.Count; } - { + if (publicDependency_.Count > 0) { int dataSize = 0; - foreach (int element in PublicDependencyList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + foreach (int element in publicDependency_) { + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; size += 1 * publicDependency_.Count; } - { + if (weakDependency_.Count > 0) { int dataSize = 0; - foreach (int element in WeakDependencyList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + foreach (int element in weakDependency_) { + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; size += 1 * weakDependency_.Count; } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto element in MessageTypeList) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto element in EnumTypeList) { - size += pb::CodedOutputStream.ComputeMessageSize(5, element); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto element in ServiceList) { - size += pb::CodedOutputStream.ComputeMessageSize(6, element); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto element in ExtensionList) { - size += pb::CodedOutputStream.ComputeMessageSize(7, element); - } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(8, Options); - } - if (hasSourceCodeInfo) { - size += pb::CodedOutputStream.ComputeMessageSize(9, SourceCodeInfo); - } - if (hasSyntax) { - size += pb::CodedOutputStream.ComputeStringSize(12, Syntax); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FileDescriptorProto ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FileDescriptorProto ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FileDescriptorProto ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FileDescriptorProto ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FileDescriptorProto ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FileDescriptorProto ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FileDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FileDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FileDescriptorProto ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FileDescriptorProto ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FileDescriptorProto MakeReadOnly() { - dependency_.MakeReadOnly(); - publicDependency_.MakeReadOnly(); - weakDependency_.MakeReadOnly(); - messageType_.MakeReadOnly(); - enumType_.MakeReadOnly(); - service_.MakeReadOnly(); - extension_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FileDescriptorProto prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<FileDescriptorProto, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FileDescriptorProto cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FileDescriptorProto result; - - private FileDescriptorProto PrepareBuilder() { - if (resultIsReadOnly) { - FileDescriptorProto original = result; - result = new FileDescriptorProto(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FileDescriptorProto MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); + if (messageType_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto element in messageType_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * messageType_.Count; } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto.Descriptor; } - } - - public override FileDescriptorProto DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto.DefaultInstance; } - } - - public override FileDescriptorProto BuildPartial() { - if (resultIsReadOnly) { - return result; + if (enumType_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto element in enumType_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); } - resultIsReadOnly = true; - return result.MakeReadOnly(); + size += 1 * enumType_.Count; } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FileDescriptorProto) { - return MergeFrom((FileDescriptorProto) other); - } else { - base.MergeFrom(other); - return this; + if (service_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto element in service_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * service_.Count; } - - public override Builder MergeFrom(FileDescriptorProto other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasName) { - Name = other.Name; - } - if (other.HasPackage) { - Package = other.Package; - } - if (other.dependency_.Count != 0) { - result.dependency_.Add(other.dependency_); - } - if (other.publicDependency_.Count != 0) { - result.publicDependency_.Add(other.publicDependency_); - } - if (other.weakDependency_.Count != 0) { - result.weakDependency_.Add(other.weakDependency_); - } - if (other.messageType_.Count != 0) { - result.messageType_.Add(other.messageType_); - } - if (other.enumType_.Count != 0) { - result.enumType_.Add(other.enumType_); - } - if (other.service_.Count != 0) { - result.service_.Add(other.service_); - } - if (other.extension_.Count != 0) { - result.extension_.Add(other.extension_); - } - if (other.HasOptions) { - MergeOptions(other.Options); - } - if (other.HasSourceCodeInfo) { - MergeSourceCodeInfo(other.SourceCodeInfo); - } - if (other.HasSyntax) { - Syntax = other.Syntax; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fileDescriptorProtoFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fileDescriptorProtoFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasName = input.ReadString(ref result.name_); - break; - } - case 18: { - result.hasPackage = input.ReadString(ref result.package_); - break; - } - case 26: { - input.ReadStringArray(tag, field_name, result.dependency_); - break; - } - case 34: { - input.ReadMessageArray(tag, field_name, result.messageType_, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.DefaultInstance, extensionRegistry); - break; - } - case 42: { - input.ReadMessageArray(tag, field_name, result.enumType_, global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.DefaultInstance, extensionRegistry); - break; - } - case 50: { - input.ReadMessageArray(tag, field_name, result.service_, global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto.DefaultInstance, extensionRegistry); - break; - } - case 58: { - input.ReadMessageArray(tag, field_name, result.extension_, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.DefaultInstance, extensionRegistry); - break; - } - case 66: { - global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Builder subBuilder = global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.CreateBuilder(); - if (result.hasOptions) { - subBuilder.MergeFrom(Options); - } - input.ReadMessage(subBuilder, extensionRegistry); - Options = subBuilder.BuildPartial(); - break; - } - case 74: { - global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Builder subBuilder = global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.CreateBuilder(); - if (result.hasSourceCodeInfo) { - subBuilder.MergeFrom(SourceCodeInfo); - } - input.ReadMessage(subBuilder, extensionRegistry); - SourceCodeInfo = subBuilder.BuildPartial(); - break; - } - case 82: - case 80: { - input.ReadInt32Array(tag, field_name, result.publicDependency_); - break; - } - case 90: - case 88: { - input.ReadInt32Array(tag, field_name, result.weakDependency_); - break; - } - case 98: { - result.hasSyntax = input.ReadString(ref result.syntax_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); + if (extension_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in extension_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); } - return this; - } - - - public bool HasName { - get { return result.hasName; } - } - public string Name { - get { return result.Name; } - set { SetName(value); } - } - public Builder SetName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasName = true; - result.name_ = value; - return this; - } - public Builder ClearName() { - PrepareBuilder(); - result.hasName = false; - result.name_ = ""; - return this; - } - - public bool HasPackage { - get { return result.hasPackage; } - } - public string Package { - get { return result.Package; } - set { SetPackage(value); } - } - public Builder SetPackage(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasPackage = true; - result.package_ = value; - return this; + size += 1 * extension_.Count; } - public Builder ClearPackage() { - PrepareBuilder(); - result.hasPackage = false; - result.package_ = ""; - return this; + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } - - public pbc::IPopsicleList<string> DependencyList { - get { return PrepareBuilder().dependency_; } - } - public int DependencyCount { - get { return result.DependencyCount; } - } - public string GetDependency(int index) { - return result.GetDependency(index); - } - public Builder SetDependency(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.dependency_[index] = value; - return this; - } - public Builder AddDependency(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.dependency_.Add(value); - return this; - } - public Builder AddRangeDependency(scg::IEnumerable<string> values) { - PrepareBuilder(); - result.dependency_.Add(values); - return this; - } - public Builder ClearDependency() { - PrepareBuilder(); - result.dependency_.Clear(); - return this; - } - - public pbc::IPopsicleList<int> PublicDependencyList { - get { return PrepareBuilder().publicDependency_; } - } - public int PublicDependencyCount { - get { return result.PublicDependencyCount; } + if (sourceCodeInfo_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceCodeInfo); } - public int GetPublicDependency(int index) { - return result.GetPublicDependency(index); + if (Syntax.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Syntax); } - public Builder SetPublicDependency(int index, int value) { - PrepareBuilder(); - result.publicDependency_[index] = value; - return this; - } - public Builder AddPublicDependency(int value) { - PrepareBuilder(); - result.publicDependency_.Add(value); - return this; - } - public Builder AddRangePublicDependency(scg::IEnumerable<int> values) { - PrepareBuilder(); - result.publicDependency_.Add(values); - return this; - } - public Builder ClearPublicDependency() { - PrepareBuilder(); - result.publicDependency_.Clear(); - return this; - } - - public pbc::IPopsicleList<int> WeakDependencyList { - get { return PrepareBuilder().weakDependency_; } - } - public int WeakDependencyCount { - get { return result.WeakDependencyCount; } - } - public int GetWeakDependency(int index) { - return result.GetWeakDependency(index); - } - public Builder SetWeakDependency(int index, int value) { - PrepareBuilder(); - result.weakDependency_[index] = value; - return this; - } - public Builder AddWeakDependency(int value) { - PrepareBuilder(); - result.weakDependency_.Add(value); - return this; - } - public Builder AddRangeWeakDependency(scg::IEnumerable<int> values) { - PrepareBuilder(); - result.weakDependency_.Add(values); - return this; - } - public Builder ClearWeakDependency() { - PrepareBuilder(); - result.weakDependency_.Clear(); - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> MessageTypeList { - get { return PrepareBuilder().messageType_; } + return size; + } + public void MergeFrom(FileDescriptorProto other) { + if (other == null) { + return; } - public int MessageTypeCount { - get { return result.MessageTypeCount; } + if (other.Name.Length != 0) { + Name = other.Name; } - public global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto GetMessageType(int index) { - return result.GetMessageType(index); - } - public Builder SetMessageType(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.messageType_[index] = value; - return this; - } - public Builder SetMessageType(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.messageType_[index] = builderForValue.Build(); - return this; - } - public Builder AddMessageType(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.messageType_.Add(value); - return this; - } - public Builder AddMessageType(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.messageType_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeMessageType(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> values) { - PrepareBuilder(); - result.messageType_.Add(values); - return this; + if (other.Package.Length != 0) { + Package = other.Package; } - public Builder ClearMessageType() { - PrepareBuilder(); - result.messageType_.Clear(); - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> EnumTypeList { - get { return PrepareBuilder().enumType_; } - } - public int EnumTypeCount { - get { return result.EnumTypeCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto GetEnumType(int index) { - return result.GetEnumType(index); - } - public Builder SetEnumType(int index, global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.enumType_[index] = value; - return this; - } - public Builder SetEnumType(int index, global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.enumType_[index] = builderForValue.Build(); - return this; - } - public Builder AddEnumType(global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.enumType_.Add(value); - return this; - } - public Builder AddEnumType(global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.enumType_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeEnumType(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> values) { - PrepareBuilder(); - result.enumType_.Add(values); - return this; - } - public Builder ClearEnumType() { - PrepareBuilder(); - result.enumType_.Clear(); - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto> ServiceList { - get { return PrepareBuilder().service_; } - } - public int ServiceCount { - get { return result.ServiceCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto GetService(int index) { - return result.GetService(index); - } - public Builder SetService(int index, global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.service_[index] = value; - return this; - } - public Builder SetService(int index, global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.service_[index] = builderForValue.Build(); - return this; - } - public Builder AddService(global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.service_.Add(value); - return this; - } - public Builder AddService(global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.service_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeService(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto> values) { - PrepareBuilder(); - result.service_.Add(values); - return this; - } - public Builder ClearService() { - PrepareBuilder(); - result.service_.Clear(); - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> ExtensionList { - get { return PrepareBuilder().extension_; } - } - public int ExtensionCount { - get { return result.ExtensionCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto GetExtension(int index) { - return result.GetExtension(index); - } - public Builder SetExtension(int index, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.extension_[index] = value; - return this; - } - public Builder SetExtension(int index, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.extension_[index] = builderForValue.Build(); - return this; - } - public Builder AddExtension(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.extension_.Add(value); - return this; - } - public Builder AddExtension(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.extension_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeExtension(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> values) { - PrepareBuilder(); - result.extension_.Add(values); - return this; - } - public Builder ClearExtension() { - PrepareBuilder(); - result.extension_.Clear(); - return this; - } - - public bool HasOptions { - get { return result.hasOptions; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FileOptions Options { - get { return result.Options; } - set { SetOptions(value); } - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.FileOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = value; - return this; - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = builderForValue.Build(); - return this; - } - public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.FileOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptions && - result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.DefaultInstance) { - result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); - } else { - result.options_ = value; + dependency_.Add(other.dependency_); + publicDependency_.Add(other.publicDependency_); + weakDependency_.Add(other.weakDependency_); + messageType_.Add(other.messageType_); + enumType_.Add(other.enumType_); + service_.Add(other.service_); + extension_.Add(other.extension_); + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.FileOptions(); } - result.hasOptions = true; - return this; - } - public Builder ClearOptions() { - PrepareBuilder(); - result.hasOptions = false; - result.options_ = null; - return this; - } - - public bool HasSourceCodeInfo { - get { return result.hasSourceCodeInfo; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo SourceCodeInfo { - get { return result.SourceCodeInfo; } - set { SetSourceCodeInfo(value); } - } - public Builder SetSourceCodeInfo(global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasSourceCodeInfo = true; - result.sourceCodeInfo_ = value; - return this; - } - public Builder SetSourceCodeInfo(global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasSourceCodeInfo = true; - result.sourceCodeInfo_ = builderForValue.Build(); - return this; - } - public Builder MergeSourceCodeInfo(global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasSourceCodeInfo && - result.sourceCodeInfo_ != global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.DefaultInstance) { - result.sourceCodeInfo_ = global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.CreateBuilder(result.sourceCodeInfo_).MergeFrom(value).BuildPartial(); - } else { - result.sourceCodeInfo_ = value; - } - result.hasSourceCodeInfo = true; - return this; - } - public Builder ClearSourceCodeInfo() { - PrepareBuilder(); - result.hasSourceCodeInfo = false; - result.sourceCodeInfo_ = null; - return this; + Options.MergeFrom(other.Options); } - - public bool HasSyntax { - get { return result.hasSyntax; } - } - public string Syntax { - get { return result.Syntax; } - set { SetSyntax(value); } - } - public Builder SetSyntax(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasSyntax = true; - result.syntax_ = value; - return this; + if (other.sourceCodeInfo_ != null) { + if (sourceCodeInfo_ == null) { + sourceCodeInfo_ = new global::Google.Protobuf.DescriptorProtos.SourceCodeInfo(); + } + SourceCodeInfo.MergeFrom(other.SourceCodeInfo); } - public Builder ClearSyntax() { - PrepareBuilder(); - result.hasSyntax = false; - result.syntax_ = ""; - return this; + if (other.Syntax.Length != 0) { + Syntax = other.Syntax; } } - static FileDescriptorProto() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DescriptorProto : pb::GeneratedMessage<DescriptorProto, DescriptorProto.Builder> { - private DescriptorProto() { } - private static readonly DescriptorProto defaultInstance = new DescriptorProto().MakeReadOnly(); - private static readonly string[] _descriptorProtoFieldNames = new string[] { "enum_type", "extension", "extension_range", "field", "name", "nested_type", "oneof_decl", "options", "reserved_name", "reserved_range" }; - private static readonly uint[] _descriptorProtoFieldTags = new uint[] { 34, 50, 42, 18, 10, 26, 66, 58, 82, 74 }; - public static DescriptorProto DefaultInstance { - get { return defaultInstance; } - } - - public override DescriptorProto DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override DescriptorProto ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable<DescriptorProto, DescriptorProto.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ExtensionRange : pb::GeneratedMessage<ExtensionRange, ExtensionRange.Builder> { - private ExtensionRange() { } - private static readonly ExtensionRange defaultInstance = new ExtensionRange().MakeReadOnly(); - private static readonly string[] _extensionRangeFieldNames = new string[] { "end", "start" }; - private static readonly uint[] _extensionRangeFieldTags = new uint[] { 16, 8 }; - public static ExtensionRange DefaultInstance { - get { return defaultInstance; } - } - - public override ExtensionRange DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override ExtensionRange ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable<ExtensionRange, ExtensionRange.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; } - } - - public const int StartFieldNumber = 1; - private bool hasStart; - private int start_; - public bool HasStart { - get { return hasStart; } - } - public int Start { - get { return start_; } - } - - public const int EndFieldNumber = 2; - private bool hasEnd; - private int end_; - public bool HasEnd { - get { return hasEnd; } - } - public int End { - get { return end_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _extensionRangeFieldNames; - if (hasStart) { - output.WriteInt32(1, field_names[1], Start); - } - if (hasEnd) { - output.WriteInt32(2, field_names[0], End); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasStart) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Start); - } - if (hasEnd) { - size += pb::CodedOutputStream.ComputeInt32Size(2, End); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static ExtensionRange ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ExtensionRange ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ExtensionRange ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ExtensionRange ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ExtensionRange ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ExtensionRange ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static ExtensionRange ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static ExtensionRange ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static ExtensionRange ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ExtensionRange ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private ExtensionRange MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(ExtensionRange prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<ExtensionRange, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(ExtensionRange cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - private bool resultIsReadOnly; - private ExtensionRange result; - - private ExtensionRange PrepareBuilder() { - if (resultIsReadOnly) { - ExtensionRange original = result; - result = new ExtensionRange(); - resultIsReadOnly = false; - MergeFrom(original); + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } - return result; + break; + case 10: { + Name = input.ReadString(); + break; } - - public override bool IsInitialized { - get { return result.IsInitialized; } + case 18: { + Package = input.ReadString(); + break; } - - protected override ExtensionRange MessageBeingBuilt { - get { return PrepareBuilder(); } + case 26: { + input.ReadStringArray(dependency_); + break; } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; + case 34: { + input.ReadMessageArray(messageType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); + break; } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } + case 42: { + input.ReadMessageArray(enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); + break; } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Descriptor; } + case 50: { + input.ReadMessageArray(service_, global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto.Parser); + break; } - - public override ExtensionRange DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange.DefaultInstance; } + case 58: { + input.ReadMessageArray(extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); + break; } - - public override ExtensionRange BuildPartial() { - if (resultIsReadOnly) { - return result; + case 66: { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.FileOptions(); } - resultIsReadOnly = true; - return result.MakeReadOnly(); + input.ReadMessage(options_); + break; } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is ExtensionRange) { - return MergeFrom((ExtensionRange) other); - } else { - base.MergeFrom(other); - return this; + case 74: { + if (sourceCodeInfo_ == null) { + sourceCodeInfo_ = new global::Google.Protobuf.DescriptorProtos.SourceCodeInfo(); } + input.ReadMessage(sourceCodeInfo_); + break; } - - public override Builder MergeFrom(ExtensionRange other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasStart) { - Start = other.Start; - } - if (other.HasEnd) { - End = other.End; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_extensionRangeFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _extensionRangeFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasStart = input.ReadInt32(ref result.start_); - break; - } - case 16: { - result.hasEnd = input.ReadInt32(ref result.end_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasStart { - get { return result.hasStart; } - } - public int Start { - get { return result.Start; } - set { SetStart(value); } - } - public Builder SetStart(int value) { - PrepareBuilder(); - result.hasStart = true; - result.start_ = value; - return this; - } - public Builder ClearStart() { - PrepareBuilder(); - result.hasStart = false; - result.start_ = 0; - return this; - } - - public bool HasEnd { - get { return result.hasEnd; } + case 82: + case 80: { + input.ReadInt32Array(publicDependency_); + break; } - public int End { - get { return result.End; } - set { SetEnd(value); } + case 90: + case 88: { + input.ReadInt32Array(weakDependency_); + break; } - public Builder SetEnd(int value) { - PrepareBuilder(); - result.hasEnd = true; - result.end_ = value; - return this; + case 98: { + Syntax = input.ReadString(); + break; } - public Builder ClearEnd() { - PrepareBuilder(); - result.hasEnd = false; - result.end_ = 0; - return this; - } - } - static ExtensionRange() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); } } + } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ReservedRange : pb::GeneratedMessage<ReservedRange, ReservedRange.Builder> { - private ReservedRange() { } - private static readonly ReservedRange defaultInstance = new ReservedRange().MakeReadOnly(); - private static readonly string[] _reservedRangeFieldNames = new string[] { "end", "start" }; - private static readonly uint[] _reservedRangeFieldTags = new uint[] { 16, 8 }; - public static ReservedRange DefaultInstance { - get { return defaultInstance; } - } - - public override ReservedRange DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override ReservedRange ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable<ReservedRange, ReservedRange.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; } - } - - public const int StartFieldNumber = 1; - private bool hasStart; - private int start_; - public bool HasStart { - get { return hasStart; } - } - public int Start { - get { return start_; } - } - - public const int EndFieldNumber = 2; - private bool hasEnd; - private int end_; - public bool HasEnd { - get { return hasEnd; } - } - public int End { - get { return end_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _reservedRangeFieldNames; - if (hasStart) { - output.WriteInt32(1, field_names[1], Start); - } - if (hasEnd) { - output.WriteInt32(2, field_names[0], End); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasStart) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Start); - } - if (hasEnd) { - size += pb::CodedOutputStream.ComputeInt32Size(2, End); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static ReservedRange ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ReservedRange ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ReservedRange ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ReservedRange ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ReservedRange ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ReservedRange ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static ReservedRange ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static ReservedRange ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static ReservedRange ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ReservedRange ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private ReservedRange MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(ReservedRange prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<ReservedRange, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(ReservedRange cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private ReservedRange result; - - private ReservedRange PrepareBuilder() { - if (resultIsReadOnly) { - ReservedRange original = result; - result = new ReservedRange(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override ReservedRange MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange.Descriptor; } - } - - public override ReservedRange DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange.DefaultInstance; } - } - - public override ReservedRange BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is ReservedRange) { - return MergeFrom((ReservedRange) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(ReservedRange other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasStart) { - Start = other.Start; - } - if (other.HasEnd) { - End = other.End; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_reservedRangeFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _reservedRangeFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasStart = input.ReadInt32(ref result.start_); - break; - } - case 16: { - result.hasEnd = input.ReadInt32(ref result.end_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - + } - public bool HasStart { - get { return result.hasStart; } - } - public int Start { - get { return result.Start; } - set { SetStart(value); } - } - public Builder SetStart(int value) { - PrepareBuilder(); - result.hasStart = true; - result.start_ = value; - return this; - } - public Builder ClearStart() { - PrepareBuilder(); - result.hasStart = false; - result.start_ = 0; - return this; - } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class DescriptorProto : pb::IMessage<DescriptorProto>, global::System.IEquatable<DescriptorProto> { + private static readonly pb::MessageParser<DescriptorProto> _parser = new pb::MessageParser<DescriptorProto>(() => new DescriptorProto()); + public static pb::MessageParser<DescriptorProto> Parser { get { return _parser; } } - public bool HasEnd { - get { return result.hasEnd; } - } - public int End { - get { return result.End; } - set { SetEnd(value); } - } - public Builder SetEnd(int value) { - PrepareBuilder(); - result.hasEnd = true; - result.end_ = value; - return this; - } - public Builder ClearEnd() { - PrepareBuilder(); - result.hasEnd = false; - result.end_ = 0; - return this; - } - } - static ReservedRange() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); - } - } + private static readonly string[] _fieldNames = new string[] { "enum_type", "extension", "extension_range", "field", "name", "nested_type", "oneof_decl", "options", "reserved_name", "reserved_range" }; + private static readonly uint[] _fieldTags = new uint[] { 34, 50, 42, 18, 10, 26, 66, 58, 82, 74 }; + public static pbd::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__Descriptor; } + } + public pb::FieldAccess.FieldAccessorTable<DescriptorProto> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; } } - #endregion + public DescriptorProto() { } + public DescriptorProto(DescriptorProto other) { + MergeFrom(other); + } public const int NameFieldNumber = 1; - private bool hasName; private string name_ = ""; - public bool HasName { - get { return hasName; } - } public string Name { get { return name_; } + set { name_ = value ?? ""; } } + public const int FieldFieldNumber = 2; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> field_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> FieldList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> field_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Field { get { return field_; } } - public int FieldCount { - get { return field_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto GetField(int index) { - return field_[index]; - } public const int ExtensionFieldNumber = 6; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> extension_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> ExtensionList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> extension_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Extension { get { return extension_; } } - public int ExtensionCount { - get { return extension_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto GetExtension(int index) { - return extension_[index]; - } public const int NestedTypeFieldNumber = 3; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> nestedType_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> NestedTypeList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> nestedType_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> NestedType { get { return nestedType_; } } - public int NestedTypeCount { - get { return nestedType_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto GetNestedType(int index) { - return nestedType_[index]; - } public const int EnumTypeFieldNumber = 4; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> enumType_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> EnumTypeList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> enumType_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> EnumType { get { return enumType_; } } - public int EnumTypeCount { - get { return enumType_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto GetEnumType(int index) { - return enumType_[index]; - } public const int ExtensionRangeFieldNumber = 5; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange> extensionRange_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange> ExtensionRangeList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange> extensionRange_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange> ExtensionRange { get { return extensionRange_; } } - public int ExtensionRangeCount { - get { return extensionRange_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange GetExtensionRange(int index) { - return extensionRange_[index]; - } public const int OneofDeclFieldNumber = 8; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto> oneofDecl_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto> OneofDeclList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto> oneofDecl_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto> OneofDecl { get { return oneofDecl_; } } - public int OneofDeclCount { - get { return oneofDecl_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto GetOneofDecl(int index) { - return oneofDecl_[index]; - } public const int OptionsFieldNumber = 7; - private bool hasOptions; - private global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions options_; - public bool HasOptions { - get { return hasOptions; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions Options { - get { return options_ ?? global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.DefaultInstance; } + private global::Google.Protobuf.DescriptorProtos.MessageOptions options_; + public global::Google.Protobuf.DescriptorProtos.MessageOptions Options { + get { return options_; } + set { options_ = value; } } public const int ReservedRangeFieldNumber = 9; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange> reservedRange_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange> ReservedRangeList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange> reservedRange_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange> ReservedRange { get { return reservedRange_; } } - public int ReservedRangeCount { - get { return reservedRange_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange GetReservedRange(int index) { - return reservedRange_[index]; - } public const int ReservedNameFieldNumber = 10; - private pbc::PopsicleList<string> reservedName_ = new pbc::PopsicleList<string>(); - public scg::IList<string> ReservedNameList { - get { return pbc::Lists.AsReadOnly(reservedName_); } + private readonly pbc::RepeatedField<string> reservedName_ = new pbc::RepeatedField<string>(); + public pbc::RepeatedField<string> ReservedName { + get { return reservedName_; } } - public int ReservedNameCount { - get { return reservedName_.Count; } - } - public string GetReservedName(int index) { - return reservedName_[index]; + + public override bool Equals(object other) { + return Equals(other as DescriptorProto); } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto element in FieldList) { - if (!element.IsInitialized) return false; - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto element in ExtensionList) { - if (!element.IsInitialized) return false; - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto element in NestedTypeList) { - if (!element.IsInitialized) return false; - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto element in EnumTypeList) { - if (!element.IsInitialized) return false; - } - if (HasOptions) { - if (!Options.IsInitialized) return false; - } + public bool Equals(DescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { return true; } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _descriptorProtoFieldNames; - if (hasName) { - output.WriteString(1, field_names[4], Name); + if (Name != other.Name) return false; + if(!field_.Equals(other.field_)) return false; + if(!extension_.Equals(other.extension_)) return false; + if(!nestedType_.Equals(other.nestedType_)) return false; + if(!enumType_.Equals(other.enumType_)) return false; + if(!extensionRange_.Equals(other.extensionRange_)) return false; + if(!oneofDecl_.Equals(other.oneofDecl_)) return false; + if (!object.Equals(Options, other.Options)) return false;if(!reservedRange_.Equals(other.reservedRange_)) return false; + if(!reservedName_.Equals(other.reservedName_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 0; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + hash ^= field_.GetHashCode(); + hash ^= extension_.GetHashCode(); + hash ^= nestedType_.GetHashCode(); + hash ^= enumType_.GetHashCode(); + hash ^= extensionRange_.GetHashCode(); + hash ^= oneofDecl_.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + hash ^= reservedRange_.GetHashCode(); + hash ^= reservedName_.GetHashCode(); + return hash; + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); } if (field_.Count > 0) { - output.WriteMessageArray(2, field_names[3], field_); + output.WriteMessageArray(2, field_); } if (nestedType_.Count > 0) { - output.WriteMessageArray(3, field_names[5], nestedType_); + output.WriteMessageArray(3, nestedType_); } if (enumType_.Count > 0) { - output.WriteMessageArray(4, field_names[0], enumType_); + output.WriteMessageArray(4, enumType_); } if (extensionRange_.Count > 0) { - output.WriteMessageArray(5, field_names[2], extensionRange_); + output.WriteMessageArray(5, extensionRange_); } if (extension_.Count > 0) { - output.WriteMessageArray(6, field_names[1], extension_); + output.WriteMessageArray(6, extension_); } - if (hasOptions) { - output.WriteMessage(7, field_names[7], Options); + if (options_ != null) { + output.WriteRawTag(58); + output.WriteMessage(Options); } if (oneofDecl_.Count > 0) { - output.WriteMessageArray(8, field_names[6], oneofDecl_); + output.WriteMessageArray(8, oneofDecl_); } if (reservedRange_.Count > 0) { - output.WriteMessageArray(9, field_names[9], reservedRange_); + output.WriteMessageArray(9, reservedRange_); } if (reservedName_.Count > 0) { - output.WriteStringArray(10, field_names[8], reservedName_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); + output.WriteStringArray(10, reservedName_); } } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto element in FieldList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); + if (field_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in field_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); + } + size += 1 * field_.Count; } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto element in ExtensionList) { - size += pb::CodedOutputStream.ComputeMessageSize(6, element); + if (extension_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in extension_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); + } + size += 1 * extension_.Count; } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto element in NestedTypeList) { - size += pb::CodedOutputStream.ComputeMessageSize(3, element); + if (nestedType_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto element in nestedType_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); + } + size += 1 * nestedType_.Count; } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto element in EnumTypeList) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); + if (enumType_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto element in enumType_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); + } + size += 1 * enumType_.Count; } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange element in ExtensionRangeList) { - size += pb::CodedOutputStream.ComputeMessageSize(5, element); + if (extensionRange_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange element in extensionRange_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); + } + size += 1 * extensionRange_.Count; } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto element in OneofDeclList) { - size += pb::CodedOutputStream.ComputeMessageSize(8, element); + if (oneofDecl_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto element in oneofDecl_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); + } + size += 1 * oneofDecl_.Count; } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(7, Options); + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange element in ReservedRangeList) { - size += pb::CodedOutputStream.ComputeMessageSize(9, element); + if (reservedRange_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange element in reservedRange_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); + } + size += 1 * reservedRange_.Count; } - { + if (reservedName_.Count > 0) { int dataSize = 0; - foreach (string element in ReservedNameList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + foreach (string element in reservedName_) { + dataSize += pb::CodedOutputStream.ComputeStringSize(element); } size += dataSize; size += 1 * reservedName_.Count; } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; return size; } - public static DescriptorProto ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static DescriptorProto ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static DescriptorProto ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static DescriptorProto ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static DescriptorProto ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static DescriptorProto ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static DescriptorProto ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static DescriptorProto ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static DescriptorProto ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static DescriptorProto ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private DescriptorProto MakeReadOnly() { - field_.MakeReadOnly(); - extension_.MakeReadOnly(); - nestedType_.MakeReadOnly(); - enumType_.MakeReadOnly(); - extensionRange_.MakeReadOnly(); - oneofDecl_.MakeReadOnly(); - reservedRange_.MakeReadOnly(); - reservedName_.MakeReadOnly(); - return this; + public void MergeFrom(DescriptorProto other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + field_.Add(other.field_); + extension_.Add(other.extension_); + nestedType_.Add(other.nestedType_); + enumType_.Add(other.enumType_); + extensionRange_.Add(other.extensionRange_); + oneofDecl_.Add(other.oneofDecl_); + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.MessageOptions(); + } + Options.MergeFrom(other.Options); + } + reservedRange_.Add(other.reservedRange_); + reservedName_.Add(other.reservedName_); } - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(DescriptorProto prototype) { - return new Builder(prototype); + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + input.ReadMessageArray(field_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); + break; + } + case 26: { + input.ReadMessageArray(nestedType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); + break; + } + case 34: { + input.ReadMessageArray(enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); + break; + } + case 42: { + input.ReadMessageArray(extensionRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Parser); + break; + } + case 50: { + input.ReadMessageArray(extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); + break; + } + case 58: { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.MessageOptions(); + } + input.ReadMessage(options_); + break; + } + case 66: { + input.ReadMessageArray(oneofDecl_, global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto.Parser); + break; + } + case 74: { + input.ReadMessageArray(reservedRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange.Parser); + break; + } + case 82: { + input.ReadStringArray(reservedName_); + break; + } + } + } } + #region Nested types [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<DescriptorProto, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(DescriptorProto cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } + public static partial class Types { + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class ExtensionRange : pb::IMessage<ExtensionRange>, global::System.IEquatable<ExtensionRange> { + private static readonly pb::MessageParser<ExtensionRange> _parser = new pb::MessageParser<ExtensionRange>(() => new ExtensionRange()); + public static pb::MessageParser<ExtensionRange> Parser { get { return _parser; } } - private bool resultIsReadOnly; - private DescriptorProto result; + private static readonly string[] _fieldNames = new string[] { "end", "start" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; + public static pbd::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor; } + } - private DescriptorProto PrepareBuilder() { - if (resultIsReadOnly) { - DescriptorProto original = result; - result = new DescriptorProto(); - resultIsReadOnly = false; - MergeFrom(original); + public pb::FieldAccess.FieldAccessorTable<ExtensionRange> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; } } - return result; - } - public override bool IsInitialized { - get { return result.IsInitialized; } - } + public ExtensionRange() { } + public ExtensionRange(ExtensionRange other) { + MergeFrom(other); + } + public const int StartFieldNumber = 1; + private int start_; + public int Start { + get { return start_; } + set { start_ = value; } + } - protected override DescriptorProto MessageBeingBuilt { - get { return PrepareBuilder(); } - } - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } + public const int EndFieldNumber = 2; + private int end_; + public int End { + get { return end_; } + set { end_ = value; } + } + - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); + public override bool Equals(object other) { + return Equals(other as ExtensionRange); } - } - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Descriptor; } - } + public bool Equals(ExtensionRange other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Start != other.Start) return false; + if (End != other.End) return false; + return true; + } - public override DescriptorProto DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.DefaultInstance; } - } + public override int GetHashCode() { + int hash = 0; + if (Start != 0) hash ^= Start.GetHashCode(); + if (End != 0) hash ^= End.GetHashCode(); + return hash; + } - public override DescriptorProto BuildPartial() { - if (resultIsReadOnly) { - return result; + public void WriteTo(pb::CodedOutputStream output) { + if (Start != 0) { + output.WriteRawTag(8); + output.WriteInt32(Start); + } + if (End != 0) { + output.WriteRawTag(16); + output.WriteInt32(End); + } } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - public override Builder MergeFrom(pb::IMessage other) { - if (other is DescriptorProto) { - return MergeFrom((DescriptorProto) other); - } else { - base.MergeFrom(other); - return this; + public int CalculateSize() { + int size = 0; + if (Start != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Start); + } + if (End != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(End); + } + return size; + } + public void MergeFrom(ExtensionRange other) { + if (other == null) { + return; + } + if (other.Start != 0) { + Start = other.Start; + } + if (other.End != 0) { + End = other.End; + } } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Start = input.ReadInt32(); + break; + } + case 16: { + End = input.ReadInt32(); + break; + } + } + } + } + } - public override Builder MergeFrom(DescriptorProto other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasName) { - Name = other.Name; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class ReservedRange : pb::IMessage<ReservedRange>, global::System.IEquatable<ReservedRange> { + private static readonly pb::MessageParser<ReservedRange> _parser = new pb::MessageParser<ReservedRange>(() => new ReservedRange()); + public static pb::MessageParser<ReservedRange> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "end", "start" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; + public static pbd::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor; } } - if (other.field_.Count != 0) { - result.field_.Add(other.field_); + + public pb::FieldAccess.FieldAccessorTable<ReservedRange> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; } } - if (other.extension_.Count != 0) { - result.extension_.Add(other.extension_); + + public ReservedRange() { } + public ReservedRange(ReservedRange other) { + MergeFrom(other); } - if (other.nestedType_.Count != 0) { - result.nestedType_.Add(other.nestedType_); + public const int StartFieldNumber = 1; + private int start_; + public int Start { + get { return start_; } + set { start_ = value; } } - if (other.enumType_.Count != 0) { - result.enumType_.Add(other.enumType_); + + + public const int EndFieldNumber = 2; + private int end_; + public int End { + get { return end_; } + set { end_ = value; } } - if (other.extensionRange_.Count != 0) { - result.extensionRange_.Add(other.extensionRange_); + + + public override bool Equals(object other) { + return Equals(other as ReservedRange); } - if (other.oneofDecl_.Count != 0) { - result.oneofDecl_.Add(other.oneofDecl_); + + public bool Equals(ReservedRange other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Start != other.Start) return false; + if (End != other.End) return false; + return true; } - if (other.HasOptions) { - MergeOptions(other.Options); + + public override int GetHashCode() { + int hash = 0; + if (Start != 0) hash ^= Start.GetHashCode(); + if (End != 0) hash ^= End.GetHashCode(); + return hash; } - if (other.reservedRange_.Count != 0) { - result.reservedRange_.Add(other.reservedRange_); + + public void WriteTo(pb::CodedOutputStream output) { + if (Start != 0) { + output.WriteRawTag(8); + output.WriteInt32(Start); + } + if (End != 0) { + output.WriteRawTag(16); + output.WriteInt32(End); + } } - if (other.reservedName_.Count != 0) { - result.reservedName_.Add(other.reservedName_); + + public int CalculateSize() { + int size = 0; + if (Start != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Start); + } + if (End != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(End); + } + return size; } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_descriptorProtoFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _descriptorProtoFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } + public void MergeFrom(ReservedRange other) { + if (other == null) { + return; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); + if (other.Start != 0) { + Start = other.Start; + } + if (other.End != 0) { + End = other.End; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); + break; + case 8: { + Start = input.ReadInt32(); + break; } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasName = input.ReadString(ref result.name_); - break; - } - case 18: { - input.ReadMessageArray(tag, field_name, result.field_, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.DefaultInstance, extensionRegistry); - break; - } - case 26: { - input.ReadMessageArray(tag, field_name, result.nestedType_, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.DefaultInstance, extensionRegistry); - break; - } - case 34: { - input.ReadMessageArray(tag, field_name, result.enumType_, global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.DefaultInstance, extensionRegistry); - break; - } - case 42: { - input.ReadMessageArray(tag, field_name, result.extensionRange_, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange.DefaultInstance, extensionRegistry); - break; - } - case 50: { - input.ReadMessageArray(tag, field_name, result.extension_, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.DefaultInstance, extensionRegistry); - break; - } - case 58: { - global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.Builder subBuilder = global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.CreateBuilder(); - if (result.hasOptions) { - subBuilder.MergeFrom(Options); + case 16: { + End = input.ReadInt32(); + break; } - input.ReadMessage(subBuilder, extensionRegistry); - Options = subBuilder.BuildPartial(); - break; - } - case 66: { - input.ReadMessageArray(tag, field_name, result.oneofDecl_, global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto.DefaultInstance, extensionRegistry); - break; - } - case 74: { - input.ReadMessageArray(tag, field_name, result.reservedRange_, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange.DefaultInstance, extensionRegistry); - break; - } - case 82: { - input.ReadStringArray(tag, field_name, result.reservedName_); - break; } } } - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasName { - get { return result.hasName; } - } - public string Name { - get { return result.Name; } - set { SetName(value); } - } - public Builder SetName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasName = true; - result.name_ = value; - return this; - } - public Builder ClearName() { - PrepareBuilder(); - result.hasName = false; - result.name_ = ""; - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> FieldList { - get { return PrepareBuilder().field_; } - } - public int FieldCount { - get { return result.FieldCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto GetField(int index) { - return result.GetField(index); - } - public Builder SetField(int index, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field_[index] = value; - return this; - } - public Builder SetField(int index, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field_[index] = builderForValue.Build(); - return this; - } - public Builder AddField(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field_.Add(value); - return this; - } - public Builder AddField(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeField(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> values) { - PrepareBuilder(); - result.field_.Add(values); - return this; - } - public Builder ClearField() { - PrepareBuilder(); - result.field_.Clear(); - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> ExtensionList { - get { return PrepareBuilder().extension_; } - } - public int ExtensionCount { - get { return result.ExtensionCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto GetExtension(int index) { - return result.GetExtension(index); - } - public Builder SetExtension(int index, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.extension_[index] = value; - return this; - } - public Builder SetExtension(int index, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.extension_[index] = builderForValue.Build(); - return this; - } - public Builder AddExtension(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.extension_.Add(value); - return this; - } - public Builder AddExtension(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.extension_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeExtension(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> values) { - PrepareBuilder(); - result.extension_.Add(values); - return this; - } - public Builder ClearExtension() { - PrepareBuilder(); - result.extension_.Clear(); - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> NestedTypeList { - get { return PrepareBuilder().nestedType_; } - } - public int NestedTypeCount { - get { return result.NestedTypeCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto GetNestedType(int index) { - return result.GetNestedType(index); - } - public Builder SetNestedType(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.nestedType_[index] = value; - return this; - } - public Builder SetNestedType(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.nestedType_[index] = builderForValue.Build(); - return this; - } - public Builder AddNestedType(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.nestedType_.Add(value); - return this; - } - public Builder AddNestedType(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.nestedType_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeNestedType(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> values) { - PrepareBuilder(); - result.nestedType_.Add(values); - return this; - } - public Builder ClearNestedType() { - PrepareBuilder(); - result.nestedType_.Clear(); - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> EnumTypeList { - get { return PrepareBuilder().enumType_; } - } - public int EnumTypeCount { - get { return result.EnumTypeCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto GetEnumType(int index) { - return result.GetEnumType(index); - } - public Builder SetEnumType(int index, global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.enumType_[index] = value; - return this; - } - public Builder SetEnumType(int index, global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.enumType_[index] = builderForValue.Build(); - return this; - } - public Builder AddEnumType(global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.enumType_.Add(value); - return this; - } - public Builder AddEnumType(global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.enumType_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeEnumType(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> values) { - PrepareBuilder(); - result.enumType_.Add(values); - return this; - } - public Builder ClearEnumType() { - PrepareBuilder(); - result.enumType_.Clear(); - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange> ExtensionRangeList { - get { return PrepareBuilder().extensionRange_; } - } - public int ExtensionRangeCount { - get { return result.ExtensionRangeCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange GetExtensionRange(int index) { - return result.GetExtensionRange(index); - } - public Builder SetExtensionRange(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.extensionRange_[index] = value; - return this; - } - public Builder SetExtensionRange(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.extensionRange_[index] = builderForValue.Build(); - return this; - } - public Builder AddExtensionRange(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.extensionRange_.Add(value); - return this; - } - public Builder AddExtensionRange(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.extensionRange_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeExtensionRange(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange> values) { - PrepareBuilder(); - result.extensionRange_.Add(values); - return this; - } - public Builder ClearExtensionRange() { - PrepareBuilder(); - result.extensionRange_.Clear(); - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto> OneofDeclList { - get { return PrepareBuilder().oneofDecl_; } - } - public int OneofDeclCount { - get { return result.OneofDeclCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto GetOneofDecl(int index) { - return result.GetOneofDecl(index); - } - public Builder SetOneofDecl(int index, global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.oneofDecl_[index] = value; - return this; - } - public Builder SetOneofDecl(int index, global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.oneofDecl_[index] = builderForValue.Build(); - return this; - } - public Builder AddOneofDecl(global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.oneofDecl_.Add(value); - return this; - } - public Builder AddOneofDecl(global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.oneofDecl_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeOneofDecl(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto> values) { - PrepareBuilder(); - result.oneofDecl_.Add(values); - return this; - } - public Builder ClearOneofDecl() { - PrepareBuilder(); - result.oneofDecl_.Clear(); - return this; - } - - public bool HasOptions { - get { return result.hasOptions; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions Options { - get { return result.Options; } - set { SetOptions(value); } - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = value; - return this; - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = builderForValue.Build(); - return this; - } - public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptions && - result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.DefaultInstance) { - result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); - } else { - result.options_ = value; - } - result.hasOptions = true; - return this; - } - public Builder ClearOptions() { - PrepareBuilder(); - result.hasOptions = false; - result.options_ = null; - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange> ReservedRangeList { - get { return PrepareBuilder().reservedRange_; } - } - public int ReservedRangeCount { - get { return result.ReservedRangeCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange GetReservedRange(int index) { - return result.GetReservedRange(index); - } - public Builder SetReservedRange(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.reservedRange_[index] = value; - return this; - } - public Builder SetReservedRange(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.reservedRange_[index] = builderForValue.Build(); - return this; - } - public Builder AddReservedRange(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.reservedRange_.Add(value); - return this; - } - public Builder AddReservedRange(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.reservedRange_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeReservedRange(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ReservedRange> values) { - PrepareBuilder(); - result.reservedRange_.Add(values); - return this; - } - public Builder ClearReservedRange() { - PrepareBuilder(); - result.reservedRange_.Clear(); - return this; } - public pbc::IPopsicleList<string> ReservedNameList { - get { return PrepareBuilder().reservedName_; } - } - public int ReservedNameCount { - get { return result.ReservedNameCount; } - } - public string GetReservedName(int index) { - return result.GetReservedName(index); - } - public Builder SetReservedName(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.reservedName_[index] = value; - return this; - } - public Builder AddReservedName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.reservedName_.Add(value); - return this; - } - public Builder AddRangeReservedName(scg::IEnumerable<string> values) { - PrepareBuilder(); - result.reservedName_.Add(values); - return this; - } - public Builder ClearReservedName() { - PrepareBuilder(); - result.reservedName_.Clear(); - return this; - } - } - static DescriptorProto() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); } + #endregion + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FieldDescriptorProto : pb::GeneratedMessage<FieldDescriptorProto, FieldDescriptorProto.Builder> { - private FieldDescriptorProto() { } - private static readonly FieldDescriptorProto defaultInstance = new FieldDescriptorProto().MakeReadOnly(); - private static readonly string[] _fieldDescriptorProtoFieldNames = new string[] { "default_value", "extendee", "label", "name", "number", "oneof_index", "options", "type", "type_name" }; - private static readonly uint[] _fieldDescriptorProtoFieldTags = new uint[] { 58, 18, 32, 10, 24, 72, 66, 40, 50 }; - public static FieldDescriptorProto DefaultInstance { - get { return defaultInstance; } - } - - public override FieldDescriptorProto DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FieldDescriptorProto ThisMessage { - get { return this; } - } + public sealed partial class FieldDescriptorProto : pb::IMessage<FieldDescriptorProto>, global::System.IEquatable<FieldDescriptorProto> { + private static readonly pb::MessageParser<FieldDescriptorProto> _parser = new pb::MessageParser<FieldDescriptorProto>(() => new FieldDescriptorProto()); + public static pb::MessageParser<FieldDescriptorProto> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "default_value", "extendee", "label", "name", "number", "oneof_index", "options", "type", "type_name" }; + private static readonly uint[] _fieldTags = new uint[] { 58, 18, 32, 10, 24, 72, 66, 40, 50 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<FieldDescriptorProto, FieldDescriptorProto.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<FieldDescriptorProto> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; } } - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum Type { - TYPE_DOUBLE = 1, - TYPE_FLOAT = 2, - TYPE_INT64 = 3, - TYPE_UINT64 = 4, - TYPE_INT32 = 5, - TYPE_FIXED64 = 6, - TYPE_FIXED32 = 7, - TYPE_BOOL = 8, - TYPE_STRING = 9, - TYPE_GROUP = 10, - TYPE_MESSAGE = 11, - TYPE_BYTES = 12, - TYPE_UINT32 = 13, - TYPE_ENUM = 14, - TYPE_SFIXED32 = 15, - TYPE_SFIXED64 = 16, - TYPE_SINT32 = 17, - TYPE_SINT64 = 18, - } - - public enum Label { - LABEL_OPTIONAL = 1, - LABEL_REQUIRED = 2, - LABEL_REPEATED = 3, - } - + public FieldDescriptorProto() { } + public FieldDescriptorProto(FieldDescriptorProto other) { + MergeFrom(other); } - #endregion - public const int NameFieldNumber = 1; - private bool hasName; private string name_ = ""; - public bool HasName { - get { return hasName; } - } public string Name { get { return name_; } + set { name_ = value ?? ""; } } + public const int NumberFieldNumber = 3; - private bool hasNumber; private int number_; - public bool HasNumber { - get { return hasNumber; } - } public int Number { get { return number_; } + set { number_ = value; } } + public const int LabelFieldNumber = 4; - private bool hasLabel; - private global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Label label_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL; - public bool HasLabel { - get { return hasLabel; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Label Label { + private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label label_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL; + public global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label Label { get { return label_; } + set { label_ = value; } } + public const int TypeFieldNumber = 5; - private bool hasType; - private global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Type type_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE; - public bool HasType { - get { return hasType; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Type Type { + private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type type_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE; + public global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type Type { get { return type_; } + set { type_ = value; } } + public const int TypeNameFieldNumber = 6; - private bool hasTypeName; private string typeName_ = ""; - public bool HasTypeName { - get { return hasTypeName; } - } public string TypeName { get { return typeName_; } + set { typeName_ = value ?? ""; } } + public const int ExtendeeFieldNumber = 2; - private bool hasExtendee; private string extendee_ = ""; - public bool HasExtendee { - get { return hasExtendee; } - } public string Extendee { get { return extendee_; } + set { extendee_ = value ?? ""; } } + public const int DefaultValueFieldNumber = 7; - private bool hasDefaultValue; private string defaultValue_ = ""; - public bool HasDefaultValue { - get { return hasDefaultValue; } - } public string DefaultValue { get { return defaultValue_; } + set { defaultValue_ = value ?? ""; } } + public const int OneofIndexFieldNumber = 9; - private bool hasOneofIndex; private int oneofIndex_; - public bool HasOneofIndex { - get { return hasOneofIndex; } - } public int OneofIndex { get { return oneofIndex_; } + set { oneofIndex_ = value; } } + public const int OptionsFieldNumber = 8; - private bool hasOptions; - private global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions options_; - public bool HasOptions { - get { return hasOptions; } + private global::Google.Protobuf.DescriptorProtos.FieldOptions options_; + public global::Google.Protobuf.DescriptorProtos.FieldOptions Options { + get { return options_; } + set { options_ = value; } } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions Options { - get { return options_ ?? global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.DefaultInstance; } + + public override bool Equals(object other) { + return Equals(other as FieldDescriptorProto); } - public override bool IsInitialized { - get { - if (HasOptions) { - if (!Options.IsInitialized) return false; - } + public bool Equals(FieldDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { return true; } + if (Name != other.Name) return false; + if (Number != other.Number) return false; + if (Label != other.Label) return false; + if (Type != other.Type) return false; + if (TypeName != other.TypeName) return false; + if (Extendee != other.Extendee) return false; + if (DefaultValue != other.DefaultValue) return false; + if (OneofIndex != other.OneofIndex) return false; + if (!object.Equals(Options, other.Options)) return false; return true; } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fieldDescriptorProtoFieldNames; - if (hasName) { - output.WriteString(1, field_names[3], Name); + public override int GetHashCode() { + int hash = 0; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (Number != 0) hash ^= Number.GetHashCode(); + if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) hash ^= Label.GetHashCode(); + if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) hash ^= Type.GetHashCode(); + if (TypeName.Length != 0) hash ^= TypeName.GetHashCode(); + if (Extendee.Length != 0) hash ^= Extendee.GetHashCode(); + if (DefaultValue.Length != 0) hash ^= DefaultValue.GetHashCode(); + if (OneofIndex != 0) hash ^= OneofIndex.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + return hash; + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); } - if (hasExtendee) { - output.WriteString(2, field_names[1], Extendee); + if (Extendee.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Extendee); } - if (hasNumber) { - output.WriteInt32(3, field_names[4], Number); + if (Number != 0) { + output.WriteRawTag(24); + output.WriteInt32(Number); } - if (hasLabel) { - output.WriteEnum(4, field_names[2], (int) Label, Label); + if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { + output.WriteRawTag(32); + output.WriteEnum((int) Label); } - if (hasType) { - output.WriteEnum(5, field_names[7], (int) Type, Type); + if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { + output.WriteRawTag(40); + output.WriteEnum((int) Type); } - if (hasTypeName) { - output.WriteString(6, field_names[8], TypeName); + if (TypeName.Length != 0) { + output.WriteRawTag(50); + output.WriteString(TypeName); } - if (hasDefaultValue) { - output.WriteString(7, field_names[0], DefaultValue); + if (DefaultValue.Length != 0) { + output.WriteRawTag(58); + output.WriteString(DefaultValue); } - if (hasOptions) { - output.WriteMessage(8, field_names[6], Options); + if (options_ != null) { + output.WriteRawTag(66); + output.WriteMessage(Options); } - if (hasOneofIndex) { - output.WriteInt32(9, field_names[5], OneofIndex); + if (OneofIndex != 0) { + output.WriteRawTag(72); + output.WriteInt32(OneofIndex); } - UnknownFields.WriteTo(output); } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); - } - if (hasNumber) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Number); + if (Number != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); } - if (hasLabel) { - size += pb::CodedOutputStream.ComputeEnumSize(4, (int) Label); + if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Label); } - if (hasType) { - size += pb::CodedOutputStream.ComputeEnumSize(5, (int) Type); + if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); } - if (hasTypeName) { - size += pb::CodedOutputStream.ComputeStringSize(6, TypeName); + if (TypeName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TypeName); } - if (hasExtendee) { - size += pb::CodedOutputStream.ComputeStringSize(2, Extendee); + if (Extendee.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Extendee); } - if (hasDefaultValue) { - size += pb::CodedOutputStream.ComputeStringSize(7, DefaultValue); + if (DefaultValue.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(DefaultValue); } - if (hasOneofIndex) { - size += pb::CodedOutputStream.ComputeInt32Size(9, OneofIndex); + if (OneofIndex != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(OneofIndex); } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(8, Options); + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; return size; } - public static FieldDescriptorProto ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FieldDescriptorProto ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FieldDescriptorProto ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FieldDescriptorProto ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FieldDescriptorProto ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FieldDescriptorProto ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FieldDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FieldDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FieldDescriptorProto ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FieldDescriptorProto ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FieldDescriptorProto MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FieldDescriptorProto prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<FieldDescriptorProto, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FieldDescriptorProto cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; + public void MergeFrom(FieldDescriptorProto other) { + if (other == null) { + return; } - - private bool resultIsReadOnly; - private FieldDescriptorProto result; - - private FieldDescriptorProto PrepareBuilder() { - if (resultIsReadOnly) { - FieldDescriptorProto original = result; - result = new FieldDescriptorProto(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; + if (other.Name.Length != 0) { + Name = other.Name; } - - public override bool IsInitialized { - get { return result.IsInitialized; } + if (other.Number != 0) { + Number = other.Number; } - - protected override FieldDescriptorProto MessageBeingBuilt { - get { return PrepareBuilder(); } + if (other.Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { + Label = other.Label; } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; + if (other.Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { + Type = other.Type; } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } + if (other.TypeName.Length != 0) { + TypeName = other.TypeName; } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Descriptor; } + if (other.Extendee.Length != 0) { + Extendee = other.Extendee; } - - public override FieldDescriptorProto DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.DefaultInstance; } + if (other.DefaultValue.Length != 0) { + DefaultValue = other.DefaultValue; } - - public override FieldDescriptorProto BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); + if (other.OneofIndex != 0) { + OneofIndex = other.OneofIndex; } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FieldDescriptorProto) { - return MergeFrom((FieldDescriptorProto) other); - } else { - base.MergeFrom(other); - return this; + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.FieldOptions(); } + Options.MergeFrom(other.Options); } + } - public override Builder MergeFrom(FieldDescriptorProto other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasName) { - Name = other.Name; - } - if (other.HasNumber) { - Number = other.Number; - } - if (other.HasLabel) { - Label = other.Label; - } - if (other.HasType) { - Type = other.Type; - } - if (other.HasTypeName) { - TypeName = other.TypeName; - } - if (other.HasExtendee) { - Extendee = other.Extendee; - } - if (other.HasDefaultValue) { - DefaultValue = other.DefaultValue; - } - if (other.HasOneofIndex) { - OneofIndex = other.OneofIndex; - } - if (other.HasOptions) { - MergeOptions(other.Options); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fieldDescriptorProtoFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fieldDescriptorProtoFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 10: { + Name = input.ReadString(); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasName = input.ReadString(ref result.name_); - break; - } - case 18: { - result.hasExtendee = input.ReadString(ref result.extendee_); - break; - } - case 24: { - result.hasNumber = input.ReadInt32(ref result.number_); - break; - } - case 32: { - object unknown; - if(input.ReadEnum(ref result.label_, out unknown)) { - result.hasLabel = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(4, (ulong)(int)unknown); - } - break; - } - case 40: { - object unknown; - if(input.ReadEnum(ref result.type_, out unknown)) { - result.hasType = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(5, (ulong)(int)unknown); - } - break; - } - case 50: { - result.hasTypeName = input.ReadString(ref result.typeName_); - break; - } - case 58: { - result.hasDefaultValue = input.ReadString(ref result.defaultValue_); - break; - } - case 66: { - global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Builder subBuilder = global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.CreateBuilder(); - if (result.hasOptions) { - subBuilder.MergeFrom(Options); - } - input.ReadMessage(subBuilder, extensionRegistry); - Options = subBuilder.BuildPartial(); - break; - } - case 72: { - result.hasOneofIndex = input.ReadInt32(ref result.oneofIndex_); - break; + case 18: { + Extendee = input.ReadString(); + break; + } + case 24: { + Number = input.ReadInt32(); + break; + } + case 32: { + label_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label) input.ReadEnum(); + break; + } + case 40: { + type_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type) input.ReadEnum(); + break; + } + case 50: { + TypeName = input.ReadString(); + break; + } + case 58: { + DefaultValue = input.ReadString(); + break; + } + case 66: { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.FieldOptions(); } + input.ReadMessage(options_); + break; + } + case 72: { + OneofIndex = input.ReadInt32(); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasName { - get { return result.hasName; } - } - public string Name { - get { return result.Name; } - set { SetName(value); } - } - public Builder SetName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasName = true; - result.name_ = value; - return this; - } - public Builder ClearName() { - PrepareBuilder(); - result.hasName = false; - result.name_ = ""; - return this; - } - - public bool HasNumber { - get { return result.hasNumber; } - } - public int Number { - get { return result.Number; } - set { SetNumber(value); } - } - public Builder SetNumber(int value) { - PrepareBuilder(); - result.hasNumber = true; - result.number_ = value; - return this; - } - public Builder ClearNumber() { - PrepareBuilder(); - result.hasNumber = false; - result.number_ = 0; - return this; } + } - public bool HasLabel { - get { return result.hasLabel; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Label Label { - get { return result.Label; } - set { SetLabel(value); } - } - public Builder SetLabel(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Label value) { - PrepareBuilder(); - result.hasLabel = true; - result.label_ = value; - return this; - } - public Builder ClearLabel() { - PrepareBuilder(); - result.hasLabel = false; - result.label_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL; - return this; + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + public enum Type { + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + TYPE_GROUP = 10, + TYPE_MESSAGE = 11, + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + TYPE_SINT32 = 17, + TYPE_SINT64 = 18, } - public bool HasType { - get { return result.hasType; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Type Type { - get { return result.Type; } - set { SetType(value); } - } - public Builder SetType(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Type value) { - PrepareBuilder(); - result.hasType = true; - result.type_ = value; - return this; - } - public Builder ClearType() { - PrepareBuilder(); - result.hasType = false; - result.type_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE; - return this; + public enum Label { + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, } - public bool HasTypeName { - get { return result.hasTypeName; } - } - public string TypeName { - get { return result.TypeName; } - set { SetTypeName(value); } - } - public Builder SetTypeName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasTypeName = true; - result.typeName_ = value; - return this; - } - public Builder ClearTypeName() { - PrepareBuilder(); - result.hasTypeName = false; - result.typeName_ = ""; - return this; - } - - public bool HasExtendee { - get { return result.hasExtendee; } - } - public string Extendee { - get { return result.Extendee; } - set { SetExtendee(value); } - } - public Builder SetExtendee(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasExtendee = true; - result.extendee_ = value; - return this; - } - public Builder ClearExtendee() { - PrepareBuilder(); - result.hasExtendee = false; - result.extendee_ = ""; - return this; - } - - public bool HasDefaultValue { - get { return result.hasDefaultValue; } - } - public string DefaultValue { - get { return result.DefaultValue; } - set { SetDefaultValue(value); } - } - public Builder SetDefaultValue(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDefaultValue = true; - result.defaultValue_ = value; - return this; - } - public Builder ClearDefaultValue() { - PrepareBuilder(); - result.hasDefaultValue = false; - result.defaultValue_ = ""; - return this; - } - - public bool HasOneofIndex { - get { return result.hasOneofIndex; } - } - public int OneofIndex { - get { return result.OneofIndex; } - set { SetOneofIndex(value); } - } - public Builder SetOneofIndex(int value) { - PrepareBuilder(); - result.hasOneofIndex = true; - result.oneofIndex_ = value; - return this; - } - public Builder ClearOneofIndex() { - PrepareBuilder(); - result.hasOneofIndex = false; - result.oneofIndex_ = 0; - return this; - } - - public bool HasOptions { - get { return result.hasOptions; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions Options { - get { return result.Options; } - set { SetOptions(value); } - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = value; - return this; - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = builderForValue.Build(); - return this; - } - public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptions && - result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.DefaultInstance) { - result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); - } else { - result.options_ = value; - } - result.hasOptions = true; - return this; - } - public Builder ClearOptions() { - PrepareBuilder(); - result.hasOptions = false; - result.options_ = null; - return this; - } - } - static FieldDescriptorProto() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); } + #endregion + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OneofDescriptorProto : pb::GeneratedMessage<OneofDescriptorProto, OneofDescriptorProto.Builder> { - private OneofDescriptorProto() { } - private static readonly OneofDescriptorProto defaultInstance = new OneofDescriptorProto().MakeReadOnly(); - private static readonly string[] _oneofDescriptorProtoFieldNames = new string[] { "name" }; - private static readonly uint[] _oneofDescriptorProtoFieldTags = new uint[] { 10 }; - public static OneofDescriptorProto DefaultInstance { - get { return defaultInstance; } - } - - public override OneofDescriptorProto DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OneofDescriptorProto ThisMessage { - get { return this; } - } + public sealed partial class OneofDescriptorProto : pb::IMessage<OneofDescriptorProto>, global::System.IEquatable<OneofDescriptorProto> { + private static readonly pb::MessageParser<OneofDescriptorProto> _parser = new pb::MessageParser<OneofDescriptorProto>(() => new OneofDescriptorProto()); + public static pb::MessageParser<OneofDescriptorProto> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "name" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<OneofDescriptorProto, OneofDescriptorProto.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<OneofDescriptorProto> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; } } + public OneofDescriptorProto() { } + public OneofDescriptorProto(OneofDescriptorProto other) { + MergeFrom(other); + } public const int NameFieldNumber = 1; - private bool hasName; private string name_ = ""; - public bool HasName { - get { return hasName; } - } public string Name { get { return name_; } + set { name_ = value ?? ""; } } - public override bool IsInitialized { - get { - return true; - } - } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _oneofDescriptorProtoFieldNames; - if (hasName) { - output.WriteString(1, field_names[0], Name); - } - UnknownFields.WriteTo(output); + public override bool Equals(object other) { + return Equals(other as OneofDescriptorProto); } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); + public bool Equals(OneofDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + if (ReferenceEquals(other, this)) { + return true; } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static OneofDescriptorProto ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OneofDescriptorProto ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OneofDescriptorProto ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OneofDescriptorProto ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OneofDescriptorProto ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OneofDescriptorProto ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OneofDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OneofDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OneofDescriptorProto ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OneofDescriptorProto ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OneofDescriptorProto MakeReadOnly() { - return this; + if (Name != other.Name) return false; + return true; } - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OneofDescriptorProto prototype) { - return new Builder(prototype); + public override int GetHashCode() { + int hash = 0; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + return hash; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<OneofDescriptorProto, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OneofDescriptorProto cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OneofDescriptorProto result; - - private OneofDescriptorProto PrepareBuilder() { - if (resultIsReadOnly) { - OneofDescriptorProto original = result; - result = new OneofDescriptorProto(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OneofDescriptorProto MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto.Descriptor; } + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); } + } - public override OneofDescriptorProto DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto.DefaultInstance; } + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - - public override OneofDescriptorProto BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); + return size; + } + public void MergeFrom(OneofDescriptorProto other) { + if (other == null) { + return; } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is OneofDescriptorProto) { - return MergeFrom((OneofDescriptorProto) other); - } else { - base.MergeFrom(other); - return this; - } + if (other.Name.Length != 0) { + Name = other.Name; } + } - public override Builder MergeFrom(OneofDescriptorProto other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.OneofDescriptorProto.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasName) { - Name = other.Name; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_oneofDescriptorProtoFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _oneofDescriptorProtoFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 10: { + Name = input.ReadString(); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasName = input.ReadString(ref result.name_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); } - return this; - } - - - public bool HasName { - get { return result.hasName; } - } - public string Name { - get { return result.Name; } - set { SetName(value); } - } - public Builder SetName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasName = true; - result.name_ = value; - return this; } - public Builder ClearName() { - PrepareBuilder(); - result.hasName = false; - result.name_ = ""; - return this; - } - } - static OneofDescriptorProto() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); } + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumDescriptorProto : pb::GeneratedMessage<EnumDescriptorProto, EnumDescriptorProto.Builder> { - private EnumDescriptorProto() { } - private static readonly EnumDescriptorProto defaultInstance = new EnumDescriptorProto().MakeReadOnly(); - private static readonly string[] _enumDescriptorProtoFieldNames = new string[] { "name", "options", "value" }; - private static readonly uint[] _enumDescriptorProtoFieldTags = new uint[] { 10, 26, 18 }; - public static EnumDescriptorProto DefaultInstance { - get { return defaultInstance; } - } - - public override EnumDescriptorProto DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override EnumDescriptorProto ThisMessage { - get { return this; } - } + public sealed partial class EnumDescriptorProto : pb::IMessage<EnumDescriptorProto>, global::System.IEquatable<EnumDescriptorProto> { + private static readonly pb::MessageParser<EnumDescriptorProto> _parser = new pb::MessageParser<EnumDescriptorProto>(() => new EnumDescriptorProto()); + public static pb::MessageParser<EnumDescriptorProto> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "name", "options", "value" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 26, 18 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<EnumDescriptorProto, EnumDescriptorProto.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<EnumDescriptorProto> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; } } + public EnumDescriptorProto() { } + public EnumDescriptorProto(EnumDescriptorProto other) { + MergeFrom(other); + } public const int NameFieldNumber = 1; - private bool hasName; private string name_ = ""; - public bool HasName { - get { return hasName; } - } public string Name { get { return name_; } + set { name_ = value ?? ""; } } + public const int ValueFieldNumber = 2; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto> value_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto> ValueList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> value_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> Value { get { return value_; } } - public int ValueCount { - get { return value_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto GetValue(int index) { - return value_[index]; - } public const int OptionsFieldNumber = 3; - private bool hasOptions; - private global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions options_; - public bool HasOptions { - get { return hasOptions; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions Options { - get { return options_ ?? global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.DefaultInstance; } + private global::Google.Protobuf.DescriptorProtos.EnumOptions options_; + public global::Google.Protobuf.DescriptorProtos.EnumOptions Options { + get { return options_; } + set { options_ = value; } } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto element in ValueList) { - if (!element.IsInitialized) return false; - } - if (HasOptions) { - if (!Options.IsInitialized) return false; - } - return true; - } + public override bool Equals(object other) { + return Equals(other as EnumDescriptorProto); } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _enumDescriptorProtoFieldNames; - if (hasName) { - output.WriteString(1, field_names[0], Name); - } - if (value_.Count > 0) { - output.WriteMessageArray(2, field_names[2], value_); + public bool Equals(EnumDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; } - if (hasOptions) { - output.WriteMessage(3, field_names[1], Options); + if (ReferenceEquals(other, this)) { + return true; } - UnknownFields.WriteTo(output); + if (Name != other.Name) return false; + if(!value_.Equals(other.value_)) return false; + if (!object.Equals(Options, other.Options)) return false; return true; } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } + public override int GetHashCode() { + int hash = 0; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + hash ^= value_.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + return hash; } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto element in ValueList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); + if (value_.Count > 0) { + output.WriteMessageArray(2, value_); } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(3, Options); + if (options_ != null) { + output.WriteRawTag(26); + output.WriteMessage(Options); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static EnumDescriptorProto ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static EnumDescriptorProto ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); } - public static EnumDescriptorProto ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static EnumDescriptorProto ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static EnumDescriptorProto ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static EnumDescriptorProto ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static EnumDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static EnumDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static EnumDescriptorProto ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static EnumDescriptorProto ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private EnumDescriptorProto MakeReadOnly() { - value_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(EnumDescriptorProto prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<EnumDescriptorProto, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(EnumDescriptorProto cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private EnumDescriptorProto result; - - private EnumDescriptorProto PrepareBuilder() { - if (resultIsReadOnly) { - EnumDescriptorProto original = result; - result = new EnumDescriptorProto(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - public override bool IsInitialized { - get { return result.IsInitialized; } + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - - protected override EnumDescriptorProto MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); + if (value_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto element in value_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * value_.Count; } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.Descriptor; } + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } - - public override EnumDescriptorProto DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.DefaultInstance; } + return size; + } + public void MergeFrom(EnumDescriptorProto other) { + if (other == null) { + return; } - - public override EnumDescriptorProto BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); + if (other.Name.Length != 0) { + Name = other.Name; } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is EnumDescriptorProto) { - return MergeFrom((EnumDescriptorProto) other); - } else { - base.MergeFrom(other); - return this; + value_.Add(other.value_); + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.EnumOptions(); } + Options.MergeFrom(other.Options); } + } - public override Builder MergeFrom(EnumDescriptorProto other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasName) { - Name = other.Name; - } - if (other.value_.Count != 0) { - result.value_.Add(other.value_); - } - if (other.HasOptions) { - MergeOptions(other.Options); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_enumDescriptorProtoFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _enumDescriptorProtoFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 10: { + Name = input.ReadString(); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasName = input.ReadString(ref result.name_); - break; - } - case 18: { - input.ReadMessageArray(tag, field_name, result.value_, global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto.DefaultInstance, extensionRegistry); - break; - } - case 26: { - global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.Builder subBuilder = global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.CreateBuilder(); - if (result.hasOptions) { - subBuilder.MergeFrom(Options); - } - input.ReadMessage(subBuilder, extensionRegistry); - Options = subBuilder.BuildPartial(); - break; + case 18: { + input.ReadMessageArray(value_, global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto.Parser); + break; + } + case 26: { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.EnumOptions(); } + input.ReadMessage(options_); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasName { - get { return result.hasName; } - } - public string Name { - get { return result.Name; } - set { SetName(value); } - } - public Builder SetName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasName = true; - result.name_ = value; - return this; - } - public Builder ClearName() { - PrepareBuilder(); - result.hasName = false; - result.name_ = ""; - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto> ValueList { - get { return PrepareBuilder().value_; } - } - public int ValueCount { - get { return result.ValueCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto GetValue(int index) { - return result.GetValue(index); - } - public Builder SetValue(int index, global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.value_[index] = value; - return this; - } - public Builder SetValue(int index, global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.value_[index] = builderForValue.Build(); - return this; - } - public Builder AddValue(global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.value_.Add(value); - return this; - } - public Builder AddValue(global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.value_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeValue(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto> values) { - PrepareBuilder(); - result.value_.Add(values); - return this; - } - public Builder ClearValue() { - PrepareBuilder(); - result.value_.Clear(); - return this; - } - - public bool HasOptions { - get { return result.hasOptions; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions Options { - get { return result.Options; } - set { SetOptions(value); } - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = value; - return this; - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = builderForValue.Build(); - return this; - } - public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptions && - result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.DefaultInstance) { - result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); - } else { - result.options_ = value; - } - result.hasOptions = true; - return this; - } - public Builder ClearOptions() { - PrepareBuilder(); - result.hasOptions = false; - result.options_ = null; - return this; } } - static EnumDescriptorProto() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); - } + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumValueDescriptorProto : pb::GeneratedMessage<EnumValueDescriptorProto, EnumValueDescriptorProto.Builder> { - private EnumValueDescriptorProto() { } - private static readonly EnumValueDescriptorProto defaultInstance = new EnumValueDescriptorProto().MakeReadOnly(); - private static readonly string[] _enumValueDescriptorProtoFieldNames = new string[] { "name", "number", "options" }; - private static readonly uint[] _enumValueDescriptorProtoFieldTags = new uint[] { 10, 16, 26 }; - public static EnumValueDescriptorProto DefaultInstance { - get { return defaultInstance; } - } - - public override EnumValueDescriptorProto DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override EnumValueDescriptorProto ThisMessage { - get { return this; } - } + public sealed partial class EnumValueDescriptorProto : pb::IMessage<EnumValueDescriptorProto>, global::System.IEquatable<EnumValueDescriptorProto> { + private static readonly pb::MessageParser<EnumValueDescriptorProto> _parser = new pb::MessageParser<EnumValueDescriptorProto>(() => new EnumValueDescriptorProto()); + public static pb::MessageParser<EnumValueDescriptorProto> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "name", "number", "options" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 16, 26 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<EnumValueDescriptorProto, EnumValueDescriptorProto.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<EnumValueDescriptorProto> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; } } + public EnumValueDescriptorProto() { } + public EnumValueDescriptorProto(EnumValueDescriptorProto other) { + MergeFrom(other); + } public const int NameFieldNumber = 1; - private bool hasName; private string name_ = ""; - public bool HasName { - get { return hasName; } - } public string Name { get { return name_; } + set { name_ = value ?? ""; } } + public const int NumberFieldNumber = 2; - private bool hasNumber; private int number_; - public bool HasNumber { - get { return hasNumber; } - } public int Number { get { return number_; } + set { number_ = value; } } + public const int OptionsFieldNumber = 3; - private bool hasOptions; - private global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions options_; - public bool HasOptions { - get { return hasOptions; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions Options { - get { return options_ ?? global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.DefaultInstance; } + private global::Google.Protobuf.DescriptorProtos.EnumValueOptions options_; + public global::Google.Protobuf.DescriptorProtos.EnumValueOptions Options { + get { return options_; } + set { options_ = value; } } - public override bool IsInitialized { - get { - if (HasOptions) { - if (!Options.IsInitialized) return false; - } - return true; - } + public override bool Equals(object other) { + return Equals(other as EnumValueDescriptorProto); } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _enumValueDescriptorProtoFieldNames; - if (hasName) { - output.WriteString(1, field_names[0], Name); - } - if (hasNumber) { - output.WriteInt32(2, field_names[1], Number); + public bool Equals(EnumValueDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; } - if (hasOptions) { - output.WriteMessage(3, field_names[2], Options); + if (ReferenceEquals(other, this)) { + return true; } - UnknownFields.WriteTo(output); + if (Name != other.Name) return false; + if (Number != other.Number) return false; + if (!object.Equals(Options, other.Options)) return false; return true; } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } + public override int GetHashCode() { + int hash = 0; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (Number != 0) hash ^= Number.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + return hash; } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); } - if (hasNumber) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Number); + if (Number != 0) { + output.WriteRawTag(16); + output.WriteInt32(Number); } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(3, Options); + if (options_ != null) { + output.WriteRawTag(26); + output.WriteMessage(Options); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static EnumValueDescriptorProto ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static EnumValueDescriptorProto ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static EnumValueDescriptorProto ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static EnumValueDescriptorProto ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static EnumValueDescriptorProto ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static EnumValueDescriptorProto ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static EnumValueDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static EnumValueDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static EnumValueDescriptorProto ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); } - public static EnumValueDescriptorProto ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private EnumValueDescriptorProto MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(EnumValueDescriptorProto prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<EnumValueDescriptorProto, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(EnumValueDescriptorProto cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private EnumValueDescriptorProto result; - private EnumValueDescriptorProto PrepareBuilder() { - if (resultIsReadOnly) { - EnumValueDescriptorProto original = result; - result = new EnumValueDescriptorProto(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override EnumValueDescriptorProto MessageBeingBuilt { - get { return PrepareBuilder(); } + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; + if (Number != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto.Descriptor; } + return size; + } + public void MergeFrom(EnumValueDescriptorProto other) { + if (other == null) { + return; } - - public override EnumValueDescriptorProto DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto.DefaultInstance; } + if (other.Name.Length != 0) { + Name = other.Name; } - - public override EnumValueDescriptorProto BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); + if (other.Number != 0) { + Number = other.Number; } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is EnumValueDescriptorProto) { - return MergeFrom((EnumValueDescriptorProto) other); - } else { - base.MergeFrom(other); - return this; + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.EnumValueOptions(); } + Options.MergeFrom(other.Options); } + } - public override Builder MergeFrom(EnumValueDescriptorProto other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasName) { - Name = other.Name; - } - if (other.HasNumber) { - Number = other.Number; - } - if (other.HasOptions) { - MergeOptions(other.Options); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_enumValueDescriptorProtoFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _enumValueDescriptorProtoFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 10: { + Name = input.ReadString(); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasName = input.ReadString(ref result.name_); - break; - } - case 16: { - result.hasNumber = input.ReadInt32(ref result.number_); - break; - } - case 26: { - global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.Builder subBuilder = global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.CreateBuilder(); - if (result.hasOptions) { - subBuilder.MergeFrom(Options); - } - input.ReadMessage(subBuilder, extensionRegistry); - Options = subBuilder.BuildPartial(); - break; + case 16: { + Number = input.ReadInt32(); + break; + } + case 26: { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.EnumValueOptions(); } + input.ReadMessage(options_); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasName { - get { return result.hasName; } - } - public string Name { - get { return result.Name; } - set { SetName(value); } - } - public Builder SetName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasName = true; - result.name_ = value; - return this; - } - public Builder ClearName() { - PrepareBuilder(); - result.hasName = false; - result.name_ = ""; - return this; - } - - public bool HasNumber { - get { return result.hasNumber; } - } - public int Number { - get { return result.Number; } - set { SetNumber(value); } - } - public Builder SetNumber(int value) { - PrepareBuilder(); - result.hasNumber = true; - result.number_ = value; - return this; - } - public Builder ClearNumber() { - PrepareBuilder(); - result.hasNumber = false; - result.number_ = 0; - return this; - } - - public bool HasOptions { - get { return result.hasOptions; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions Options { - get { return result.Options; } - set { SetOptions(value); } - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = value; - return this; - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = builderForValue.Build(); - return this; - } - public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptions && - result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.DefaultInstance) { - result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); - } else { - result.options_ = value; - } - result.hasOptions = true; - return this; - } - public Builder ClearOptions() { - PrepareBuilder(); - result.hasOptions = false; - result.options_ = null; - return this; } } - static EnumValueDescriptorProto() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); - } + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ServiceDescriptorProto : pb::GeneratedMessage<ServiceDescriptorProto, ServiceDescriptorProto.Builder> { - private ServiceDescriptorProto() { } - private static readonly ServiceDescriptorProto defaultInstance = new ServiceDescriptorProto().MakeReadOnly(); - private static readonly string[] _serviceDescriptorProtoFieldNames = new string[] { "method", "name", "options" }; - private static readonly uint[] _serviceDescriptorProtoFieldTags = new uint[] { 18, 10, 26 }; - public static ServiceDescriptorProto DefaultInstance { - get { return defaultInstance; } - } - - public override ServiceDescriptorProto DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override ServiceDescriptorProto ThisMessage { - get { return this; } - } + public sealed partial class ServiceDescriptorProto : pb::IMessage<ServiceDescriptorProto>, global::System.IEquatable<ServiceDescriptorProto> { + private static readonly pb::MessageParser<ServiceDescriptorProto> _parser = new pb::MessageParser<ServiceDescriptorProto>(() => new ServiceDescriptorProto()); + public static pb::MessageParser<ServiceDescriptorProto> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "method", "name", "options" }; + private static readonly uint[] _fieldTags = new uint[] { 18, 10, 26 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<ServiceDescriptorProto, ServiceDescriptorProto.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<ServiceDescriptorProto> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; } } + public ServiceDescriptorProto() { } + public ServiceDescriptorProto(ServiceDescriptorProto other) { + MergeFrom(other); + } public const int NameFieldNumber = 1; - private bool hasName; private string name_ = ""; - public bool HasName { - get { return hasName; } - } public string Name { get { return name_; } + set { name_ = value ?? ""; } } + public const int MethodFieldNumber = 2; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto> method_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto> MethodList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> method_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> Method { get { return method_; } } - public int MethodCount { - get { return method_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto GetMethod(int index) { - return method_[index]; - } public const int OptionsFieldNumber = 3; - private bool hasOptions; - private global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions options_; - public bool HasOptions { - get { return hasOptions; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions Options { - get { return options_ ?? global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.DefaultInstance; } + private global::Google.Protobuf.DescriptorProtos.ServiceOptions options_; + public global::Google.Protobuf.DescriptorProtos.ServiceOptions Options { + get { return options_; } + set { options_ = value; } } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto element in MethodList) { - if (!element.IsInitialized) return false; - } - if (HasOptions) { - if (!Options.IsInitialized) return false; - } - return true; - } + public override bool Equals(object other) { + return Equals(other as ServiceDescriptorProto); } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _serviceDescriptorProtoFieldNames; - if (hasName) { - output.WriteString(1, field_names[1], Name); + public bool Equals(ServiceDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; } - if (method_.Count > 0) { - output.WriteMessageArray(2, field_names[0], method_); - } - if (hasOptions) { - output.WriteMessage(3, field_names[2], Options); + if (ReferenceEquals(other, this)) { + return true; } - UnknownFields.WriteTo(output); + if (Name != other.Name) return false; + if(!method_.Equals(other.method_)) return false; + if (!object.Equals(Options, other.Options)) return false; return true; } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } + public override int GetHashCode() { + int hash = 0; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + hash ^= method_.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + return hash; } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto element in MethodList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); + if (method_.Count > 0) { + output.WriteMessageArray(2, method_); } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(3, Options); + if (options_ != null) { + output.WriteRawTag(26); + output.WriteMessage(Options); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static ServiceDescriptorProto ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ServiceDescriptorProto ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ServiceDescriptorProto ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ServiceDescriptorProto ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); } - public static ServiceDescriptorProto ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ServiceDescriptorProto ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static ServiceDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static ServiceDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static ServiceDescriptorProto ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ServiceDescriptorProto ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private ServiceDescriptorProto MakeReadOnly() { - method_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(ServiceDescriptorProto prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<ServiceDescriptorProto, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(ServiceDescriptorProto cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private ServiceDescriptorProto result; - - private ServiceDescriptorProto PrepareBuilder() { - if (resultIsReadOnly) { - ServiceDescriptorProto original = result; - result = new ServiceDescriptorProto(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - protected override ServiceDescriptorProto MessageBeingBuilt { - get { return PrepareBuilder(); } + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); + if (method_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto element in method_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * method_.Count; } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto.Descriptor; } + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } - - public override ServiceDescriptorProto DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto.DefaultInstance; } + return size; + } + public void MergeFrom(ServiceDescriptorProto other) { + if (other == null) { + return; } - - public override ServiceDescriptorProto BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); + if (other.Name.Length != 0) { + Name = other.Name; } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is ServiceDescriptorProto) { - return MergeFrom((ServiceDescriptorProto) other); - } else { - base.MergeFrom(other); - return this; + method_.Add(other.method_); + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.ServiceOptions(); } + Options.MergeFrom(other.Options); } + } - public override Builder MergeFrom(ServiceDescriptorProto other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasName) { - Name = other.Name; - } - if (other.method_.Count != 0) { - result.method_.Add(other.method_); - } - if (other.HasOptions) { - MergeOptions(other.Options); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_serviceDescriptorProtoFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _serviceDescriptorProtoFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 10: { + Name = input.ReadString(); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasName = input.ReadString(ref result.name_); - break; - } - case 18: { - input.ReadMessageArray(tag, field_name, result.method_, global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto.DefaultInstance, extensionRegistry); - break; - } - case 26: { - global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.Builder subBuilder = global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.CreateBuilder(); - if (result.hasOptions) { - subBuilder.MergeFrom(Options); - } - input.ReadMessage(subBuilder, extensionRegistry); - Options = subBuilder.BuildPartial(); - break; + case 18: { + input.ReadMessageArray(method_, global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto.Parser); + break; + } + case 26: { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.ServiceOptions(); } + input.ReadMessage(options_); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasName { - get { return result.hasName; } - } - public string Name { - get { return result.Name; } - set { SetName(value); } - } - public Builder SetName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasName = true; - result.name_ = value; - return this; - } - public Builder ClearName() { - PrepareBuilder(); - result.hasName = false; - result.name_ = ""; - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto> MethodList { - get { return PrepareBuilder().method_; } - } - public int MethodCount { - get { return result.MethodCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto GetMethod(int index) { - return result.GetMethod(index); - } - public Builder SetMethod(int index, global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.method_[index] = value; - return this; - } - public Builder SetMethod(int index, global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.method_[index] = builderForValue.Build(); - return this; - } - public Builder AddMethod(global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.method_.Add(value); - return this; - } - public Builder AddMethod(global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.method_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeMethod(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto> values) { - PrepareBuilder(); - result.method_.Add(values); - return this; - } - public Builder ClearMethod() { - PrepareBuilder(); - result.method_.Clear(); - return this; - } - - public bool HasOptions { - get { return result.hasOptions; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions Options { - get { return result.Options; } - set { SetOptions(value); } - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = value; - return this; - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = builderForValue.Build(); - return this; - } - public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptions && - result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.DefaultInstance) { - result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); - } else { - result.options_ = value; - } - result.hasOptions = true; - return this; - } - public Builder ClearOptions() { - PrepareBuilder(); - result.hasOptions = false; - result.options_ = null; - return this; } } - static ServiceDescriptorProto() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); - } + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MethodDescriptorProto : pb::GeneratedMessage<MethodDescriptorProto, MethodDescriptorProto.Builder> { - private MethodDescriptorProto() { } - private static readonly MethodDescriptorProto defaultInstance = new MethodDescriptorProto().MakeReadOnly(); - private static readonly string[] _methodDescriptorProtoFieldNames = new string[] { "client_streaming", "input_type", "name", "options", "output_type", "server_streaming" }; - private static readonly uint[] _methodDescriptorProtoFieldTags = new uint[] { 40, 18, 10, 34, 26, 48 }; - public static MethodDescriptorProto DefaultInstance { - get { return defaultInstance; } - } - - public override MethodDescriptorProto DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override MethodDescriptorProto ThisMessage { - get { return this; } - } + public sealed partial class MethodDescriptorProto : pb::IMessage<MethodDescriptorProto>, global::System.IEquatable<MethodDescriptorProto> { + private static readonly pb::MessageParser<MethodDescriptorProto> _parser = new pb::MessageParser<MethodDescriptorProto>(() => new MethodDescriptorProto()); + public static pb::MessageParser<MethodDescriptorProto> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "client_streaming", "input_type", "name", "options", "output_type", "server_streaming" }; + private static readonly uint[] _fieldTags = new uint[] { 40, 18, 10, 34, 26, 48 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<MethodDescriptorProto, MethodDescriptorProto.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<MethodDescriptorProto> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; } } + public MethodDescriptorProto() { } + public MethodDescriptorProto(MethodDescriptorProto other) { + MergeFrom(other); + } public const int NameFieldNumber = 1; - private bool hasName; private string name_ = ""; - public bool HasName { - get { return hasName; } - } public string Name { get { return name_; } + set { name_ = value ?? ""; } } + public const int InputTypeFieldNumber = 2; - private bool hasInputType; private string inputType_ = ""; - public bool HasInputType { - get { return hasInputType; } - } public string InputType { get { return inputType_; } + set { inputType_ = value ?? ""; } } + public const int OutputTypeFieldNumber = 3; - private bool hasOutputType; private string outputType_ = ""; - public bool HasOutputType { - get { return hasOutputType; } - } public string OutputType { get { return outputType_; } + set { outputType_ = value ?? ""; } } + public const int OptionsFieldNumber = 4; - private bool hasOptions; - private global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions options_; - public bool HasOptions { - get { return hasOptions; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions Options { - get { return options_ ?? global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.DefaultInstance; } + private global::Google.Protobuf.DescriptorProtos.MethodOptions options_; + public global::Google.Protobuf.DescriptorProtos.MethodOptions Options { + get { return options_; } + set { options_ = value; } } public const int ClientStreamingFieldNumber = 5; - private bool hasClientStreaming; private bool clientStreaming_; - public bool HasClientStreaming { - get { return hasClientStreaming; } - } public bool ClientStreaming { get { return clientStreaming_; } + set { clientStreaming_ = value; } } + public const int ServerStreamingFieldNumber = 6; - private bool hasServerStreaming; private bool serverStreaming_; - public bool HasServerStreaming { - get { return hasServerStreaming; } - } public bool ServerStreaming { get { return serverStreaming_; } + set { serverStreaming_ = value; } } - public override bool IsInitialized { - get { - if (HasOptions) { - if (!Options.IsInitialized) return false; - } - return true; - } + + public override bool Equals(object other) { + return Equals(other as MethodDescriptorProto); } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _methodDescriptorProtoFieldNames; - if (hasName) { - output.WriteString(1, field_names[2], Name); + public bool Equals(MethodDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; } - if (hasInputType) { - output.WriteString(2, field_names[1], InputType); - } - if (hasOutputType) { - output.WriteString(3, field_names[4], OutputType); - } - if (hasOptions) { - output.WriteMessage(4, field_names[3], Options); - } - if (hasClientStreaming) { - output.WriteBool(5, field_names[0], ClientStreaming); - } - if (hasServerStreaming) { - output.WriteBool(6, field_names[5], ServerStreaming); + if (ReferenceEquals(other, this)) { + return true; } - UnknownFields.WriteTo(output); + if (Name != other.Name) return false; + if (InputType != other.InputType) return false; + if (OutputType != other.OutputType) return false; + if (!object.Equals(Options, other.Options)) return false;if (ClientStreaming != other.ClientStreaming) return false; + if (ServerStreaming != other.ServerStreaming) return false; + return true; } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } + public override int GetHashCode() { + int hash = 0; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (InputType.Length != 0) hash ^= InputType.GetHashCode(); + if (OutputType.Length != 0) hash ^= OutputType.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + if (ClientStreaming != false) hash ^= ClientStreaming.GetHashCode(); + if (ServerStreaming != false) hash ^= ServerStreaming.GetHashCode(); + return hash; } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); } - if (hasInputType) { - size += pb::CodedOutputStream.ComputeStringSize(2, InputType); + if (InputType.Length != 0) { + output.WriteRawTag(18); + output.WriteString(InputType); } - if (hasOutputType) { - size += pb::CodedOutputStream.ComputeStringSize(3, OutputType); + if (OutputType.Length != 0) { + output.WriteRawTag(26); + output.WriteString(OutputType); } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(4, Options); + if (options_ != null) { + output.WriteRawTag(34); + output.WriteMessage(Options); } - if (hasClientStreaming) { - size += pb::CodedOutputStream.ComputeBoolSize(5, ClientStreaming); + if (ClientStreaming != false) { + output.WriteRawTag(40); + output.WriteBool(ClientStreaming); } - if (hasServerStreaming) { - size += pb::CodedOutputStream.ComputeBoolSize(6, ServerStreaming); + if (ServerStreaming != false) { + output.WriteRawTag(48); + output.WriteBool(ServerStreaming); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static MethodDescriptorProto ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MethodDescriptorProto ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MethodDescriptorProto ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MethodDescriptorProto ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MethodDescriptorProto ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MethodDescriptorProto ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static MethodDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static MethodDescriptorProto ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static MethodDescriptorProto ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MethodDescriptorProto ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private MethodDescriptorProto MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(MethodDescriptorProto prototype) { - return new Builder(prototype); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<MethodDescriptorProto, Builder> { - protected override Builder ThisBuilder { - get { return this; } + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; + if (InputType.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(InputType); } - internal Builder(MethodDescriptorProto cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; + if (OutputType.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(OutputType); } - - private bool resultIsReadOnly; - private MethodDescriptorProto result; - - private MethodDescriptorProto PrepareBuilder() { - if (resultIsReadOnly) { - MethodDescriptorProto original = result; - result = new MethodDescriptorProto(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } - - public override bool IsInitialized { - get { return result.IsInitialized; } + if (ClientStreaming != false) { + size += 1 + 1; } - - protected override MethodDescriptorProto MessageBeingBuilt { - get { return PrepareBuilder(); } + if (ServerStreaming != false) { + size += 1 + 1; } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; + return size; + } + public void MergeFrom(MethodDescriptorProto other) { + if (other == null) { + return; } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } + if (other.Name.Length != 0) { + Name = other.Name; } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto.Descriptor; } + if (other.InputType.Length != 0) { + InputType = other.InputType; } - - public override MethodDescriptorProto DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto.DefaultInstance; } + if (other.OutputType.Length != 0) { + OutputType = other.OutputType; } - - public override MethodDescriptorProto BuildPartial() { - if (resultIsReadOnly) { - return result; + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.MethodOptions(); } - resultIsReadOnly = true; - return result.MakeReadOnly(); + Options.MergeFrom(other.Options); } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is MethodDescriptorProto) { - return MergeFrom((MethodDescriptorProto) other); - } else { - base.MergeFrom(other); - return this; - } + if (other.ClientStreaming != false) { + ClientStreaming = other.ClientStreaming; + } + if (other.ServerStreaming != false) { + ServerStreaming = other.ServerStreaming; } + } - public override Builder MergeFrom(MethodDescriptorProto other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasName) { - Name = other.Name; - } - if (other.HasInputType) { - InputType = other.InputType; - } - if (other.HasOutputType) { - OutputType = other.OutputType; - } - if (other.HasOptions) { - MergeOptions(other.Options); - } - if (other.HasClientStreaming) { - ClientStreaming = other.ClientStreaming; - } - if (other.HasServerStreaming) { - ServerStreaming = other.ServerStreaming; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_methodDescriptorProtoFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _methodDescriptorProtoFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 10: { + Name = input.ReadString(); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasName = input.ReadString(ref result.name_); - break; - } - case 18: { - result.hasInputType = input.ReadString(ref result.inputType_); - break; - } - case 26: { - result.hasOutputType = input.ReadString(ref result.outputType_); - break; - } - case 34: { - global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.Builder subBuilder = global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.CreateBuilder(); - if (result.hasOptions) { - subBuilder.MergeFrom(Options); - } - input.ReadMessage(subBuilder, extensionRegistry); - Options = subBuilder.BuildPartial(); - break; - } - case 40: { - result.hasClientStreaming = input.ReadBool(ref result.clientStreaming_); - break; - } - case 48: { - result.hasServerStreaming = input.ReadBool(ref result.serverStreaming_); - break; + case 18: { + InputType = input.ReadString(); + break; + } + case 26: { + OutputType = input.ReadString(); + break; + } + case 34: { + if (options_ == null) { + options_ = new global::Google.Protobuf.DescriptorProtos.MethodOptions(); } + input.ReadMessage(options_); + break; + } + case 40: { + ClientStreaming = input.ReadBool(); + break; + } + case 48: { + ServerStreaming = input.ReadBool(); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasName { - get { return result.hasName; } - } - public string Name { - get { return result.Name; } - set { SetName(value); } - } - public Builder SetName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasName = true; - result.name_ = value; - return this; - } - public Builder ClearName() { - PrepareBuilder(); - result.hasName = false; - result.name_ = ""; - return this; - } - - public bool HasInputType { - get { return result.hasInputType; } - } - public string InputType { - get { return result.InputType; } - set { SetInputType(value); } - } - public Builder SetInputType(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasInputType = true; - result.inputType_ = value; - return this; - } - public Builder ClearInputType() { - PrepareBuilder(); - result.hasInputType = false; - result.inputType_ = ""; - return this; - } - - public bool HasOutputType { - get { return result.hasOutputType; } - } - public string OutputType { - get { return result.OutputType; } - set { SetOutputType(value); } - } - public Builder SetOutputType(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOutputType = true; - result.outputType_ = value; - return this; - } - public Builder ClearOutputType() { - PrepareBuilder(); - result.hasOutputType = false; - result.outputType_ = ""; - return this; - } - - public bool HasOptions { - get { return result.hasOptions; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions Options { - get { return result.Options; } - set { SetOptions(value); } - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = value; - return this; - } - public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptions = true; - result.options_ = builderForValue.Build(); - return this; - } - public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptions && - result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.DefaultInstance) { - result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); - } else { - result.options_ = value; - } - result.hasOptions = true; - return this; - } - public Builder ClearOptions() { - PrepareBuilder(); - result.hasOptions = false; - result.options_ = null; - return this; - } - - public bool HasClientStreaming { - get { return result.hasClientStreaming; } - } - public bool ClientStreaming { - get { return result.ClientStreaming; } - set { SetClientStreaming(value); } - } - public Builder SetClientStreaming(bool value) { - PrepareBuilder(); - result.hasClientStreaming = true; - result.clientStreaming_ = value; - return this; - } - public Builder ClearClientStreaming() { - PrepareBuilder(); - result.hasClientStreaming = false; - result.clientStreaming_ = false; - return this; - } - - public bool HasServerStreaming { - get { return result.hasServerStreaming; } - } - public bool ServerStreaming { - get { return result.ServerStreaming; } - set { SetServerStreaming(value); } - } - public Builder SetServerStreaming(bool value) { - PrepareBuilder(); - result.hasServerStreaming = true; - result.serverStreaming_ = value; - return this; } - public Builder ClearServerStreaming() { - PrepareBuilder(); - result.hasServerStreaming = false; - result.serverStreaming_ = false; - return this; - } - } - static MethodDescriptorProto() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); } + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileOptions : pb::ExtendableMessage<FileOptions, FileOptions.Builder> { - private FileOptions() { } - private static readonly FileOptions defaultInstance = new FileOptions().MakeReadOnly(); - private static readonly string[] _fileOptionsFieldNames = new string[] { "cc_enable_arenas", "cc_generic_services", "csharp_namespace", "deprecated", "go_package", "java_generate_equals_and_hash", "java_generic_services", "java_multiple_files", "java_outer_classname", "java_package", "java_string_check_utf8", "objc_class_prefix", "optimize_for", "py_generic_services", "uninterpreted_option" }; - private static readonly uint[] _fileOptionsFieldTags = new uint[] { 248, 128, 298, 184, 90, 160, 136, 80, 66, 10, 216, 290, 72, 144, 7994 }; - public static FileOptions DefaultInstance { - get { return defaultInstance; } - } - - public override FileOptions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FileOptions ThisMessage { - get { return this; } - } + public sealed partial class FileOptions : pb::IMessage<FileOptions>, global::System.IEquatable<FileOptions> { + private static readonly pb::MessageParser<FileOptions> _parser = new pb::MessageParser<FileOptions>(() => new FileOptions()); + public static pb::MessageParser<FileOptions> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "cc_enable_arenas", "cc_generic_services", "csharp_namespace", "deprecated", "go_package", "java_generate_equals_and_hash", "java_generic_services", "java_multiple_files", "java_outer_classname", "java_package", "java_string_check_utf8", "objc_class_prefix", "optimize_for", "py_generic_services", "uninterpreted_option" }; + private static readonly uint[] _fieldTags = new uint[] { 248, 128, 298, 184, 90, 160, 136, 80, 66, 10, 216, 290, 72, 144, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<FileOptions, FileOptions.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<FileOptions> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__FieldAccessorTable; } } - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum OptimizeMode { - SPEED = 1, - CODE_SIZE = 2, - LITE_RUNTIME = 3, - } - + public FileOptions() { } + public FileOptions(FileOptions other) { + MergeFrom(other); } - #endregion - public const int JavaPackageFieldNumber = 1; - private bool hasJavaPackage; private string javaPackage_ = ""; - public bool HasJavaPackage { - get { return hasJavaPackage; } - } public string JavaPackage { get { return javaPackage_; } + set { javaPackage_ = value ?? ""; } } + public const int JavaOuterClassnameFieldNumber = 8; - private bool hasJavaOuterClassname; private string javaOuterClassname_ = ""; - public bool HasJavaOuterClassname { - get { return hasJavaOuterClassname; } - } public string JavaOuterClassname { get { return javaOuterClassname_; } + set { javaOuterClassname_ = value ?? ""; } } + public const int JavaMultipleFilesFieldNumber = 10; - private bool hasJavaMultipleFiles; private bool javaMultipleFiles_; - public bool HasJavaMultipleFiles { - get { return hasJavaMultipleFiles; } - } public bool JavaMultipleFiles { get { return javaMultipleFiles_; } + set { javaMultipleFiles_ = value; } } + public const int JavaGenerateEqualsAndHashFieldNumber = 20; - private bool hasJavaGenerateEqualsAndHash; private bool javaGenerateEqualsAndHash_; - public bool HasJavaGenerateEqualsAndHash { - get { return hasJavaGenerateEqualsAndHash; } - } public bool JavaGenerateEqualsAndHash { get { return javaGenerateEqualsAndHash_; } + set { javaGenerateEqualsAndHash_ = value; } } + public const int JavaStringCheckUtf8FieldNumber = 27; - private bool hasJavaStringCheckUtf8; private bool javaStringCheckUtf8_; - public bool HasJavaStringCheckUtf8 { - get { return hasJavaStringCheckUtf8; } - } public bool JavaStringCheckUtf8 { get { return javaStringCheckUtf8_; } + set { javaStringCheckUtf8_ = value; } } + public const int OptimizeForFieldNumber = 9; - private bool hasOptimizeFor; - private global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Types.OptimizeMode optimizeFor_ = global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED; - public bool HasOptimizeFor { - get { return hasOptimizeFor; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Types.OptimizeMode OptimizeFor { + private global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode optimizeFor_ = global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED; + public global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode OptimizeFor { get { return optimizeFor_; } + set { optimizeFor_ = value; } } + public const int GoPackageFieldNumber = 11; - private bool hasGoPackage; private string goPackage_ = ""; - public bool HasGoPackage { - get { return hasGoPackage; } - } public string GoPackage { get { return goPackage_; } + set { goPackage_ = value ?? ""; } } + public const int CcGenericServicesFieldNumber = 16; - private bool hasCcGenericServices; private bool ccGenericServices_; - public bool HasCcGenericServices { - get { return hasCcGenericServices; } - } public bool CcGenericServices { get { return ccGenericServices_; } + set { ccGenericServices_ = value; } } + public const int JavaGenericServicesFieldNumber = 17; - private bool hasJavaGenericServices; private bool javaGenericServices_; - public bool HasJavaGenericServices { - get { return hasJavaGenericServices; } - } public bool JavaGenericServices { get { return javaGenericServices_; } + set { javaGenericServices_ = value; } } + public const int PyGenericServicesFieldNumber = 18; - private bool hasPyGenericServices; private bool pyGenericServices_; - public bool HasPyGenericServices { - get { return hasPyGenericServices; } - } public bool PyGenericServices { get { return pyGenericServices_; } + set { pyGenericServices_ = value; } } + public const int DeprecatedFieldNumber = 23; - private bool hasDeprecated; private bool deprecated_; - public bool HasDeprecated { - get { return hasDeprecated; } - } public bool Deprecated { get { return deprecated_; } + set { deprecated_ = value; } } + public const int CcEnableArenasFieldNumber = 31; - private bool hasCcEnableArenas; private bool ccEnableArenas_; - public bool HasCcEnableArenas { - get { return hasCcEnableArenas; } - } public bool CcEnableArenas { get { return ccEnableArenas_; } + set { ccEnableArenas_ = value; } } + public const int ObjcClassPrefixFieldNumber = 36; - private bool hasObjcClassPrefix; private string objcClassPrefix_ = ""; - public bool HasObjcClassPrefix { - get { return hasObjcClassPrefix; } - } public string ObjcClassPrefix { get { return objcClassPrefix_; } + set { objcClassPrefix_ = value ?? ""; } } + public const int CsharpNamespaceFieldNumber = 37; - private bool hasCsharpNamespace; private string csharpNamespace_ = ""; - public bool HasCsharpNamespace { - get { return hasCsharpNamespace; } - } public string CsharpNamespace { get { return csharpNamespace_; } + set { csharpNamespace_ = value ?? ""; } } + public const int UninterpretedOptionFieldNumber = 999; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } - public int UninterpretedOptionCount { - get { return uninterpretedOption_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return uninterpretedOption_[index]; - } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - if (!element.IsInitialized) return false; - } - if (!ExtensionsAreInitialized) return false; - return true; - } + public override bool Equals(object other) { + return Equals(other as FileOptions); } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fileOptionsFieldNames; - pb::ExtendableMessage<FileOptions, FileOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - if (hasJavaPackage) { - output.WriteString(1, field_names[9], JavaPackage); - } - if (hasJavaOuterClassname) { - output.WriteString(8, field_names[8], JavaOuterClassname); - } - if (hasOptimizeFor) { - output.WriteEnum(9, field_names[12], (int) OptimizeFor, OptimizeFor); - } - if (hasJavaMultipleFiles) { - output.WriteBool(10, field_names[7], JavaMultipleFiles); - } - if (hasGoPackage) { - output.WriteString(11, field_names[4], GoPackage); - } - if (hasCcGenericServices) { - output.WriteBool(16, field_names[1], CcGenericServices); - } - if (hasJavaGenericServices) { - output.WriteBool(17, field_names[6], JavaGenericServices); + public bool Equals(FileOptions other) { + if (ReferenceEquals(other, null)) { + return false; } - if (hasPyGenericServices) { - output.WriteBool(18, field_names[13], PyGenericServices); - } - if (hasJavaGenerateEqualsAndHash) { - output.WriteBool(20, field_names[5], JavaGenerateEqualsAndHash); - } - if (hasDeprecated) { - output.WriteBool(23, field_names[3], Deprecated); - } - if (hasJavaStringCheckUtf8) { - output.WriteBool(27, field_names[10], JavaStringCheckUtf8); - } - if (hasCcEnableArenas) { - output.WriteBool(31, field_names[0], CcEnableArenas); - } - if (hasObjcClassPrefix) { - output.WriteString(36, field_names[11], ObjcClassPrefix); + if (ReferenceEquals(other, this)) { + return true; } - if (hasCsharpNamespace) { - output.WriteString(37, field_names[2], CsharpNamespace); + if (JavaPackage != other.JavaPackage) return false; + if (JavaOuterClassname != other.JavaOuterClassname) return false; + if (JavaMultipleFiles != other.JavaMultipleFiles) return false; + if (JavaGenerateEqualsAndHash != other.JavaGenerateEqualsAndHash) return false; + if (JavaStringCheckUtf8 != other.JavaStringCheckUtf8) return false; + if (OptimizeFor != other.OptimizeFor) return false; + if (GoPackage != other.GoPackage) return false; + if (CcGenericServices != other.CcGenericServices) return false; + if (JavaGenericServices != other.JavaGenericServices) return false; + if (PyGenericServices != other.PyGenericServices) return false; + if (Deprecated != other.Deprecated) return false; + if (CcEnableArenas != other.CcEnableArenas) return false; + if (ObjcClassPrefix != other.ObjcClassPrefix) return false; + if (CsharpNamespace != other.CsharpNamespace) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 0; + if (JavaPackage.Length != 0) hash ^= JavaPackage.GetHashCode(); + if (JavaOuterClassname.Length != 0) hash ^= JavaOuterClassname.GetHashCode(); + if (JavaMultipleFiles != false) hash ^= JavaMultipleFiles.GetHashCode(); + if (JavaGenerateEqualsAndHash != false) hash ^= JavaGenerateEqualsAndHash.GetHashCode(); + if (JavaStringCheckUtf8 != false) hash ^= JavaStringCheckUtf8.GetHashCode(); + if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) hash ^= OptimizeFor.GetHashCode(); + if (GoPackage.Length != 0) hash ^= GoPackage.GetHashCode(); + if (CcGenericServices != false) hash ^= CcGenericServices.GetHashCode(); + if (JavaGenericServices != false) hash ^= JavaGenericServices.GetHashCode(); + if (PyGenericServices != false) hash ^= PyGenericServices.GetHashCode(); + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + if (CcEnableArenas != false) hash ^= CcEnableArenas.GetHashCode(); + if (ObjcClassPrefix.Length != 0) hash ^= ObjcClassPrefix.GetHashCode(); + if (CsharpNamespace.Length != 0) hash ^= CsharpNamespace.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; + } + + public void WriteTo(pb::CodedOutputStream output) { + if (JavaPackage.Length != 0) { + output.WriteRawTag(10); + output.WriteString(JavaPackage); + } + if (JavaOuterClassname.Length != 0) { + output.WriteRawTag(66); + output.WriteString(JavaOuterClassname); + } + if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { + output.WriteRawTag(72); + output.WriteEnum((int) OptimizeFor); + } + if (JavaMultipleFiles != false) { + output.WriteRawTag(80); + output.WriteBool(JavaMultipleFiles); + } + if (GoPackage.Length != 0) { + output.WriteRawTag(90); + output.WriteString(GoPackage); + } + if (CcGenericServices != false) { + output.WriteRawTag(128, 1); + output.WriteBool(CcGenericServices); + } + if (JavaGenericServices != false) { + output.WriteRawTag(136, 1); + output.WriteBool(JavaGenericServices); + } + if (PyGenericServices != false) { + output.WriteRawTag(144, 1); + output.WriteBool(PyGenericServices); + } + if (JavaGenerateEqualsAndHash != false) { + output.WriteRawTag(160, 1); + output.WriteBool(JavaGenerateEqualsAndHash); + } + if (Deprecated != false) { + output.WriteRawTag(184, 1); + output.WriteBool(Deprecated); + } + if (JavaStringCheckUtf8 != false) { + output.WriteRawTag(216, 1); + output.WriteBool(JavaStringCheckUtf8); + } + if (CcEnableArenas != false) { + output.WriteRawTag(248, 1); + output.WriteBool(CcEnableArenas); + } + if (ObjcClassPrefix.Length != 0) { + output.WriteRawTag(162, 2); + output.WriteString(ObjcClassPrefix); + } + if (CsharpNamespace.Length != 0) { + output.WriteRawTag(170, 2); + output.WriteString(CsharpNamespace); } if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, field_names[14], uninterpretedOption_); + output.WriteMessageArray(999, uninterpretedOption_); } - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasJavaPackage) { - size += pb::CodedOutputStream.ComputeStringSize(1, JavaPackage); + public int CalculateSize() { + int size = 0; + if (JavaPackage.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(JavaPackage); } - if (hasJavaOuterClassname) { - size += pb::CodedOutputStream.ComputeStringSize(8, JavaOuterClassname); + if (JavaOuterClassname.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(JavaOuterClassname); } - if (hasJavaMultipleFiles) { - size += pb::CodedOutputStream.ComputeBoolSize(10, JavaMultipleFiles); + if (JavaMultipleFiles != false) { + size += 1 + 1; } - if (hasJavaGenerateEqualsAndHash) { - size += pb::CodedOutputStream.ComputeBoolSize(20, JavaGenerateEqualsAndHash); + if (JavaGenerateEqualsAndHash != false) { + size += 2 + 1; } - if (hasJavaStringCheckUtf8) { - size += pb::CodedOutputStream.ComputeBoolSize(27, JavaStringCheckUtf8); + if (JavaStringCheckUtf8 != false) { + size += 2 + 1; } - if (hasOptimizeFor) { - size += pb::CodedOutputStream.ComputeEnumSize(9, (int) OptimizeFor); + if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) OptimizeFor); } - if (hasGoPackage) { - size += pb::CodedOutputStream.ComputeStringSize(11, GoPackage); + if (GoPackage.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(GoPackage); } - if (hasCcGenericServices) { - size += pb::CodedOutputStream.ComputeBoolSize(16, CcGenericServices); + if (CcGenericServices != false) { + size += 2 + 1; } - if (hasJavaGenericServices) { - size += pb::CodedOutputStream.ComputeBoolSize(17, JavaGenericServices); + if (JavaGenericServices != false) { + size += 2 + 1; } - if (hasPyGenericServices) { - size += pb::CodedOutputStream.ComputeBoolSize(18, PyGenericServices); + if (PyGenericServices != false) { + size += 2 + 1; } - if (hasDeprecated) { - size += pb::CodedOutputStream.ComputeBoolSize(23, Deprecated); + if (Deprecated != false) { + size += 2 + 1; } - if (hasCcEnableArenas) { - size += pb::CodedOutputStream.ComputeBoolSize(31, CcEnableArenas); + if (CcEnableArenas != false) { + size += 2 + 1; } - if (hasObjcClassPrefix) { - size += pb::CodedOutputStream.ComputeStringSize(36, ObjcClassPrefix); + if (ObjcClassPrefix.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(ObjcClassPrefix); } - if (hasCsharpNamespace) { - size += pb::CodedOutputStream.ComputeStringSize(37, CsharpNamespace); + if (CsharpNamespace.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(CsharpNamespace); } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); + } + size += 2 * uninterpretedOption_.Count; } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; return size; } - public static FileOptions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FileOptions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FileOptions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FileOptions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FileOptions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FileOptions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FileOptions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FileOptions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FileOptions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FileOptions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FileOptions MakeReadOnly() { - uninterpretedOption_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FileOptions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder<FileOptions, Builder> { - protected override Builder ThisBuilder { - get { return this; } + public void MergeFrom(FileOptions other) { + if (other == null) { + return; } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; + if (other.JavaPackage.Length != 0) { + JavaPackage = other.JavaPackage; } - internal Builder(FileOptions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; + if (other.JavaOuterClassname.Length != 0) { + JavaOuterClassname = other.JavaOuterClassname; } - - private bool resultIsReadOnly; - private FileOptions result; - - private FileOptions PrepareBuilder() { - if (resultIsReadOnly) { - FileOptions original = result; - result = new FileOptions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; + if (other.JavaMultipleFiles != false) { + JavaMultipleFiles = other.JavaMultipleFiles; } - - public override bool IsInitialized { - get { return result.IsInitialized; } + if (other.JavaGenerateEqualsAndHash != false) { + JavaGenerateEqualsAndHash = other.JavaGenerateEqualsAndHash; } - - protected override FileOptions MessageBeingBuilt { - get { return PrepareBuilder(); } + if (other.JavaStringCheckUtf8 != false) { + JavaStringCheckUtf8 = other.JavaStringCheckUtf8; } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; + if (other.OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { + OptimizeFor = other.OptimizeFor; } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } + if (other.GoPackage.Length != 0) { + GoPackage = other.GoPackage; } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Descriptor; } + if (other.CcGenericServices != false) { + CcGenericServices = other.CcGenericServices; } - - public override FileOptions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.DefaultInstance; } + if (other.JavaGenericServices != false) { + JavaGenericServices = other.JavaGenericServices; } - - public override FileOptions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); + if (other.PyGenericServices != false) { + PyGenericServices = other.PyGenericServices; } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FileOptions) { - return MergeFrom((FileOptions) other); - } else { - base.MergeFrom(other); - return this; - } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; + } + if (other.CcEnableArenas != false) { + CcEnableArenas = other.CcEnableArenas; + } + if (other.ObjcClassPrefix.Length != 0) { + ObjcClassPrefix = other.ObjcClassPrefix; } + if (other.CsharpNamespace.Length != 0) { + CsharpNamespace = other.CsharpNamespace; + } + uninterpretedOption_.Add(other.uninterpretedOption_); + } - public override Builder MergeFrom(FileOptions other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasJavaPackage) { - JavaPackage = other.JavaPackage; - } - if (other.HasJavaOuterClassname) { - JavaOuterClassname = other.JavaOuterClassname; - } - if (other.HasJavaMultipleFiles) { - JavaMultipleFiles = other.JavaMultipleFiles; - } - if (other.HasJavaGenerateEqualsAndHash) { - JavaGenerateEqualsAndHash = other.JavaGenerateEqualsAndHash; - } - if (other.HasJavaStringCheckUtf8) { - JavaStringCheckUtf8 = other.JavaStringCheckUtf8; - } - if (other.HasOptimizeFor) { - OptimizeFor = other.OptimizeFor; - } - if (other.HasGoPackage) { - GoPackage = other.GoPackage; - } - if (other.HasCcGenericServices) { - CcGenericServices = other.CcGenericServices; - } - if (other.HasJavaGenericServices) { - JavaGenericServices = other.JavaGenericServices; - } - if (other.HasPyGenericServices) { - PyGenericServices = other.PyGenericServices; - } - if (other.HasDeprecated) { - Deprecated = other.Deprecated; - } - if (other.HasCcEnableArenas) { - CcEnableArenas = other.CcEnableArenas; - } - if (other.HasObjcClassPrefix) { - ObjcClassPrefix = other.ObjcClassPrefix; - } - if (other.HasCsharpNamespace) { - CsharpNamespace = other.CsharpNamespace; - } - if (other.uninterpretedOption_.Count != 0) { - result.uninterpretedOption_.Add(other.uninterpretedOption_); - } - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fileOptionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fileOptionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 10: { + JavaPackage = input.ReadString(); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasJavaPackage = input.ReadString(ref result.javaPackage_); - break; - } - case 66: { - result.hasJavaOuterClassname = input.ReadString(ref result.javaOuterClassname_); - break; - } - case 72: { - object unknown; - if(input.ReadEnum(ref result.optimizeFor_, out unknown)) { - result.hasOptimizeFor = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(9, (ulong)(int)unknown); - } - break; - } - case 80: { - result.hasJavaMultipleFiles = input.ReadBool(ref result.javaMultipleFiles_); - break; - } - case 90: { - result.hasGoPackage = input.ReadString(ref result.goPackage_); - break; - } - case 128: { - result.hasCcGenericServices = input.ReadBool(ref result.ccGenericServices_); - break; - } - case 136: { - result.hasJavaGenericServices = input.ReadBool(ref result.javaGenericServices_); - break; - } - case 144: { - result.hasPyGenericServices = input.ReadBool(ref result.pyGenericServices_); - break; - } - case 160: { - result.hasJavaGenerateEqualsAndHash = input.ReadBool(ref result.javaGenerateEqualsAndHash_); - break; - } - case 184: { - result.hasDeprecated = input.ReadBool(ref result.deprecated_); - break; - } - case 216: { - result.hasJavaStringCheckUtf8 = input.ReadBool(ref result.javaStringCheckUtf8_); - break; - } - case 248: { - result.hasCcEnableArenas = input.ReadBool(ref result.ccEnableArenas_); - break; - } - case 290: { - result.hasObjcClassPrefix = input.ReadString(ref result.objcClassPrefix_); - break; - } - case 298: { - result.hasCsharpNamespace = input.ReadString(ref result.csharpNamespace_); - break; - } - case 7994: { - input.ReadMessageArray(tag, field_name, result.uninterpretedOption_, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.DefaultInstance, extensionRegistry); - break; - } + case 66: { + JavaOuterClassname = input.ReadString(); + break; + } + case 72: { + optimizeFor_ = (global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode) input.ReadEnum(); + break; + } + case 80: { + JavaMultipleFiles = input.ReadBool(); + break; + } + case 90: { + GoPackage = input.ReadString(); + break; + } + case 128: { + CcGenericServices = input.ReadBool(); + break; + } + case 136: { + JavaGenericServices = input.ReadBool(); + break; + } + case 144: { + PyGenericServices = input.ReadBool(); + break; + } + case 160: { + JavaGenerateEqualsAndHash = input.ReadBool(); + break; + } + case 184: { + Deprecated = input.ReadBool(); + break; + } + case 216: { + JavaStringCheckUtf8 = input.ReadBool(); + break; + } + case 248: { + CcEnableArenas = input.ReadBool(); + break; + } + case 290: { + ObjcClassPrefix = input.ReadString(); + break; + } + case 298: { + CsharpNamespace = input.ReadString(); + break; + } + case 7994: { + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasJavaPackage { - get { return result.hasJavaPackage; } - } - public string JavaPackage { - get { return result.JavaPackage; } - set { SetJavaPackage(value); } - } - public Builder SetJavaPackage(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasJavaPackage = true; - result.javaPackage_ = value; - return this; - } - public Builder ClearJavaPackage() { - PrepareBuilder(); - result.hasJavaPackage = false; - result.javaPackage_ = ""; - return this; - } - - public bool HasJavaOuterClassname { - get { return result.hasJavaOuterClassname; } - } - public string JavaOuterClassname { - get { return result.JavaOuterClassname; } - set { SetJavaOuterClassname(value); } - } - public Builder SetJavaOuterClassname(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasJavaOuterClassname = true; - result.javaOuterClassname_ = value; - return this; - } - public Builder ClearJavaOuterClassname() { - PrepareBuilder(); - result.hasJavaOuterClassname = false; - result.javaOuterClassname_ = ""; - return this; - } - - public bool HasJavaMultipleFiles { - get { return result.hasJavaMultipleFiles; } - } - public bool JavaMultipleFiles { - get { return result.JavaMultipleFiles; } - set { SetJavaMultipleFiles(value); } - } - public Builder SetJavaMultipleFiles(bool value) { - PrepareBuilder(); - result.hasJavaMultipleFiles = true; - result.javaMultipleFiles_ = value; - return this; - } - public Builder ClearJavaMultipleFiles() { - PrepareBuilder(); - result.hasJavaMultipleFiles = false; - result.javaMultipleFiles_ = false; - return this; - } - - public bool HasJavaGenerateEqualsAndHash { - get { return result.hasJavaGenerateEqualsAndHash; } - } - public bool JavaGenerateEqualsAndHash { - get { return result.JavaGenerateEqualsAndHash; } - set { SetJavaGenerateEqualsAndHash(value); } - } - public Builder SetJavaGenerateEqualsAndHash(bool value) { - PrepareBuilder(); - result.hasJavaGenerateEqualsAndHash = true; - result.javaGenerateEqualsAndHash_ = value; - return this; - } - public Builder ClearJavaGenerateEqualsAndHash() { - PrepareBuilder(); - result.hasJavaGenerateEqualsAndHash = false; - result.javaGenerateEqualsAndHash_ = false; - return this; - } - - public bool HasJavaStringCheckUtf8 { - get { return result.hasJavaStringCheckUtf8; } - } - public bool JavaStringCheckUtf8 { - get { return result.JavaStringCheckUtf8; } - set { SetJavaStringCheckUtf8(value); } - } - public Builder SetJavaStringCheckUtf8(bool value) { - PrepareBuilder(); - result.hasJavaStringCheckUtf8 = true; - result.javaStringCheckUtf8_ = value; - return this; - } - public Builder ClearJavaStringCheckUtf8() { - PrepareBuilder(); - result.hasJavaStringCheckUtf8 = false; - result.javaStringCheckUtf8_ = false; - return this; - } - - public bool HasOptimizeFor { - get { return result.hasOptimizeFor; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Types.OptimizeMode OptimizeFor { - get { return result.OptimizeFor; } - set { SetOptimizeFor(value); } - } - public Builder SetOptimizeFor(global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Types.OptimizeMode value) { - PrepareBuilder(); - result.hasOptimizeFor = true; - result.optimizeFor_ = value; - return this; - } - public Builder ClearOptimizeFor() { - PrepareBuilder(); - result.hasOptimizeFor = false; - result.optimizeFor_ = global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED; - return this; - } - - public bool HasGoPackage { - get { return result.hasGoPackage; } - } - public string GoPackage { - get { return result.GoPackage; } - set { SetGoPackage(value); } - } - public Builder SetGoPackage(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasGoPackage = true; - result.goPackage_ = value; - return this; - } - public Builder ClearGoPackage() { - PrepareBuilder(); - result.hasGoPackage = false; - result.goPackage_ = ""; - return this; } + } - public bool HasCcGenericServices { - get { return result.hasCcGenericServices; } - } - public bool CcGenericServices { - get { return result.CcGenericServices; } - set { SetCcGenericServices(value); } - } - public Builder SetCcGenericServices(bool value) { - PrepareBuilder(); - result.hasCcGenericServices = true; - result.ccGenericServices_ = value; - return this; - } - public Builder ClearCcGenericServices() { - PrepareBuilder(); - result.hasCcGenericServices = false; - result.ccGenericServices_ = false; - return this; - } - - public bool HasJavaGenericServices { - get { return result.hasJavaGenericServices; } - } - public bool JavaGenericServices { - get { return result.JavaGenericServices; } - set { SetJavaGenericServices(value); } - } - public Builder SetJavaGenericServices(bool value) { - PrepareBuilder(); - result.hasJavaGenericServices = true; - result.javaGenericServices_ = value; - return this; - } - public Builder ClearJavaGenericServices() { - PrepareBuilder(); - result.hasJavaGenericServices = false; - result.javaGenericServices_ = false; - return this; - } - - public bool HasPyGenericServices { - get { return result.hasPyGenericServices; } - } - public bool PyGenericServices { - get { return result.PyGenericServices; } - set { SetPyGenericServices(value); } - } - public Builder SetPyGenericServices(bool value) { - PrepareBuilder(); - result.hasPyGenericServices = true; - result.pyGenericServices_ = value; - return this; - } - public Builder ClearPyGenericServices() { - PrepareBuilder(); - result.hasPyGenericServices = false; - result.pyGenericServices_ = false; - return this; - } - - public bool HasDeprecated { - get { return result.hasDeprecated; } - } - public bool Deprecated { - get { return result.Deprecated; } - set { SetDeprecated(value); } - } - public Builder SetDeprecated(bool value) { - PrepareBuilder(); - result.hasDeprecated = true; - result.deprecated_ = value; - return this; - } - public Builder ClearDeprecated() { - PrepareBuilder(); - result.hasDeprecated = false; - result.deprecated_ = false; - return this; - } - - public bool HasCcEnableArenas { - get { return result.hasCcEnableArenas; } - } - public bool CcEnableArenas { - get { return result.CcEnableArenas; } - set { SetCcEnableArenas(value); } - } - public Builder SetCcEnableArenas(bool value) { - PrepareBuilder(); - result.hasCcEnableArenas = true; - result.ccEnableArenas_ = value; - return this; - } - public Builder ClearCcEnableArenas() { - PrepareBuilder(); - result.hasCcEnableArenas = false; - result.ccEnableArenas_ = false; - return this; + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + public enum OptimizeMode { + SPEED = 1, + CODE_SIZE = 2, + LITE_RUNTIME = 3, } - public bool HasObjcClassPrefix { - get { return result.hasObjcClassPrefix; } - } - public string ObjcClassPrefix { - get { return result.ObjcClassPrefix; } - set { SetObjcClassPrefix(value); } - } - public Builder SetObjcClassPrefix(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasObjcClassPrefix = true; - result.objcClassPrefix_ = value; - return this; - } - public Builder ClearObjcClassPrefix() { - PrepareBuilder(); - result.hasObjcClassPrefix = false; - result.objcClassPrefix_ = ""; - return this; - } - - public bool HasCsharpNamespace { - get { return result.hasCsharpNamespace; } - } - public string CsharpNamespace { - get { return result.CsharpNamespace; } - set { SetCsharpNamespace(value); } - } - public Builder SetCsharpNamespace(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasCsharpNamespace = true; - result.csharpNamespace_ = value; - return this; - } - public Builder ClearCsharpNamespace() { - PrepareBuilder(); - result.hasCsharpNamespace = false; - result.csharpNamespace_ = ""; - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { - get { return PrepareBuilder().uninterpretedOption_; } - } - public int UninterpretedOptionCount { - get { return result.UninterpretedOptionCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return result.GetUninterpretedOption(index); - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_[index] = value; - return this; - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_[index] = builderForValue.Build(); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_.Add(value); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeUninterpretedOption(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> values) { - PrepareBuilder(); - result.uninterpretedOption_.Add(values); - return this; - } - public Builder ClearUninterpretedOption() { - PrepareBuilder(); - result.uninterpretedOption_.Clear(); - return this; - } - } - static FileOptions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); } + #endregion + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MessageOptions : pb::ExtendableMessage<MessageOptions, MessageOptions.Builder> { - private MessageOptions() { } - private static readonly MessageOptions defaultInstance = new MessageOptions().MakeReadOnly(); - private static readonly string[] _messageOptionsFieldNames = new string[] { "deprecated", "map_entry", "message_set_wire_format", "no_standard_descriptor_accessor", "uninterpreted_option" }; - private static readonly uint[] _messageOptionsFieldTags = new uint[] { 24, 56, 8, 16, 7994 }; - public static MessageOptions DefaultInstance { - get { return defaultInstance; } - } - - public override MessageOptions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override MessageOptions ThisMessage { - get { return this; } - } + public sealed partial class MessageOptions : pb::IMessage<MessageOptions>, global::System.IEquatable<MessageOptions> { + private static readonly pb::MessageParser<MessageOptions> _parser = new pb::MessageParser<MessageOptions>(() => new MessageOptions()); + public static pb::MessageParser<MessageOptions> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "deprecated", "map_entry", "message_set_wire_format", "no_standard_descriptor_accessor", "uninterpreted_option" }; + private static readonly uint[] _fieldTags = new uint[] { 24, 56, 8, 16, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<MessageOptions, MessageOptions.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<MessageOptions> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__FieldAccessorTable; } } + public MessageOptions() { } + public MessageOptions(MessageOptions other) { + MergeFrom(other); + } public const int MessageSetWireFormatFieldNumber = 1; - private bool hasMessageSetWireFormat; private bool messageSetWireFormat_; - public bool HasMessageSetWireFormat { - get { return hasMessageSetWireFormat; } - } public bool MessageSetWireFormat { get { return messageSetWireFormat_; } + set { messageSetWireFormat_ = value; } } + public const int NoStandardDescriptorAccessorFieldNumber = 2; - private bool hasNoStandardDescriptorAccessor; private bool noStandardDescriptorAccessor_; - public bool HasNoStandardDescriptorAccessor { - get { return hasNoStandardDescriptorAccessor; } - } public bool NoStandardDescriptorAccessor { get { return noStandardDescriptorAccessor_; } + set { noStandardDescriptorAccessor_ = value; } } + public const int DeprecatedFieldNumber = 3; - private bool hasDeprecated; private bool deprecated_; - public bool HasDeprecated { - get { return hasDeprecated; } - } public bool Deprecated { get { return deprecated_; } + set { deprecated_ = value; } } + public const int MapEntryFieldNumber = 7; - private bool hasMapEntry; private bool mapEntry_; - public bool HasMapEntry { - get { return hasMapEntry; } - } public bool MapEntry { get { return mapEntry_; } + set { mapEntry_ = value; } } + public const int UninterpretedOptionFieldNumber = 999; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } - public int UninterpretedOptionCount { - get { return uninterpretedOption_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return uninterpretedOption_[index]; - } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - if (!element.IsInitialized) return false; - } - if (!ExtensionsAreInitialized) return false; - return true; - } + public override bool Equals(object other) { + return Equals(other as MessageOptions); } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _messageOptionsFieldNames; - pb::ExtendableMessage<MessageOptions, MessageOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - if (hasMessageSetWireFormat) { - output.WriteBool(1, field_names[2], MessageSetWireFormat); - } - if (hasNoStandardDescriptorAccessor) { - output.WriteBool(2, field_names[3], NoStandardDescriptorAccessor); - } - if (hasDeprecated) { - output.WriteBool(3, field_names[0], Deprecated); + public bool Equals(MessageOptions other) { + if (ReferenceEquals(other, null)) { + return false; } - if (hasMapEntry) { - output.WriteBool(7, field_names[1], MapEntry); - } - if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, field_names[4], uninterpretedOption_); + if (ReferenceEquals(other, this)) { + return true; } - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); + if (MessageSetWireFormat != other.MessageSetWireFormat) return false; + if (NoStandardDescriptorAccessor != other.NoStandardDescriptorAccessor) return false; + if (Deprecated != other.Deprecated) return false; + if (MapEntry != other.MapEntry) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } + public override int GetHashCode() { + int hash = 0; + if (MessageSetWireFormat != false) hash ^= MessageSetWireFormat.GetHashCode(); + if (NoStandardDescriptorAccessor != false) hash ^= NoStandardDescriptorAccessor.GetHashCode(); + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + if (MapEntry != false) hash ^= MapEntry.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasMessageSetWireFormat) { - size += pb::CodedOutputStream.ComputeBoolSize(1, MessageSetWireFormat); + public void WriteTo(pb::CodedOutputStream output) { + if (MessageSetWireFormat != false) { + output.WriteRawTag(8); + output.WriteBool(MessageSetWireFormat); } - if (hasNoStandardDescriptorAccessor) { - size += pb::CodedOutputStream.ComputeBoolSize(2, NoStandardDescriptorAccessor); + if (NoStandardDescriptorAccessor != false) { + output.WriteRawTag(16); + output.WriteBool(NoStandardDescriptorAccessor); } - if (hasDeprecated) { - size += pb::CodedOutputStream.ComputeBoolSize(3, Deprecated); + if (Deprecated != false) { + output.WriteRawTag(24); + output.WriteBool(Deprecated); } - if (hasMapEntry) { - size += pb::CodedOutputStream.ComputeBoolSize(7, MapEntry); + if (MapEntry != false) { + output.WriteRawTag(56); + output.WriteBool(MapEntry); } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + output.WriteMessageArray(999, uninterpretedOption_); } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static MessageOptions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MessageOptions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MessageOptions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MessageOptions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MessageOptions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MessageOptions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static MessageOptions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static MessageOptions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static MessageOptions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MessageOptions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private MessageOptions MakeReadOnly() { - uninterpretedOption_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(MessageOptions prototype) { - return new Builder(prototype); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder<MessageOptions, Builder> { - protected override Builder ThisBuilder { - get { return this; } + public int CalculateSize() { + int size = 0; + if (MessageSetWireFormat != false) { + size += 1 + 1; } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; + if (NoStandardDescriptorAccessor != false) { + size += 1 + 1; } - internal Builder(MessageOptions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; + if (Deprecated != false) { + size += 1 + 1; } - - private bool resultIsReadOnly; - private MessageOptions result; - - private MessageOptions PrepareBuilder() { - if (resultIsReadOnly) { - MessageOptions original = result; - result = new MessageOptions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override MessageOptions MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; + if (MapEntry != false) { + size += 1 + 1; } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * uninterpretedOption_.Count; } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.Descriptor; } + return size; + } + public void MergeFrom(MessageOptions other) { + if (other == null) { + return; } - - public override MessageOptions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.DefaultInstance; } + if (other.MessageSetWireFormat != false) { + MessageSetWireFormat = other.MessageSetWireFormat; } - - public override MessageOptions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); + if (other.NoStandardDescriptorAccessor != false) { + NoStandardDescriptorAccessor = other.NoStandardDescriptorAccessor; } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is MessageOptions) { - return MergeFrom((MessageOptions) other); - } else { - base.MergeFrom(other); - return this; - } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; } + if (other.MapEntry != false) { + MapEntry = other.MapEntry; + } + uninterpretedOption_.Add(other.uninterpretedOption_); + } - public override Builder MergeFrom(MessageOptions other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasMessageSetWireFormat) { - MessageSetWireFormat = other.MessageSetWireFormat; - } - if (other.HasNoStandardDescriptorAccessor) { - NoStandardDescriptorAccessor = other.NoStandardDescriptorAccessor; - } - if (other.HasDeprecated) { - Deprecated = other.Deprecated; - } - if (other.HasMapEntry) { - MapEntry = other.MapEntry; - } - if (other.uninterpretedOption_.Count != 0) { - result.uninterpretedOption_.Add(other.uninterpretedOption_); - } - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_messageOptionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _messageOptionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 8: { + MessageSetWireFormat = input.ReadBool(); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasMessageSetWireFormat = input.ReadBool(ref result.messageSetWireFormat_); - break; - } - case 16: { - result.hasNoStandardDescriptorAccessor = input.ReadBool(ref result.noStandardDescriptorAccessor_); - break; - } - case 24: { - result.hasDeprecated = input.ReadBool(ref result.deprecated_); - break; - } - case 56: { - result.hasMapEntry = input.ReadBool(ref result.mapEntry_); - break; - } - case 7994: { - input.ReadMessageArray(tag, field_name, result.uninterpretedOption_, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.DefaultInstance, extensionRegistry); - break; - } + case 16: { + NoStandardDescriptorAccessor = input.ReadBool(); + break; + } + case 24: { + Deprecated = input.ReadBool(); + break; + } + case 56: { + MapEntry = input.ReadBool(); + break; + } + case 7994: { + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasMessageSetWireFormat { - get { return result.hasMessageSetWireFormat; } - } - public bool MessageSetWireFormat { - get { return result.MessageSetWireFormat; } - set { SetMessageSetWireFormat(value); } - } - public Builder SetMessageSetWireFormat(bool value) { - PrepareBuilder(); - result.hasMessageSetWireFormat = true; - result.messageSetWireFormat_ = value; - return this; - } - public Builder ClearMessageSetWireFormat() { - PrepareBuilder(); - result.hasMessageSetWireFormat = false; - result.messageSetWireFormat_ = false; - return this; - } - - public bool HasNoStandardDescriptorAccessor { - get { return result.hasNoStandardDescriptorAccessor; } - } - public bool NoStandardDescriptorAccessor { - get { return result.NoStandardDescriptorAccessor; } - set { SetNoStandardDescriptorAccessor(value); } - } - public Builder SetNoStandardDescriptorAccessor(bool value) { - PrepareBuilder(); - result.hasNoStandardDescriptorAccessor = true; - result.noStandardDescriptorAccessor_ = value; - return this; - } - public Builder ClearNoStandardDescriptorAccessor() { - PrepareBuilder(); - result.hasNoStandardDescriptorAccessor = false; - result.noStandardDescriptorAccessor_ = false; - return this; - } - - public bool HasDeprecated { - get { return result.hasDeprecated; } - } - public bool Deprecated { - get { return result.Deprecated; } - set { SetDeprecated(value); } - } - public Builder SetDeprecated(bool value) { - PrepareBuilder(); - result.hasDeprecated = true; - result.deprecated_ = value; - return this; - } - public Builder ClearDeprecated() { - PrepareBuilder(); - result.hasDeprecated = false; - result.deprecated_ = false; - return this; - } - - public bool HasMapEntry { - get { return result.hasMapEntry; } - } - public bool MapEntry { - get { return result.MapEntry; } - set { SetMapEntry(value); } - } - public Builder SetMapEntry(bool value) { - PrepareBuilder(); - result.hasMapEntry = true; - result.mapEntry_ = value; - return this; } - public Builder ClearMapEntry() { - PrepareBuilder(); - result.hasMapEntry = false; - result.mapEntry_ = false; - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { - get { return PrepareBuilder().uninterpretedOption_; } - } - public int UninterpretedOptionCount { - get { return result.UninterpretedOptionCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return result.GetUninterpretedOption(index); - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_[index] = value; - return this; - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_[index] = builderForValue.Build(); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_.Add(value); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeUninterpretedOption(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> values) { - PrepareBuilder(); - result.uninterpretedOption_.Add(values); - return this; - } - public Builder ClearUninterpretedOption() { - PrepareBuilder(); - result.uninterpretedOption_.Clear(); - return this; - } - } - static MessageOptions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); } + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FieldOptions : pb::ExtendableMessage<FieldOptions, FieldOptions.Builder> { - private FieldOptions() { } - private static readonly FieldOptions defaultInstance = new FieldOptions().MakeReadOnly(); - private static readonly string[] _fieldOptionsFieldNames = new string[] { "ctype", "deprecated", "jstype", "lazy", "packed", "uninterpreted_option", "weak" }; - private static readonly uint[] _fieldOptionsFieldTags = new uint[] { 8, 24, 48, 40, 16, 7994, 80 }; - public static FieldOptions DefaultInstance { - get { return defaultInstance; } - } - - public override FieldOptions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FieldOptions ThisMessage { - get { return this; } - } + public sealed partial class FieldOptions : pb::IMessage<FieldOptions>, global::System.IEquatable<FieldOptions> { + private static readonly pb::MessageParser<FieldOptions> _parser = new pb::MessageParser<FieldOptions>(() => new FieldOptions()); + public static pb::MessageParser<FieldOptions> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "ctype", "deprecated", "jstype", "lazy", "packed", "uninterpreted_option", "weak" }; + private static readonly uint[] _fieldTags = new uint[] { 8, 24, 48, 40, 16, 7994, 80 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<FieldOptions, FieldOptions.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<FieldOptions> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__FieldAccessorTable; } } - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum CType { - STRING = 0, - CORD = 1, - STRING_PIECE = 2, - } - - public enum JSType { - JS_NORMAL = 0, - JS_STRING = 1, - JS_NUMBER = 2, - } - + public FieldOptions() { } + public FieldOptions(FieldOptions other) { + MergeFrom(other); } - #endregion - public const int CtypeFieldNumber = 1; - private bool hasCtype; - private global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.CType ctype_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.CType.STRING; - public bool HasCtype { - get { return hasCtype; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.CType Ctype { + private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType ctype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING; + public global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType Ctype { get { return ctype_; } + set { ctype_ = value; } } + public const int PackedFieldNumber = 2; - private bool hasPacked; private bool packed_; - public bool HasPacked { - get { return hasPacked; } - } public bool Packed { get { return packed_; } + set { packed_ = value; } } + public const int JstypeFieldNumber = 6; - private bool hasJstype; - private global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.JSType jstype_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL; - public bool HasJstype { - get { return hasJstype; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.JSType Jstype { + private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType jstype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL; + public global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType Jstype { get { return jstype_; } + set { jstype_ = value; } } + public const int LazyFieldNumber = 5; - private bool hasLazy; private bool lazy_; - public bool HasLazy { - get { return hasLazy; } - } public bool Lazy { get { return lazy_; } + set { lazy_ = value; } } + public const int DeprecatedFieldNumber = 3; - private bool hasDeprecated; private bool deprecated_; - public bool HasDeprecated { - get { return hasDeprecated; } - } public bool Deprecated { get { return deprecated_; } + set { deprecated_ = value; } } + public const int WeakFieldNumber = 10; - private bool hasWeak; private bool weak_; - public bool HasWeak { - get { return hasWeak; } - } public bool Weak { get { return weak_; } + set { weak_ = value; } } + public const int UninterpretedOptionFieldNumber = 999; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } - public int UninterpretedOptionCount { - get { return uninterpretedOption_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return uninterpretedOption_[index]; - } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - if (!element.IsInitialized) return false; - } - if (!ExtensionsAreInitialized) return false; - return true; - } + public override bool Equals(object other) { + return Equals(other as FieldOptions); } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fieldOptionsFieldNames; - pb::ExtendableMessage<FieldOptions, FieldOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - if (hasCtype) { - output.WriteEnum(1, field_names[0], (int) Ctype, Ctype); - } - if (hasPacked) { - output.WriteBool(2, field_names[4], Packed); - } - if (hasDeprecated) { - output.WriteBool(3, field_names[1], Deprecated); + public bool Equals(FieldOptions other) { + if (ReferenceEquals(other, null)) { + return false; } - if (hasLazy) { - output.WriteBool(5, field_names[3], Lazy); - } - if (hasJstype) { - output.WriteEnum(6, field_names[2], (int) Jstype, Jstype); + if (ReferenceEquals(other, this)) { + return true; } - if (hasWeak) { - output.WriteBool(10, field_names[6], Weak); + if (Ctype != other.Ctype) return false; + if (Packed != other.Packed) return false; + if (Jstype != other.Jstype) return false; + if (Lazy != other.Lazy) return false; + if (Deprecated != other.Deprecated) return false; + if (Weak != other.Weak) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 0; + if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) hash ^= Ctype.GetHashCode(); + if (Packed != false) hash ^= Packed.GetHashCode(); + if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) hash ^= Jstype.GetHashCode(); + if (Lazy != false) hash ^= Lazy.GetHashCode(); + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + if (Weak != false) hash ^= Weak.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) { + output.WriteRawTag(8); + output.WriteEnum((int) Ctype); + } + if (Packed != false) { + output.WriteRawTag(16); + output.WriteBool(Packed); + } + if (Deprecated != false) { + output.WriteRawTag(24); + output.WriteBool(Deprecated); + } + if (Lazy != false) { + output.WriteRawTag(40); + output.WriteBool(Lazy); + } + if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) { + output.WriteRawTag(48); + output.WriteEnum((int) Jstype); + } + if (Weak != false) { + output.WriteRawTag(80); + output.WriteBool(Weak); } if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, field_names[5], uninterpretedOption_); + output.WriteMessageArray(999, uninterpretedOption_); } - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); + public int CalculateSize() { + int size = 0; + if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Ctype); } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasCtype) { - size += pb::CodedOutputStream.ComputeEnumSize(1, (int) Ctype); + if (Packed != false) { + size += 1 + 1; } - if (hasPacked) { - size += pb::CodedOutputStream.ComputeBoolSize(2, Packed); + if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Jstype); } - if (hasJstype) { - size += pb::CodedOutputStream.ComputeEnumSize(6, (int) Jstype); + if (Lazy != false) { + size += 1 + 1; } - if (hasLazy) { - size += pb::CodedOutputStream.ComputeBoolSize(5, Lazy); + if (Deprecated != false) { + size += 1 + 1; } - if (hasDeprecated) { - size += pb::CodedOutputStream.ComputeBoolSize(3, Deprecated); + if (Weak != false) { + size += 1 + 1; } - if (hasWeak) { - size += pb::CodedOutputStream.ComputeBoolSize(10, Weak); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); + } + size += 2 * uninterpretedOption_.Count; } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; return size; } - public static FieldOptions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FieldOptions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FieldOptions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FieldOptions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FieldOptions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FieldOptions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FieldOptions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FieldOptions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FieldOptions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FieldOptions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FieldOptions MakeReadOnly() { - uninterpretedOption_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FieldOptions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder<FieldOptions, Builder> { - protected override Builder ThisBuilder { - get { return this; } + public void MergeFrom(FieldOptions other) { + if (other == null) { + return; } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; + if (other.Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) { + Ctype = other.Ctype; } - internal Builder(FieldOptions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; + if (other.Packed != false) { + Packed = other.Packed; } - - private bool resultIsReadOnly; - private FieldOptions result; - - private FieldOptions PrepareBuilder() { - if (resultIsReadOnly) { - FieldOptions original = result; - result = new FieldOptions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; + if (other.Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) { + Jstype = other.Jstype; } - - public override bool IsInitialized { - get { return result.IsInitialized; } + if (other.Lazy != false) { + Lazy = other.Lazy; } - - protected override FieldOptions MessageBeingBuilt { - get { return PrepareBuilder(); } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Descriptor; } - } - - public override FieldOptions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.DefaultInstance; } - } - - public override FieldOptions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FieldOptions) { - return MergeFrom((FieldOptions) other); - } else { - base.MergeFrom(other); - return this; - } + if (other.Weak != false) { + Weak = other.Weak; } + uninterpretedOption_.Add(other.uninterpretedOption_); + } - public override Builder MergeFrom(FieldOptions other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasCtype) { - Ctype = other.Ctype; - } - if (other.HasPacked) { - Packed = other.Packed; - } - if (other.HasJstype) { - Jstype = other.Jstype; - } - if (other.HasLazy) { - Lazy = other.Lazy; - } - if (other.HasDeprecated) { - Deprecated = other.Deprecated; - } - if (other.HasWeak) { - Weak = other.Weak; - } - if (other.uninterpretedOption_.Count != 0) { - result.uninterpretedOption_.Add(other.uninterpretedOption_); - } - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fieldOptionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fieldOptionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 8: { + ctype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType) input.ReadEnum(); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - object unknown; - if(input.ReadEnum(ref result.ctype_, out unknown)) { - result.hasCtype = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(1, (ulong)(int)unknown); - } - break; - } - case 16: { - result.hasPacked = input.ReadBool(ref result.packed_); - break; - } - case 24: { - result.hasDeprecated = input.ReadBool(ref result.deprecated_); - break; - } - case 40: { - result.hasLazy = input.ReadBool(ref result.lazy_); - break; - } - case 48: { - object unknown; - if(input.ReadEnum(ref result.jstype_, out unknown)) { - result.hasJstype = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(6, (ulong)(int)unknown); - } - break; - } - case 80: { - result.hasWeak = input.ReadBool(ref result.weak_); - break; - } - case 7994: { - input.ReadMessageArray(tag, field_name, result.uninterpretedOption_, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.DefaultInstance, extensionRegistry); - break; - } + case 16: { + Packed = input.ReadBool(); + break; + } + case 24: { + Deprecated = input.ReadBool(); + break; + } + case 40: { + Lazy = input.ReadBool(); + break; + } + case 48: { + jstype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType) input.ReadEnum(); + break; + } + case 80: { + Weak = input.ReadBool(); + break; + } + case 7994: { + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasCtype { - get { return result.hasCtype; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.CType Ctype { - get { return result.Ctype; } - set { SetCtype(value); } - } - public Builder SetCtype(global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.CType value) { - PrepareBuilder(); - result.hasCtype = true; - result.ctype_ = value; - return this; - } - public Builder ClearCtype() { - PrepareBuilder(); - result.hasCtype = false; - result.ctype_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.CType.STRING; - return this; - } - - public bool HasPacked { - get { return result.hasPacked; } - } - public bool Packed { - get { return result.Packed; } - set { SetPacked(value); } - } - public Builder SetPacked(bool value) { - PrepareBuilder(); - result.hasPacked = true; - result.packed_ = value; - return this; - } - public Builder ClearPacked() { - PrepareBuilder(); - result.hasPacked = false; - result.packed_ = false; - return this; - } - - public bool HasJstype { - get { return result.hasJstype; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.JSType Jstype { - get { return result.Jstype; } - set { SetJstype(value); } - } - public Builder SetJstype(global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.JSType value) { - PrepareBuilder(); - result.hasJstype = true; - result.jstype_ = value; - return this; - } - public Builder ClearJstype() { - PrepareBuilder(); - result.hasJstype = false; - result.jstype_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL; - return this; - } - - public bool HasLazy { - get { return result.hasLazy; } - } - public bool Lazy { - get { return result.Lazy; } - set { SetLazy(value); } - } - public Builder SetLazy(bool value) { - PrepareBuilder(); - result.hasLazy = true; - result.lazy_ = value; - return this; - } - public Builder ClearLazy() { - PrepareBuilder(); - result.hasLazy = false; - result.lazy_ = false; - return this; } + } - public bool HasDeprecated { - get { return result.hasDeprecated; } - } - public bool Deprecated { - get { return result.Deprecated; } - set { SetDeprecated(value); } - } - public Builder SetDeprecated(bool value) { - PrepareBuilder(); - result.hasDeprecated = true; - result.deprecated_ = value; - return this; - } - public Builder ClearDeprecated() { - PrepareBuilder(); - result.hasDeprecated = false; - result.deprecated_ = false; - return this; + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + public enum CType { + STRING = 0, + CORD = 1, + STRING_PIECE = 2, } - public bool HasWeak { - get { return result.hasWeak; } - } - public bool Weak { - get { return result.Weak; } - set { SetWeak(value); } - } - public Builder SetWeak(bool value) { - PrepareBuilder(); - result.hasWeak = true; - result.weak_ = value; - return this; - } - public Builder ClearWeak() { - PrepareBuilder(); - result.hasWeak = false; - result.weak_ = false; - return this; + public enum JSType { + JS_NORMAL = 0, + JS_STRING = 1, + JS_NUMBER = 2, } - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { - get { return PrepareBuilder().uninterpretedOption_; } - } - public int UninterpretedOptionCount { - get { return result.UninterpretedOptionCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return result.GetUninterpretedOption(index); - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_[index] = value; - return this; - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_[index] = builderForValue.Build(); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_.Add(value); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeUninterpretedOption(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> values) { - PrepareBuilder(); - result.uninterpretedOption_.Add(values); - return this; - } - public Builder ClearUninterpretedOption() { - PrepareBuilder(); - result.uninterpretedOption_.Clear(); - return this; - } - } - static FieldOptions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); } + #endregion + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumOptions : pb::ExtendableMessage<EnumOptions, EnumOptions.Builder> { - private EnumOptions() { } - private static readonly EnumOptions defaultInstance = new EnumOptions().MakeReadOnly(); - private static readonly string[] _enumOptionsFieldNames = new string[] { "allow_alias", "deprecated", "uninterpreted_option" }; - private static readonly uint[] _enumOptionsFieldTags = new uint[] { 16, 24, 7994 }; - public static EnumOptions DefaultInstance { - get { return defaultInstance; } - } - - public override EnumOptions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override EnumOptions ThisMessage { - get { return this; } - } + public sealed partial class EnumOptions : pb::IMessage<EnumOptions>, global::System.IEquatable<EnumOptions> { + private static readonly pb::MessageParser<EnumOptions> _parser = new pb::MessageParser<EnumOptions>(() => new EnumOptions()); + public static pb::MessageParser<EnumOptions> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "allow_alias", "deprecated", "uninterpreted_option" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 24, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<EnumOptions, EnumOptions.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<EnumOptions> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__FieldAccessorTable; } } + public EnumOptions() { } + public EnumOptions(EnumOptions other) { + MergeFrom(other); + } public const int AllowAliasFieldNumber = 2; - private bool hasAllowAlias; private bool allowAlias_; - public bool HasAllowAlias { - get { return hasAllowAlias; } - } public bool AllowAlias { get { return allowAlias_; } + set { allowAlias_ = value; } } + public const int DeprecatedFieldNumber = 3; - private bool hasDeprecated; private bool deprecated_; - public bool HasDeprecated { - get { return hasDeprecated; } - } public bool Deprecated { get { return deprecated_; } + set { deprecated_ = value; } } + public const int UninterpretedOptionFieldNumber = 999; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } - public int UninterpretedOptionCount { - get { return uninterpretedOption_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return uninterpretedOption_[index]; - } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - if (!element.IsInitialized) return false; - } - if (!ExtensionsAreInitialized) return false; - return true; - } + public override bool Equals(object other) { + return Equals(other as EnumOptions); } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _enumOptionsFieldNames; - pb::ExtendableMessage<EnumOptions, EnumOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - if (hasAllowAlias) { - output.WriteBool(2, field_names[0], AllowAlias); + public bool Equals(EnumOptions other) { + if (ReferenceEquals(other, null)) { + return false; } - if (hasDeprecated) { - output.WriteBool(3, field_names[1], Deprecated); - } - if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, field_names[2], uninterpretedOption_); + if (ReferenceEquals(other, this)) { + return true; } - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); + if (AllowAlias != other.AllowAlias) return false; + if (Deprecated != other.Deprecated) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } + public override int GetHashCode() { + int hash = 0; + if (AllowAlias != false) hash ^= AllowAlias.GetHashCode(); + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasAllowAlias) { - size += pb::CodedOutputStream.ComputeBoolSize(2, AllowAlias); + public void WriteTo(pb::CodedOutputStream output) { + if (AllowAlias != false) { + output.WriteRawTag(16); + output.WriteBool(AllowAlias); } - if (hasDeprecated) { - size += pb::CodedOutputStream.ComputeBoolSize(3, Deprecated); + if (Deprecated != false) { + output.WriteRawTag(24); + output.WriteBool(Deprecated); } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + output.WriteMessageArray(999, uninterpretedOption_); } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static EnumOptions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static EnumOptions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static EnumOptions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } - public static EnumOptions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static EnumOptions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static EnumOptions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static EnumOptions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static EnumOptions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static EnumOptions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static EnumOptions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private EnumOptions MakeReadOnly() { - uninterpretedOption_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(EnumOptions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder<EnumOptions, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(EnumOptions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private EnumOptions result; - - private EnumOptions PrepareBuilder() { - if (resultIsReadOnly) { - EnumOptions original = result; - result = new EnumOptions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - protected override EnumOptions MessageBeingBuilt { - get { return PrepareBuilder(); } + public int CalculateSize() { + int size = 0; + if (AllowAlias != false) { + size += 1 + 1; } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; + if (Deprecated != false) { + size += 1 + 1; } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * uninterpretedOption_.Count; } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.Descriptor; } + return size; + } + public void MergeFrom(EnumOptions other) { + if (other == null) { + return; } - - public override EnumOptions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.DefaultInstance; } + if (other.AllowAlias != false) { + AllowAlias = other.AllowAlias; } - - public override EnumOptions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is EnumOptions) { - return MergeFrom((EnumOptions) other); - } else { - base.MergeFrom(other); - return this; - } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; } + uninterpretedOption_.Add(other.uninterpretedOption_); + } - public override Builder MergeFrom(EnumOptions other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasAllowAlias) { - AllowAlias = other.AllowAlias; - } - if (other.HasDeprecated) { - Deprecated = other.Deprecated; - } - if (other.uninterpretedOption_.Count != 0) { - result.uninterpretedOption_.Add(other.uninterpretedOption_); - } - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_enumOptionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _enumOptionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 16: { + AllowAlias = input.ReadBool(); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 16: { - result.hasAllowAlias = input.ReadBool(ref result.allowAlias_); - break; - } - case 24: { - result.hasDeprecated = input.ReadBool(ref result.deprecated_); - break; - } - case 7994: { - input.ReadMessageArray(tag, field_name, result.uninterpretedOption_, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.DefaultInstance, extensionRegistry); - break; - } + case 24: { + Deprecated = input.ReadBool(); + break; + } + case 7994: { + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasAllowAlias { - get { return result.hasAllowAlias; } - } - public bool AllowAlias { - get { return result.AllowAlias; } - set { SetAllowAlias(value); } - } - public Builder SetAllowAlias(bool value) { - PrepareBuilder(); - result.hasAllowAlias = true; - result.allowAlias_ = value; - return this; - } - public Builder ClearAllowAlias() { - PrepareBuilder(); - result.hasAllowAlias = false; - result.allowAlias_ = false; - return this; - } - - public bool HasDeprecated { - get { return result.hasDeprecated; } - } - public bool Deprecated { - get { return result.Deprecated; } - set { SetDeprecated(value); } - } - public Builder SetDeprecated(bool value) { - PrepareBuilder(); - result.hasDeprecated = true; - result.deprecated_ = value; - return this; } - public Builder ClearDeprecated() { - PrepareBuilder(); - result.hasDeprecated = false; - result.deprecated_ = false; - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { - get { return PrepareBuilder().uninterpretedOption_; } - } - public int UninterpretedOptionCount { - get { return result.UninterpretedOptionCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return result.GetUninterpretedOption(index); - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_[index] = value; - return this; - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_[index] = builderForValue.Build(); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_.Add(value); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeUninterpretedOption(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> values) { - PrepareBuilder(); - result.uninterpretedOption_.Add(values); - return this; - } - public Builder ClearUninterpretedOption() { - PrepareBuilder(); - result.uninterpretedOption_.Clear(); - return this; - } - } - static EnumOptions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); } + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumValueOptions : pb::ExtendableMessage<EnumValueOptions, EnumValueOptions.Builder> { - private EnumValueOptions() { } - private static readonly EnumValueOptions defaultInstance = new EnumValueOptions().MakeReadOnly(); - private static readonly string[] _enumValueOptionsFieldNames = new string[] { "deprecated", "uninterpreted_option" }; - private static readonly uint[] _enumValueOptionsFieldTags = new uint[] { 8, 7994 }; - public static EnumValueOptions DefaultInstance { - get { return defaultInstance; } - } - - public override EnumValueOptions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override EnumValueOptions ThisMessage { - get { return this; } - } + public sealed partial class EnumValueOptions : pb::IMessage<EnumValueOptions>, global::System.IEquatable<EnumValueOptions> { + private static readonly pb::MessageParser<EnumValueOptions> _parser = new pb::MessageParser<EnumValueOptions>(() => new EnumValueOptions()); + public static pb::MessageParser<EnumValueOptions> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; + private static readonly uint[] _fieldTags = new uint[] { 8, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<EnumValueOptions, EnumValueOptions.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<EnumValueOptions> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; } } + public EnumValueOptions() { } + public EnumValueOptions(EnumValueOptions other) { + MergeFrom(other); + } public const int DeprecatedFieldNumber = 1; - private bool hasDeprecated; private bool deprecated_; - public bool HasDeprecated { - get { return hasDeprecated; } - } public bool Deprecated { get { return deprecated_; } + set { deprecated_ = value; } } + public const int UninterpretedOptionFieldNumber = 999; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } - public int UninterpretedOptionCount { - get { return uninterpretedOption_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return uninterpretedOption_[index]; - } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - if (!element.IsInitialized) return false; - } - if (!ExtensionsAreInitialized) return false; - return true; - } + public override bool Equals(object other) { + return Equals(other as EnumValueOptions); } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _enumValueOptionsFieldNames; - pb::ExtendableMessage<EnumValueOptions, EnumValueOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - if (hasDeprecated) { - output.WriteBool(1, field_names[0], Deprecated); + public bool Equals(EnumValueOptions other) { + if (ReferenceEquals(other, null)) { + return false; } - if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, field_names[1], uninterpretedOption_); + if (ReferenceEquals(other, this)) { + return true; } - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); + if (Deprecated != other.Deprecated) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } + public override int GetHashCode() { + int hash = 0; + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasDeprecated) { - size += pb::CodedOutputStream.ComputeBoolSize(1, Deprecated); + public void WriteTo(pb::CodedOutputStream output) { + if (Deprecated != false) { + output.WriteRawTag(8); + output.WriteBool(Deprecated); } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + output.WriteMessageArray(999, uninterpretedOption_); } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static EnumValueOptions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static EnumValueOptions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static EnumValueOptions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static EnumValueOptions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static EnumValueOptions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static EnumValueOptions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static EnumValueOptions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static EnumValueOptions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static EnumValueOptions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static EnumValueOptions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private EnumValueOptions MakeReadOnly() { - uninterpretedOption_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(EnumValueOptions prototype) { - return new Builder(prototype); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder<EnumValueOptions, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(EnumValueOptions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; + public int CalculateSize() { + int size = 0; + if (Deprecated != false) { + size += 1 + 1; } - - private bool resultIsReadOnly; - private EnumValueOptions result; - - private EnumValueOptions PrepareBuilder() { - if (resultIsReadOnly) { - EnumValueOptions original = result; - result = new EnumValueOptions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override EnumValueOptions MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * uninterpretedOption_.Count; } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.Descriptor; } - } - - public override EnumValueOptions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.DefaultInstance; } - } - - public override EnumValueOptions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); + return size; + } + public void MergeFrom(EnumValueOptions other) { + if (other == null) { + return; } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is EnumValueOptions) { - return MergeFrom((EnumValueOptions) other); - } else { - base.MergeFrom(other); - return this; - } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; } + uninterpretedOption_.Add(other.uninterpretedOption_); + } - public override Builder MergeFrom(EnumValueOptions other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasDeprecated) { - Deprecated = other.Deprecated; - } - if (other.uninterpretedOption_.Count != 0) { - result.uninterpretedOption_.Add(other.uninterpretedOption_); - } - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_enumValueOptionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _enumValueOptionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 8: { + Deprecated = input.ReadBool(); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasDeprecated = input.ReadBool(ref result.deprecated_); - break; - } - case 7994: { - input.ReadMessageArray(tag, field_name, result.uninterpretedOption_, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.DefaultInstance, extensionRegistry); - break; - } + case 7994: { + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; } - - - public bool HasDeprecated { - get { return result.hasDeprecated; } - } - public bool Deprecated { - get { return result.Deprecated; } - set { SetDeprecated(value); } - } - public Builder SetDeprecated(bool value) { - PrepareBuilder(); - result.hasDeprecated = true; - result.deprecated_ = value; - return this; - } - public Builder ClearDeprecated() { - PrepareBuilder(); - result.hasDeprecated = false; - result.deprecated_ = false; - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { - get { return PrepareBuilder().uninterpretedOption_; } - } - public int UninterpretedOptionCount { - get { return result.UninterpretedOptionCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return result.GetUninterpretedOption(index); - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_[index] = value; - return this; - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_[index] = builderForValue.Build(); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_.Add(value); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeUninterpretedOption(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> values) { - PrepareBuilder(); - result.uninterpretedOption_.Add(values); - return this; - } - public Builder ClearUninterpretedOption() { - PrepareBuilder(); - result.uninterpretedOption_.Clear(); - return this; - } - } - static EnumValueOptions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); } + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ServiceOptions : pb::ExtendableMessage<ServiceOptions, ServiceOptions.Builder> { - private ServiceOptions() { } - private static readonly ServiceOptions defaultInstance = new ServiceOptions().MakeReadOnly(); - private static readonly string[] _serviceOptionsFieldNames = new string[] { "deprecated", "uninterpreted_option" }; - private static readonly uint[] _serviceOptionsFieldTags = new uint[] { 264, 7994 }; - public static ServiceOptions DefaultInstance { - get { return defaultInstance; } - } - - public override ServiceOptions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override ServiceOptions ThisMessage { - get { return this; } - } + public sealed partial class ServiceOptions : pb::IMessage<ServiceOptions>, global::System.IEquatable<ServiceOptions> { + private static readonly pb::MessageParser<ServiceOptions> _parser = new pb::MessageParser<ServiceOptions>(() => new ServiceOptions()); + public static pb::MessageParser<ServiceOptions> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; + private static readonly uint[] _fieldTags = new uint[] { 264, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<ServiceOptions, ServiceOptions.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<ServiceOptions> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; } } + public ServiceOptions() { } + public ServiceOptions(ServiceOptions other) { + MergeFrom(other); + } public const int DeprecatedFieldNumber = 33; - private bool hasDeprecated; private bool deprecated_; - public bool HasDeprecated { - get { return hasDeprecated; } - } public bool Deprecated { get { return deprecated_; } + set { deprecated_ = value; } } + public const int UninterpretedOptionFieldNumber = 999; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } - public int UninterpretedOptionCount { - get { return uninterpretedOption_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return uninterpretedOption_[index]; - } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - if (!element.IsInitialized) return false; - } - if (!ExtensionsAreInitialized) return false; - return true; - } + public override bool Equals(object other) { + return Equals(other as ServiceOptions); } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _serviceOptionsFieldNames; - pb::ExtendableMessage<ServiceOptions, ServiceOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - if (hasDeprecated) { - output.WriteBool(33, field_names[0], Deprecated); + public bool Equals(ServiceOptions other) { + if (ReferenceEquals(other, null)) { + return false; } - if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, field_names[1], uninterpretedOption_); + if (ReferenceEquals(other, this)) { + return true; } - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); + if (Deprecated != other.Deprecated) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } + public override int GetHashCode() { + int hash = 0; + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasDeprecated) { - size += pb::CodedOutputStream.ComputeBoolSize(33, Deprecated); + public void WriteTo(pb::CodedOutputStream output) { + if (Deprecated != false) { + output.WriteRawTag(136, 2); + output.WriteBool(Deprecated); } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + output.WriteMessageArray(999, uninterpretedOption_); } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static ServiceOptions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ServiceOptions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ServiceOptions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } - public static ServiceOptions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ServiceOptions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ServiceOptions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static ServiceOptions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static ServiceOptions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static ServiceOptions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ServiceOptions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private ServiceOptions MakeReadOnly() { - uninterpretedOption_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(ServiceOptions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder<ServiceOptions, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(ServiceOptions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private ServiceOptions result; - - private ServiceOptions PrepareBuilder() { - if (resultIsReadOnly) { - ServiceOptions original = result; - result = new ServiceOptions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - protected override ServiceOptions MessageBeingBuilt { - get { return PrepareBuilder(); } + public int CalculateSize() { + int size = 0; + if (Deprecated != false) { + size += 2 + 1; } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * uninterpretedOption_.Count; } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.Descriptor; } - } - - public override ServiceOptions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.DefaultInstance; } - } - - public override ServiceOptions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); + return size; + } + public void MergeFrom(ServiceOptions other) { + if (other == null) { + return; } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is ServiceOptions) { - return MergeFrom((ServiceOptions) other); - } else { - base.MergeFrom(other); - return this; - } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; } + uninterpretedOption_.Add(other.uninterpretedOption_); + } - public override Builder MergeFrom(ServiceOptions other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasDeprecated) { - Deprecated = other.Deprecated; - } - if (other.uninterpretedOption_.Count != 0) { - result.uninterpretedOption_.Add(other.uninterpretedOption_); - } - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_serviceOptionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _serviceOptionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 264: { + Deprecated = input.ReadBool(); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 264: { - result.hasDeprecated = input.ReadBool(ref result.deprecated_); - break; - } - case 7994: { - input.ReadMessageArray(tag, field_name, result.uninterpretedOption_, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.DefaultInstance, extensionRegistry); - break; - } + case 7994: { + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasDeprecated { - get { return result.hasDeprecated; } - } - public bool Deprecated { - get { return result.Deprecated; } - set { SetDeprecated(value); } - } - public Builder SetDeprecated(bool value) { - PrepareBuilder(); - result.hasDeprecated = true; - result.deprecated_ = value; - return this; - } - public Builder ClearDeprecated() { - PrepareBuilder(); - result.hasDeprecated = false; - result.deprecated_ = false; - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { - get { return PrepareBuilder().uninterpretedOption_; } - } - public int UninterpretedOptionCount { - get { return result.UninterpretedOptionCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return result.GetUninterpretedOption(index); - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_[index] = value; - return this; - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_[index] = builderForValue.Build(); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_.Add(value); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeUninterpretedOption(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> values) { - PrepareBuilder(); - result.uninterpretedOption_.Add(values); - return this; - } - public Builder ClearUninterpretedOption() { - PrepareBuilder(); - result.uninterpretedOption_.Clear(); - return this; } } - static ServiceOptions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); - } + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MethodOptions : pb::ExtendableMessage<MethodOptions, MethodOptions.Builder> { - private MethodOptions() { } - private static readonly MethodOptions defaultInstance = new MethodOptions().MakeReadOnly(); - private static readonly string[] _methodOptionsFieldNames = new string[] { "deprecated", "uninterpreted_option" }; - private static readonly uint[] _methodOptionsFieldTags = new uint[] { 264, 7994 }; - public static MethodOptions DefaultInstance { - get { return defaultInstance; } - } - - public override MethodOptions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override MethodOptions ThisMessage { - get { return this; } - } + public sealed partial class MethodOptions : pb::IMessage<MethodOptions>, global::System.IEquatable<MethodOptions> { + private static readonly pb::MessageParser<MethodOptions> _parser = new pb::MessageParser<MethodOptions>(() => new MethodOptions()); + public static pb::MessageParser<MethodOptions> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; + private static readonly uint[] _fieldTags = new uint[] { 264, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<MethodOptions, MethodOptions.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<MethodOptions> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__FieldAccessorTable; } } + public MethodOptions() { } + public MethodOptions(MethodOptions other) { + MergeFrom(other); + } public const int DeprecatedFieldNumber = 33; - private bool hasDeprecated; private bool deprecated_; - public bool HasDeprecated { - get { return hasDeprecated; } - } public bool Deprecated { get { return deprecated_; } + set { deprecated_ = value; } } + public const int UninterpretedOptionFieldNumber = 999; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } - public int UninterpretedOptionCount { - get { return uninterpretedOption_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return uninterpretedOption_[index]; - } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - if (!element.IsInitialized) return false; - } - if (!ExtensionsAreInitialized) return false; - return true; - } + public override bool Equals(object other) { + return Equals(other as MethodOptions); } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _methodOptionsFieldNames; - pb::ExtendableMessage<MethodOptions, MethodOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - if (hasDeprecated) { - output.WriteBool(33, field_names[0], Deprecated); + public bool Equals(MethodOptions other) { + if (ReferenceEquals(other, null)) { + return false; } - if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, field_names[1], uninterpretedOption_); + if (ReferenceEquals(other, this)) { + return true; } - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); + if (Deprecated != other.Deprecated) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } + public override int GetHashCode() { + int hash = 0; + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasDeprecated) { - size += pb::CodedOutputStream.ComputeBoolSize(33, Deprecated); + public void WriteTo(pb::CodedOutputStream output) { + if (Deprecated != false) { + output.WriteRawTag(136, 2); + output.WriteBool(Deprecated); } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + output.WriteMessageArray(999, uninterpretedOption_); } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static MethodOptions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MethodOptions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MethodOptions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MethodOptions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MethodOptions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MethodOptions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static MethodOptions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static MethodOptions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static MethodOptions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MethodOptions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private MethodOptions MakeReadOnly() { - uninterpretedOption_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(MethodOptions prototype) { - return new Builder(prototype); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder<MethodOptions, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; + public int CalculateSize() { + int size = 0; + if (Deprecated != false) { + size += 2 + 1; } - internal Builder(MethodOptions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private MethodOptions result; - - private MethodOptions PrepareBuilder() { - if (resultIsReadOnly) { - MethodOptions original = result; - result = new MethodOptions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override MethodOptions MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * uninterpretedOption_.Count; } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.Descriptor; } - } - - public override MethodOptions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.DefaultInstance; } + return size; + } + public void MergeFrom(MethodOptions other) { + if (other == null) { + return; } - - public override MethodOptions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is MethodOptions) { - return MergeFrom((MethodOptions) other); - } else { - base.MergeFrom(other); - return this; - } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; } + uninterpretedOption_.Add(other.uninterpretedOption_); + } - public override Builder MergeFrom(MethodOptions other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasDeprecated) { - Deprecated = other.Deprecated; - } - if (other.uninterpretedOption_.Count != 0) { - result.uninterpretedOption_.Add(other.uninterpretedOption_); - } - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_methodOptionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _methodOptionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 264: { + Deprecated = input.ReadBool(); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 264: { - result.hasDeprecated = input.ReadBool(ref result.deprecated_); - break; - } - case 7994: { - input.ReadMessageArray(tag, field_name, result.uninterpretedOption_, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.DefaultInstance, extensionRegistry); - break; - } + case 7994: { + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasDeprecated { - get { return result.hasDeprecated; } - } - public bool Deprecated { - get { return result.Deprecated; } - set { SetDeprecated(value); } - } - public Builder SetDeprecated(bool value) { - PrepareBuilder(); - result.hasDeprecated = true; - result.deprecated_ = value; - return this; - } - public Builder ClearDeprecated() { - PrepareBuilder(); - result.hasDeprecated = false; - result.deprecated_ = false; - return this; - } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> UninterpretedOptionList { - get { return PrepareBuilder().uninterpretedOption_; } - } - public int UninterpretedOptionCount { - get { return result.UninterpretedOptionCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption GetUninterpretedOption(int index) { - return result.GetUninterpretedOption(index); - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_[index] = value; - return this; - } - public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_[index] = builderForValue.Build(); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.uninterpretedOption_.Add(value); - return this; - } - public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.uninterpretedOption_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeUninterpretedOption(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption> values) { - PrepareBuilder(); - result.uninterpretedOption_.Add(values); - return this; - } - public Builder ClearUninterpretedOption() { - PrepareBuilder(); - result.uninterpretedOption_.Clear(); - return this; } } - static MethodOptions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); - } + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class UninterpretedOption : pb::GeneratedMessage<UninterpretedOption, UninterpretedOption.Builder> { - private UninterpretedOption() { } - private static readonly UninterpretedOption defaultInstance = new UninterpretedOption().MakeReadOnly(); - private static readonly string[] _uninterpretedOptionFieldNames = new string[] { "aggregate_value", "double_value", "identifier_value", "name", "negative_int_value", "positive_int_value", "string_value" }; - private static readonly uint[] _uninterpretedOptionFieldTags = new uint[] { 66, 49, 26, 18, 40, 32, 58 }; - public static UninterpretedOption DefaultInstance { - get { return defaultInstance; } - } - - public override UninterpretedOption DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override UninterpretedOption ThisMessage { - get { return this; } - } + public sealed partial class UninterpretedOption : pb::IMessage<UninterpretedOption>, global::System.IEquatable<UninterpretedOption> { + private static readonly pb::MessageParser<UninterpretedOption> _parser = new pb::MessageParser<UninterpretedOption>(() => new UninterpretedOption()); + public static pb::MessageParser<UninterpretedOption> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "aggregate_value", "double_value", "identifier_value", "name", "negative_int_value", "positive_int_value", "string_value" }; + private static readonly uint[] _fieldTags = new uint[] { 66, 49, 26, 18, 40, 32, 58 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<UninterpretedOption, UninterpretedOption.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<UninterpretedOption> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; } } - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NamePart : pb::GeneratedMessage<NamePart, NamePart.Builder> { - private NamePart() { } - private static readonly NamePart defaultInstance = new NamePart().MakeReadOnly(); - private static readonly string[] _namePartFieldNames = new string[] { "is_extension", "name_part" }; - private static readonly uint[] _namePartFieldTags = new uint[] { 16, 10 }; - public static NamePart DefaultInstance { - get { return defaultInstance; } - } - - public override NamePart DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NamePart ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable<NamePart, NamePart.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; } - } - - public const int NamePart_FieldNumber = 1; - private bool hasNamePart_; - private string namePart_ = ""; - public bool HasNamePart_ { - get { return hasNamePart_; } - } - public string NamePart_ { - get { return namePart_; } - } - - public const int IsExtensionFieldNumber = 2; - private bool hasIsExtension; - private bool isExtension_; - public bool HasIsExtension { - get { return hasIsExtension; } - } - public bool IsExtension { - get { return isExtension_; } - } - - public override bool IsInitialized { - get { - if (!hasNamePart_) return false; - if (!hasIsExtension) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _namePartFieldNames; - if (hasNamePart_) { - output.WriteString(1, field_names[1], NamePart_); - } - if (hasIsExtension) { - output.WriteBool(2, field_names[0], IsExtension); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasNamePart_) { - size += pb::CodedOutputStream.ComputeStringSize(1, NamePart_); - } - if (hasIsExtension) { - size += pb::CodedOutputStream.ComputeBoolSize(2, IsExtension); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static NamePart ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NamePart ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NamePart ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NamePart ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NamePart ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NamePart ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NamePart ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NamePart ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NamePart ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NamePart ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NamePart MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NamePart prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<NamePart, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NamePart cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NamePart result; - - private NamePart PrepareBuilder() { - if (resultIsReadOnly) { - NamePart original = result; - result = new NamePart(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NamePart MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart.Descriptor; } - } - - public override NamePart DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart.DefaultInstance; } - } - - public override NamePart BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is NamePart) { - return MergeFrom((NamePart) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NamePart other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasNamePart_) { - NamePart_ = other.NamePart_; - } - if (other.HasIsExtension) { - IsExtension = other.IsExtension; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_namePartFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _namePartFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasNamePart_ = input.ReadString(ref result.namePart_); - break; - } - case 16: { - result.hasIsExtension = input.ReadBool(ref result.isExtension_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasNamePart_ { - get { return result.hasNamePart_; } - } - public string NamePart_ { - get { return result.NamePart_; } - set { SetNamePart_(value); } - } - public Builder SetNamePart_(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasNamePart_ = true; - result.namePart_ = value; - return this; - } - public Builder ClearNamePart_() { - PrepareBuilder(); - result.hasNamePart_ = false; - result.namePart_ = ""; - return this; - } - - public bool HasIsExtension { - get { return result.hasIsExtension; } - } - public bool IsExtension { - get { return result.IsExtension; } - set { SetIsExtension(value); } - } - public Builder SetIsExtension(bool value) { - PrepareBuilder(); - result.hasIsExtension = true; - result.isExtension_ = value; - return this; - } - public Builder ClearIsExtension() { - PrepareBuilder(); - result.hasIsExtension = false; - result.isExtension_ = false; - return this; - } - } - static NamePart() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); - } - } - + public UninterpretedOption() { } + public UninterpretedOption(UninterpretedOption other) { + MergeFrom(other); } - #endregion - public const int NameFieldNumber = 2; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart> name_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart> NameList { + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> name_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> Name { get { return name_; } } - public int NameCount { - get { return name_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart GetName(int index) { - return name_[index]; - } public const int IdentifierValueFieldNumber = 3; - private bool hasIdentifierValue; private string identifierValue_ = ""; - public bool HasIdentifierValue { - get { return hasIdentifierValue; } - } public string IdentifierValue { get { return identifierValue_; } + set { identifierValue_ = value ?? ""; } } + public const int PositiveIntValueFieldNumber = 4; - private bool hasPositiveIntValue; private ulong positiveIntValue_; - public bool HasPositiveIntValue { - get { return hasPositiveIntValue; } - } public ulong PositiveIntValue { get { return positiveIntValue_; } + set { positiveIntValue_ = value; } } + public const int NegativeIntValueFieldNumber = 5; - private bool hasNegativeIntValue; private long negativeIntValue_; - public bool HasNegativeIntValue { - get { return hasNegativeIntValue; } - } public long NegativeIntValue { get { return negativeIntValue_; } + set { negativeIntValue_ = value; } } + public const int DoubleValueFieldNumber = 6; - private bool hasDoubleValue; private double doubleValue_; - public bool HasDoubleValue { - get { return hasDoubleValue; } - } public double DoubleValue { get { return doubleValue_; } + set { doubleValue_ = value; } } + public const int StringValueFieldNumber = 7; - private bool hasStringValue; private pb::ByteString stringValue_ = pb::ByteString.Empty; - public bool HasStringValue { - get { return hasStringValue; } - } public pb::ByteString StringValue { get { return stringValue_; } + set { stringValue_ = value ?? pb::ByteString.Empty; } } + public const int AggregateValueFieldNumber = 8; - private bool hasAggregateValue; private string aggregateValue_ = ""; - public bool HasAggregateValue { - get { return hasAggregateValue; } - } public string AggregateValue { get { return aggregateValue_; } + set { aggregateValue_ = value ?? ""; } } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart element in NameList) { - if (!element.IsInitialized) return false; - } - return true; - } + + public override bool Equals(object other) { + return Equals(other as UninterpretedOption); } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _uninterpretedOptionFieldNames; - if (name_.Count > 0) { - output.WriteMessageArray(2, field_names[3], name_); + public bool Equals(UninterpretedOption other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; } - if (hasIdentifierValue) { - output.WriteString(3, field_names[2], IdentifierValue); + if(!name_.Equals(other.name_)) return false; + if (IdentifierValue != other.IdentifierValue) return false; + if (PositiveIntValue != other.PositiveIntValue) return false; + if (NegativeIntValue != other.NegativeIntValue) return false; + if (DoubleValue != other.DoubleValue) return false; + if (StringValue != other.StringValue) return false; + if (AggregateValue != other.AggregateValue) return false; + return true; + } + + public override int GetHashCode() { + int hash = 0; + hash ^= name_.GetHashCode(); + if (IdentifierValue.Length != 0) hash ^= IdentifierValue.GetHashCode(); + if (PositiveIntValue != 0UL) hash ^= PositiveIntValue.GetHashCode(); + if (NegativeIntValue != 0L) hash ^= NegativeIntValue.GetHashCode(); + if (DoubleValue != 0D) hash ^= DoubleValue.GetHashCode(); + if (StringValue.Length != 0) hash ^= StringValue.GetHashCode(); + if (AggregateValue.Length != 0) hash ^= AggregateValue.GetHashCode(); + return hash; + } + + public void WriteTo(pb::CodedOutputStream output) { + if (name_.Count > 0) { + output.WriteMessageArray(2, name_); } - if (hasPositiveIntValue) { - output.WriteUInt64(4, field_names[5], PositiveIntValue); + if (IdentifierValue.Length != 0) { + output.WriteRawTag(26); + output.WriteString(IdentifierValue); } - if (hasNegativeIntValue) { - output.WriteInt64(5, field_names[4], NegativeIntValue); + if (PositiveIntValue != 0UL) { + output.WriteRawTag(32); + output.WriteUInt64(PositiveIntValue); } - if (hasDoubleValue) { - output.WriteDouble(6, field_names[1], DoubleValue); + if (NegativeIntValue != 0L) { + output.WriteRawTag(40); + output.WriteInt64(NegativeIntValue); } - if (hasStringValue) { - output.WriteBytes(7, field_names[6], StringValue); + if (DoubleValue != 0D) { + output.WriteRawTag(49); + output.WriteDouble(DoubleValue); } - if (hasAggregateValue) { - output.WriteString(8, field_names[0], AggregateValue); + if (StringValue.Length != 0) { + output.WriteRawTag(58); + output.WriteBytes(StringValue); } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); + if (AggregateValue.Length != 0) { + output.WriteRawTag(66); + output.WriteString(AggregateValue); } } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart element in NameList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); + public int CalculateSize() { + int size = 0; + if (name_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart element in name_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); + } + size += 1 * name_.Count; } - if (hasIdentifierValue) { - size += pb::CodedOutputStream.ComputeStringSize(3, IdentifierValue); + if (IdentifierValue.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(IdentifierValue); } - if (hasPositiveIntValue) { - size += pb::CodedOutputStream.ComputeUInt64Size(4, PositiveIntValue); + if (PositiveIntValue != 0UL) { + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(PositiveIntValue); } - if (hasNegativeIntValue) { - size += pb::CodedOutputStream.ComputeInt64Size(5, NegativeIntValue); + if (NegativeIntValue != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(NegativeIntValue); } - if (hasDoubleValue) { - size += pb::CodedOutputStream.ComputeDoubleSize(6, DoubleValue); + if (DoubleValue != 0D) { + size += 1 + 8; } - if (hasStringValue) { - size += pb::CodedOutputStream.ComputeBytesSize(7, StringValue); + if (StringValue.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(StringValue); } - if (hasAggregateValue) { - size += pb::CodedOutputStream.ComputeStringSize(8, AggregateValue); + if (AggregateValue.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(AggregateValue); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; return size; } - public static UninterpretedOption ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static UninterpretedOption ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static UninterpretedOption ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static UninterpretedOption ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static UninterpretedOption ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static UninterpretedOption ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static UninterpretedOption ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static UninterpretedOption ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static UninterpretedOption ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static UninterpretedOption ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private UninterpretedOption MakeReadOnly() { - name_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(UninterpretedOption prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<UninterpretedOption, Builder> { - protected override Builder ThisBuilder { - get { return this; } + public void MergeFrom(UninterpretedOption other) { + if (other == null) { + return; } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; + name_.Add(other.name_); + if (other.IdentifierValue.Length != 0) { + IdentifierValue = other.IdentifierValue; } - internal Builder(UninterpretedOption cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; + if (other.PositiveIntValue != 0UL) { + PositiveIntValue = other.PositiveIntValue; } - - private bool resultIsReadOnly; - private UninterpretedOption result; - - private UninterpretedOption PrepareBuilder() { - if (resultIsReadOnly) { - UninterpretedOption original = result; - result = new UninterpretedOption(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; + if (other.NegativeIntValue != 0L) { + NegativeIntValue = other.NegativeIntValue; } - - public override bool IsInitialized { - get { return result.IsInitialized; } + if (other.DoubleValue != 0D) { + DoubleValue = other.DoubleValue; } - - protected override UninterpretedOption MessageBeingBuilt { - get { return PrepareBuilder(); } + if (other.StringValue.Length != 0) { + StringValue = other.StringValue; } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; + if (other.AggregateValue.Length != 0) { + AggregateValue = other.AggregateValue; } + } - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 18: { + input.ReadMessageArray(name_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart.Parser); + break; + } + case 26: { + IdentifierValue = input.ReadString(); + break; + } + case 32: { + PositiveIntValue = input.ReadUInt64(); + break; + } + case 40: { + NegativeIntValue = input.ReadInt64(); + break; + } + case 49: { + DoubleValue = input.ReadDouble(); + break; + } + case 58: { + StringValue = input.ReadBytes(); + break; + } + case 66: { + AggregateValue = input.ReadString(); + break; + } } } + } - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Descriptor; } - } - - public override UninterpretedOption DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.DefaultInstance; } - } + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class NamePart : pb::IMessage<NamePart>, global::System.IEquatable<NamePart> { + private static readonly pb::MessageParser<NamePart> _parser = new pb::MessageParser<NamePart>(() => new NamePart()); + public static pb::MessageParser<NamePart> Parser { get { return _parser; } } - public override UninterpretedOption BuildPartial() { - if (resultIsReadOnly) { - return result; + private static readonly string[] _fieldNames = new string[] { "is_extension", "name_part" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 10 }; + public static pbd::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor; } } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - public override Builder MergeFrom(pb::IMessage other) { - if (other is UninterpretedOption) { - return MergeFrom((UninterpretedOption) other); - } else { - base.MergeFrom(other); - return this; + public pb::FieldAccess.FieldAccessorTable<NamePart> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; } } - } - public override Builder MergeFrom(UninterpretedOption other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.DefaultInstance) return this; - PrepareBuilder(); - if (other.name_.Count != 0) { - result.name_.Add(other.name_); + public NamePart() { } + public NamePart(NamePart other) { + MergeFrom(other); } - if (other.HasIdentifierValue) { - IdentifierValue = other.IdentifierValue; + public const int NamePart_FieldNumber = 1; + private string namePart_ = ""; + public string NamePart_ { + get { return namePart_; } + set { namePart_ = value ?? ""; } } - if (other.HasPositiveIntValue) { - PositiveIntValue = other.PositiveIntValue; + + + public const int IsExtensionFieldNumber = 2; + private bool isExtension_; + public bool IsExtension { + get { return isExtension_; } + set { isExtension_ = value; } } - if (other.HasNegativeIntValue) { - NegativeIntValue = other.NegativeIntValue; + + + public override bool Equals(object other) { + return Equals(other as NamePart); } - if (other.HasDoubleValue) { - DoubleValue = other.DoubleValue; + + public bool Equals(NamePart other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (NamePart_ != other.NamePart_) return false; + if (IsExtension != other.IsExtension) return false; + return true; } - if (other.HasStringValue) { - StringValue = other.StringValue; + + public override int GetHashCode() { + int hash = 0; + if (NamePart_.Length != 0) hash ^= NamePart_.GetHashCode(); + if (IsExtension != false) hash ^= IsExtension.GetHashCode(); + return hash; } - if (other.HasAggregateValue) { - AggregateValue = other.AggregateValue; + + public void WriteTo(pb::CodedOutputStream output) { + if (NamePart_.Length != 0) { + output.WriteRawTag(10); + output.WriteString(NamePart_); + } + if (IsExtension != false) { + output.WriteRawTag(16); + output.WriteBool(IsExtension); + } } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_uninterpretedOptionFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _uninterpretedOptionFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } + + public int CalculateSize() { + int size = 0; + if (NamePart_.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(NamePart_); } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); + if (IsExtension != false) { + size += 1 + 1; + } + return size; + } + public void MergeFrom(NamePart other) { + if (other == null) { + return; + } + if (other.NamePart_.Length != 0) { + NamePart_ = other.NamePart_; + } + if (other.IsExtension != false) { + IsExtension = other.IsExtension; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } - return this; + break; + case 10: { + NamePart_ = input.ReadString(); + break; } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); + case 16: { + IsExtension = input.ReadBool(); + break; } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 18: { - input.ReadMessageArray(tag, field_name, result.name_, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart.DefaultInstance, extensionRegistry); - break; - } - case 26: { - result.hasIdentifierValue = input.ReadString(ref result.identifierValue_); - break; - } - case 32: { - result.hasPositiveIntValue = input.ReadUInt64(ref result.positiveIntValue_); - break; - } - case 40: { - result.hasNegativeIntValue = input.ReadInt64(ref result.negativeIntValue_); - break; - } - case 49: { - result.hasDoubleValue = input.ReadDouble(ref result.doubleValue_); - break; - } - case 58: { - result.hasStringValue = input.ReadBytes(ref result.stringValue_); - break; - } - case 66: { - result.hasAggregateValue = input.ReadString(ref result.aggregateValue_); - break; } } } - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; } + } + #endregion - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart> NameList { - get { return PrepareBuilder().name_; } - } - public int NameCount { - get { return result.NameCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart GetName(int index) { - return result.GetName(index); - } - public Builder SetName(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.name_[index] = value; - return this; - } - public Builder SetName(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.name_[index] = builderForValue.Build(); - return this; - } - public Builder AddName(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.name_.Add(value); - return this; - } - public Builder AddName(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.name_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeName(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart> values) { - PrepareBuilder(); - result.name_.Add(values); - return this; - } - public Builder ClearName() { - PrepareBuilder(); - result.name_.Clear(); - return this; - } - - public bool HasIdentifierValue { - get { return result.hasIdentifierValue; } - } - public string IdentifierValue { - get { return result.IdentifierValue; } - set { SetIdentifierValue(value); } - } - public Builder SetIdentifierValue(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasIdentifierValue = true; - result.identifierValue_ = value; - return this; - } - public Builder ClearIdentifierValue() { - PrepareBuilder(); - result.hasIdentifierValue = false; - result.identifierValue_ = ""; - return this; - } - - public bool HasPositiveIntValue { - get { return result.hasPositiveIntValue; } - } - public ulong PositiveIntValue { - get { return result.PositiveIntValue; } - set { SetPositiveIntValue(value); } - } - public Builder SetPositiveIntValue(ulong value) { - PrepareBuilder(); - result.hasPositiveIntValue = true; - result.positiveIntValue_ = value; - return this; - } - public Builder ClearPositiveIntValue() { - PrepareBuilder(); - result.hasPositiveIntValue = false; - result.positiveIntValue_ = 0UL; - return this; - } + } - public bool HasNegativeIntValue { - get { return result.hasNegativeIntValue; } - } - public long NegativeIntValue { - get { return result.NegativeIntValue; } - set { SetNegativeIntValue(value); } - } - public Builder SetNegativeIntValue(long value) { - PrepareBuilder(); - result.hasNegativeIntValue = true; - result.negativeIntValue_ = value; - return this; - } - public Builder ClearNegativeIntValue() { - PrepareBuilder(); - result.hasNegativeIntValue = false; - result.negativeIntValue_ = 0L; - return this; - } - - public bool HasDoubleValue { - get { return result.hasDoubleValue; } - } - public double DoubleValue { - get { return result.DoubleValue; } - set { SetDoubleValue(value); } - } - public Builder SetDoubleValue(double value) { - PrepareBuilder(); - result.hasDoubleValue = true; - result.doubleValue_ = value; - return this; - } - public Builder ClearDoubleValue() { - PrepareBuilder(); - result.hasDoubleValue = false; - result.doubleValue_ = 0D; - return this; - } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class SourceCodeInfo : pb::IMessage<SourceCodeInfo>, global::System.IEquatable<SourceCodeInfo> { + private static readonly pb::MessageParser<SourceCodeInfo> _parser = new pb::MessageParser<SourceCodeInfo>(() => new SourceCodeInfo()); + public static pb::MessageParser<SourceCodeInfo> Parser { get { return _parser; } } - public bool HasStringValue { - get { return result.hasStringValue; } - } - public pb::ByteString StringValue { - get { return result.StringValue; } - set { SetStringValue(value); } - } - public Builder SetStringValue(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasStringValue = true; - result.stringValue_ = value; - return this; - } - public Builder ClearStringValue() { - PrepareBuilder(); - result.hasStringValue = false; - result.stringValue_ = pb::ByteString.Empty; - return this; - } + private static readonly string[] _fieldNames = new string[] { "location" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbd::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__Descriptor; } + } - public bool HasAggregateValue { - get { return result.hasAggregateValue; } - } - public string AggregateValue { - get { return result.AggregateValue; } - set { SetAggregateValue(value); } - } - public Builder SetAggregateValue(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasAggregateValue = true; - result.aggregateValue_ = value; - return this; - } - public Builder ClearAggregateValue() { - PrepareBuilder(); - result.hasAggregateValue = false; - result.aggregateValue_ = ""; - return this; - } + public pb::FieldAccess.FieldAccessorTable<SourceCodeInfo> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; } } - static UninterpretedOption() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); + + public SourceCodeInfo() { } + public SourceCodeInfo(SourceCodeInfo other) { + MergeFrom(other); + } + public const int LocationFieldNumber = 1; + private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> location_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location>(); + public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> Location { + get { return location_; } } - } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class SourceCodeInfo : pb::GeneratedMessage<SourceCodeInfo, SourceCodeInfo.Builder> { - private SourceCodeInfo() { } - private static readonly SourceCodeInfo defaultInstance = new SourceCodeInfo().MakeReadOnly(); - private static readonly string[] _sourceCodeInfoFieldNames = new string[] { "location" }; - private static readonly uint[] _sourceCodeInfoFieldTags = new uint[] { 10 }; - public static SourceCodeInfo DefaultInstance { - get { return defaultInstance; } + public override bool Equals(object other) { + return Equals(other as SourceCodeInfo); } - public override SourceCodeInfo DefaultInstanceForType { - get { return DefaultInstance; } + public bool Equals(SourceCodeInfo other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!location_.Equals(other.location_)) return false; + return true; } - protected override SourceCodeInfo ThisMessage { - get { return this; } + public override int GetHashCode() { + int hash = 0; + hash ^= location_.GetHashCode(); + return hash; } - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__Descriptor; } + public void WriteTo(pb::CodedOutputStream output) { + if (location_.Count > 0) { + output.WriteMessageArray(1, location_); + } + } + + public int CalculateSize() { + int size = 0; + if (location_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location element in location_) { + size += pb::CodedOutputStream.ComputeMessageSize(element); + } + size += 1 * location_.Count; + } + return size; + } + public void MergeFrom(SourceCodeInfo other) { + if (other == null) { + return; + } + location_.Add(other.location_); } - protected override pb::FieldAccess.FieldAccessorTable<SourceCodeInfo, SourceCodeInfo.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; } + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + input.ReadMessageArray(location_, global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location.Parser); + break; + } + } + } } #region Nested types [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Location : pb::GeneratedMessage<Location, Location.Builder> { - private Location() { } - private static readonly Location defaultInstance = new Location().MakeReadOnly(); - private static readonly string[] _locationFieldNames = new string[] { "leading_comments", "leading_detached_comments", "path", "span", "trailing_comments" }; - private static readonly uint[] _locationFieldTags = new uint[] { 26, 50, 10, 18, 34 }; - public static Location DefaultInstance { - get { return defaultInstance; } - } - - public override Location DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Location ThisMessage { - get { return this; } - } + public sealed partial class Location : pb::IMessage<Location>, global::System.IEquatable<Location> { + private static readonly pb::MessageParser<Location> _parser = new pb::MessageParser<Location>(() => new Location()); + public static pb::MessageParser<Location> Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "leading_comments", "leading_detached_comments", "path", "span", "trailing_comments" }; + private static readonly uint[] _fieldTags = new uint[] { 26, 50, 10, 18, 34 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable<Location, Location.Builder> InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; } + public pb::FieldAccess.FieldAccessorTable<Location> Fields { + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; } } - public const int PathFieldNumber = 1; - private int pathMemoizedSerializedSize; - private pbc::PopsicleList<int> path_ = new pbc::PopsicleList<int>(); - public scg::IList<int> PathList { - get { return pbc::Lists.AsReadOnly(path_); } + public Location() { } + public Location(Location other) { + MergeFrom(other); } - public int PathCount { - get { return path_.Count; } - } - public int GetPath(int index) { - return path_[index]; + public const int PathFieldNumber = 1; + private readonly pbc::RepeatedField<int> path_ = new pbc::RepeatedField<int>(); + public pbc::RepeatedField<int> Path { + get { return path_; } } public const int SpanFieldNumber = 2; - private int spanMemoizedSerializedSize; - private pbc::PopsicleList<int> span_ = new pbc::PopsicleList<int>(); - public scg::IList<int> SpanList { - get { return pbc::Lists.AsReadOnly(span_); } - } - public int SpanCount { - get { return span_.Count; } - } - public int GetSpan(int index) { - return span_[index]; + private readonly pbc::RepeatedField<int> span_ = new pbc::RepeatedField<int>(); + public pbc::RepeatedField<int> Span { + get { return span_; } } public const int LeadingCommentsFieldNumber = 3; - private bool hasLeadingComments; private string leadingComments_ = ""; - public bool HasLeadingComments { - get { return hasLeadingComments; } - } public string LeadingComments { get { return leadingComments_; } + set { leadingComments_ = value ?? ""; } } + public const int TrailingCommentsFieldNumber = 4; - private bool hasTrailingComments; private string trailingComments_ = ""; - public bool HasTrailingComments { - get { return hasTrailingComments; } - } public string TrailingComments { get { return trailingComments_; } + set { trailingComments_ = value ?? ""; } } + public const int LeadingDetachedCommentsFieldNumber = 6; - private pbc::PopsicleList<string> leadingDetachedComments_ = new pbc::PopsicleList<string>(); - public scg::IList<string> LeadingDetachedCommentsList { - get { return pbc::Lists.AsReadOnly(leadingDetachedComments_); } + private readonly pbc::RepeatedField<string> leadingDetachedComments_ = new pbc::RepeatedField<string>(); + public pbc::RepeatedField<string> LeadingDetachedComments { + get { return leadingDetachedComments_; } } - public int LeadingDetachedCommentsCount { - get { return leadingDetachedComments_.Count; } - } - public string GetLeadingDetachedComments(int index) { - return leadingDetachedComments_[index]; + + public override bool Equals(object other) { + return Equals(other as Location); } - public override bool IsInitialized { - get { + public bool Equals(Location other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { return true; } + if(!path_.Equals(other.path_)) return false; + if(!span_.Equals(other.span_)) return false; + if (LeadingComments != other.LeadingComments) return false; + if (TrailingComments != other.TrailingComments) return false; + if(!leadingDetachedComments_.Equals(other.leadingDetachedComments_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 0; + hash ^= path_.GetHashCode(); + hash ^= span_.GetHashCode(); + if (LeadingComments.Length != 0) hash ^= LeadingComments.GetHashCode(); + if (TrailingComments.Length != 0) hash ^= TrailingComments.GetHashCode(); + hash ^= leadingDetachedComments_.GetHashCode(); + return hash; } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _locationFieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (path_.Count > 0) { - output.WritePackedInt32Array(1, field_names[2], pathMemoizedSerializedSize, path_); + output.WriteRawTag(10); + output.WritePackedInt32Array(path_); } if (span_.Count > 0) { - output.WritePackedInt32Array(2, field_names[3], spanMemoizedSerializedSize, span_); + output.WriteRawTag(18); + output.WritePackedInt32Array(span_); } - if (hasLeadingComments) { - output.WriteString(3, field_names[0], LeadingComments); + if (LeadingComments.Length != 0) { + output.WriteRawTag(26); + output.WriteString(LeadingComments); } - if (hasTrailingComments) { - output.WriteString(4, field_names[4], TrailingComments); + if (TrailingComments.Length != 0) { + output.WriteRawTag(34); + output.WriteString(TrailingComments); } if (leadingDetachedComments_.Count > 0) { - output.WriteStringArray(6, field_names[1], leadingDetachedComments_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); + output.WriteStringArray(6, leadingDetachedComments_); } } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { + public int CalculateSize() { + int size = 0; + if (path_.Count > 0) { int dataSize = 0; - foreach (int element in PathList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + foreach (int element in path_) { + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; - if (path_.Count != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - pathMemoizedSerializedSize = dataSize; + size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } - { + if (span_.Count > 0) { int dataSize = 0; - foreach (int element in SpanList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + foreach (int element in span_) { + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; - if (span_.Count != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - spanMemoizedSerializedSize = dataSize; + size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } - if (hasLeadingComments) { - size += pb::CodedOutputStream.ComputeStringSize(3, LeadingComments); + if (LeadingComments.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(LeadingComments); } - if (hasTrailingComments) { - size += pb::CodedOutputStream.ComputeStringSize(4, TrailingComments); + if (TrailingComments.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TrailingComments); } - { + if (leadingDetachedComments_.Count > 0) { int dataSize = 0; - foreach (string element in LeadingDetachedCommentsList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + foreach (string element in leadingDetachedComments_) { + dataSize += pb::CodedOutputStream.ComputeStringSize(element); } size += dataSize; size += 1 * leadingDetachedComments_.Count; } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; return size; } - public static Location ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Location ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Location ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Location ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Location ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Location ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Location ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Location ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Location ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Location ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Location MakeReadOnly() { - path_.MakeReadOnly(); - span_.MakeReadOnly(); - leadingDetachedComments_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Location prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<Location, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; + public void MergeFrom(Location other) { + if (other == null) { + return; } - internal Builder(Location cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; + path_.Add(other.path_); + span_.Add(other.span_); + if (other.LeadingComments.Length != 0) { + LeadingComments = other.LeadingComments; } - - private bool resultIsReadOnly; - private Location result; - - private Location PrepareBuilder() { - if (resultIsReadOnly) { - Location original = result; - result = new Location(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Location MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location.Descriptor; } - } - - public override Location DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location.DefaultInstance; } - } - - public override Location BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Location) { - return MergeFrom((Location) other); - } else { - base.MergeFrom(other); - return this; - } + if (other.TrailingComments.Length != 0) { + TrailingComments = other.TrailingComments; } + leadingDetachedComments_.Add(other.leadingDetachedComments_); + } - public override Builder MergeFrom(Location other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location.DefaultInstance) return this; - PrepareBuilder(); - if (other.path_.Count != 0) { - result.path_.Add(other.path_); - } - if (other.span_.Count != 0) { - result.span_.Add(other.span_); - } - if (other.HasLeadingComments) { - LeadingComments = other.LeadingComments; - } - if (other.HasTrailingComments) { - TrailingComments = other.TrailingComments; - } - if (other.leadingDetachedComments_.Count != 0) { - result.leadingDetachedComments_.Add(other.leadingDetachedComments_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_locationFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _locationFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 10: + case 8: { + input.ReadInt32Array(path_); + break; } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: - case 8: { - input.ReadInt32Array(tag, field_name, result.path_); - break; - } - case 18: - case 16: { - input.ReadInt32Array(tag, field_name, result.span_); - break; - } - case 26: { - result.hasLeadingComments = input.ReadString(ref result.leadingComments_); - break; - } - case 34: { - result.hasTrailingComments = input.ReadString(ref result.trailingComments_); - break; - } - case 50: { - input.ReadStringArray(tag, field_name, result.leadingDetachedComments_); - break; - } + case 18: + case 16: { + input.ReadInt32Array(span_); + break; } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList<int> PathList { - get { return PrepareBuilder().path_; } - } - public int PathCount { - get { return result.PathCount; } - } - public int GetPath(int index) { - return result.GetPath(index); - } - public Builder SetPath(int index, int value) { - PrepareBuilder(); - result.path_[index] = value; - return this; - } - public Builder AddPath(int value) { - PrepareBuilder(); - result.path_.Add(value); - return this; - } - public Builder AddRangePath(scg::IEnumerable<int> values) { - PrepareBuilder(); - result.path_.Add(values); - return this; - } - public Builder ClearPath() { - PrepareBuilder(); - result.path_.Clear(); - return this; - } - - public pbc::IPopsicleList<int> SpanList { - get { return PrepareBuilder().span_; } - } - public int SpanCount { - get { return result.SpanCount; } - } - public int GetSpan(int index) { - return result.GetSpan(index); - } - public Builder SetSpan(int index, int value) { - PrepareBuilder(); - result.span_[index] = value; - return this; - } - public Builder AddSpan(int value) { - PrepareBuilder(); - result.span_.Add(value); - return this; - } - public Builder AddRangeSpan(scg::IEnumerable<int> values) { - PrepareBuilder(); - result.span_.Add(values); - return this; - } - public Builder ClearSpan() { - PrepareBuilder(); - result.span_.Clear(); - return this; - } - - public bool HasLeadingComments { - get { return result.hasLeadingComments; } - } - public string LeadingComments { - get { return result.LeadingComments; } - set { SetLeadingComments(value); } - } - public Builder SetLeadingComments(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasLeadingComments = true; - result.leadingComments_ = value; - return this; - } - public Builder ClearLeadingComments() { - PrepareBuilder(); - result.hasLeadingComments = false; - result.leadingComments_ = ""; - return this; - } - - public bool HasTrailingComments { - get { return result.hasTrailingComments; } - } - public string TrailingComments { - get { return result.TrailingComments; } - set { SetTrailingComments(value); } - } - public Builder SetTrailingComments(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasTrailingComments = true; - result.trailingComments_ = value; - return this; - } - public Builder ClearTrailingComments() { - PrepareBuilder(); - result.hasTrailingComments = false; - result.trailingComments_ = ""; - return this; - } - - public pbc::IPopsicleList<string> LeadingDetachedCommentsList { - get { return PrepareBuilder().leadingDetachedComments_; } - } - public int LeadingDetachedCommentsCount { - get { return result.LeadingDetachedCommentsCount; } - } - public string GetLeadingDetachedComments(int index) { - return result.GetLeadingDetachedComments(index); - } - public Builder SetLeadingDetachedComments(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.leadingDetachedComments_[index] = value; - return this; - } - public Builder AddLeadingDetachedComments(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.leadingDetachedComments_.Add(value); - return this; - } - public Builder AddRangeLeadingDetachedComments(scg::IEnumerable<string> values) { - PrepareBuilder(); - result.leadingDetachedComments_.Add(values); - return this; - } - public Builder ClearLeadingDetachedComments() { - PrepareBuilder(); - result.leadingDetachedComments_.Clear(); - return this; - } - } - static Location() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); - } - } - - } - #endregion - - public const int LocationFieldNumber = 1; - private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location> location_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location>(); - public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location> LocationList { - get { return location_; } - } - public int LocationCount { - get { return location_.Count; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location GetLocation(int index) { - return location_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _sourceCodeInfoFieldNames; - if (location_.Count > 0) { - output.WriteMessageArray(1, field_names[0], location_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location element in LocationList) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static SourceCodeInfo ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static SourceCodeInfo ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static SourceCodeInfo ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static SourceCodeInfo ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static SourceCodeInfo ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static SourceCodeInfo ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static SourceCodeInfo ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static SourceCodeInfo ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static SourceCodeInfo ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static SourceCodeInfo ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private SourceCodeInfo MakeReadOnly() { - location_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(SourceCodeInfo prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder<SourceCodeInfo, Builder> { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(SourceCodeInfo cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private SourceCodeInfo result; - - private SourceCodeInfo PrepareBuilder() { - if (resultIsReadOnly) { - SourceCodeInfo original = result; - result = new SourceCodeInfo(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override SourceCodeInfo MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Descriptor; } - } - - public override SourceCodeInfo DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.DefaultInstance; } - } - - public override SourceCodeInfo BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is SourceCodeInfo) { - return MergeFrom((SourceCodeInfo) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(SourceCodeInfo other) { - if (other == global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.DefaultInstance) return this; - PrepareBuilder(); - if (other.location_.Count != 0) { - result.location_.Add(other.location_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_sourceCodeInfoFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _sourceCodeInfoFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); + case 26: { + LeadingComments = input.ReadString(); + break; } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; + case 34: { + TrailingComments = input.ReadString(); + break; } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); + case 50: { + input.ReadStringArray(leadingDetachedComments_); + break; } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - input.ReadMessageArray(tag, field_name, result.location_, global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location.DefaultInstance, extensionRegistry); - break; } } } - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; } - - public pbc::IPopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location> LocationList { - get { return PrepareBuilder().location_; } - } - public int LocationCount { - get { return result.LocationCount; } - } - public global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location GetLocation(int index) { - return result.GetLocation(index); - } - public Builder SetLocation(int index, global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.location_[index] = value; - return this; - } - public Builder SetLocation(int index, global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.location_[index] = builderForValue.Build(); - return this; - } - public Builder AddLocation(global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.location_.Add(value); - return this; - } - public Builder AddLocation(global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.location_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeLocation(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location> values) { - PrepareBuilder(); - result.location_.Add(values); - return this; - } - public Builder ClearLocation() { - PrepareBuilder(); - result.location_.Clear(); - return this; - } - } - static SourceCodeInfo() { - object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProtoFile.Descriptor, null); } + #endregion + } #endregion diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs index c894d324..1f7c17fe 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs @@ -29,7 +29,7 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-namespace Google.ProtocolBuffers.DescriptorProtos
+namespace Google.Protobuf.DescriptorProtos
{
/// <summary>
/// Interface implemented by all DescriptorProtos. The generator doesn't
diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs index adc2afb0..9c84aa9d 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs @@ -33,7 +33,7 @@ // This file just contains partial classes for each of the
// autogenerated classes, so that they implement
// IDescriptorProto
-namespace Google.ProtocolBuffers.DescriptorProtos
+namespace Google.Protobuf.DescriptorProtos
{
public partial class DescriptorProto : IDescriptorProto<MessageOptions>
{
diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs index 59006f80..39f6d843 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs @@ -29,10 +29,11 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
+ // TODO(jonskeet): The descriptor type hierarchy needs changing so that we can hide the descriptor protos.
/// <summary>
/// Base class for nearly all descriptors, providing common functionality.
/// </summary>
diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs index 30718709..02b59d76 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs @@ -34,7 +34,7 @@ using System.Collections.Generic; using System.Text;
using System.Text.RegularExpressions;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Contains lookup tables containing all the descriptors defined in a particular file.
@@ -85,7 +85,7 @@ namespace Google.ProtocolBuffers.Descriptors /// <param name="fullName">Fully-qualified name to look up</param>
/// <returns>The symbol with the given name and type,
/// or null if the symbol doesn't exist or has the wrong type</returns>
- internal T FindSymbol<T>(string fullName) where T : class, IDescriptor
+ internal T FindSymbol<T>(string fullName) where T : class
{
IDescriptor result;
descriptorsByName.TryGetValue(fullName, out result);
diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs index 00efdbe8..9fc84c3e 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs @@ -30,9 +30,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System.Collections.Generic;
-using Google.ProtocolBuffers.Collections;
+using Google.Protobuf.Collections;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Internal class containing utility methods when working with descriptors.
diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs index d05d60d7..08516951 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs @@ -31,7 +31,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Thrown when building descriptors fails because the source DescriptorProtos
@@ -40,7 +40,6 @@ namespace Google.ProtocolBuffers.Descriptors public sealed class DescriptorValidationException : Exception
{
private readonly String name;
- private readonly IMessage proto;
private readonly string description;
/// <value>
@@ -52,14 +51,6 @@ namespace Google.ProtocolBuffers.Descriptors }
/// <value>
- /// The protocol message representation of the invalid descriptor.
- /// </value>
- public IMessage ProblemProto
- {
- get { return proto; }
- }
-
- /// <value>
/// A human-readable description of the error. (The Message property
/// is made up of the descriptor's name and this description.)
/// </value>
@@ -75,7 +66,6 @@ namespace Google.ProtocolBuffers.Descriptors // don't want to expose it directly to the user. So, we only provide
// the name and the original proto.
name = problemDescriptor.FullName;
- proto = problemDescriptor.Proto;
this.description = description;
}
@@ -83,7 +73,6 @@ namespace Google.ProtocolBuffers.Descriptors base(problemDescriptor.FullName + ": " + description, cause)
{
name = problemDescriptor.FullName;
- proto = problemDescriptor.Proto;
this.description = description;
}
}
diff --git a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs index a0b81b69..3f2abcaa 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs @@ -30,15 +30,14 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System.Collections.Generic;
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Descriptor for an enum type in a .proto file.
/// </summary>
- public sealed class EnumDescriptor : IndexedDescriptorBase<EnumDescriptorProto, EnumOptions>,
- IEnumLiteMap<EnumValueDescriptor>
+ public sealed class EnumDescriptor : IndexedDescriptorBase<EnumDescriptorProto, EnumOptions>
{
private readonly MessageDescriptor containingType;
private readonly IList<EnumValueDescriptor> values;
@@ -48,14 +47,14 @@ namespace Google.ProtocolBuffers.Descriptors {
containingType = parent;
- if (proto.ValueCount == 0)
+ if (proto.Value.Count == 0)
{
// We cannot allow enums with no values because this would mean there
// would be no valid default value for fields of this type.
throw new DescriptorValidationException(this, "Enums must contain at least one value.");
}
- values = DescriptorUtil.ConvertAndMakeReadOnly(proto.ValueList,
+ values = DescriptorUtil.ConvertAndMakeReadOnly(proto.Value,
(value, i) => new EnumValueDescriptor(value, file, this, i));
File.DescriptorPool.AddSymbol(this);
@@ -78,14 +77,6 @@ namespace Google.ProtocolBuffers.Descriptors }
/// <summary>
- /// Logic moved from FieldSet to continue current behavior
- /// </summary>
- public bool IsValidValue(IEnumLite value)
- {
- return value is EnumValueDescriptor && ((EnumValueDescriptor) value).EnumDescriptor == this;
- }
-
- /// <summary>
/// Finds an enum value by number. If multiple enum values have the
/// same number, this returns the first defined value with that number.
/// </summary>
@@ -94,16 +85,6 @@ namespace Google.ProtocolBuffers.Descriptors return File.DescriptorPool.FindEnumValueByNumber(this, number);
}
- IEnumLite IEnumLiteMap.FindValueByNumber(int number)
- {
- return FindValueByNumber(number);
- }
-
- IEnumLite IEnumLiteMap.FindValueByName(string name)
- {
- return FindValueByName(name);
- }
-
/// <summary>
/// Finds an enum value by name.
/// </summary>
@@ -119,7 +100,7 @@ namespace Google.ProtocolBuffers.Descriptors base.ReplaceProto(newProto);
for (int i = 0; i < values.Count; i++)
{
- values[i].ReplaceProto(newProto.GetValue(i));
+ values[i].ReplaceProto(newProto.Value[i]);
}
}
}
diff --git a/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs index afb9cbbc..6a5eb558 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs @@ -29,15 +29,14 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Descriptor for a single enum value within an enum in a .proto file.
/// </summary>
- public sealed class EnumValueDescriptor : IndexedDescriptorBase<EnumValueDescriptorProto, EnumValueOptions>,
- IEnumLite
+ public sealed class EnumValueDescriptor : IndexedDescriptorBase<EnumValueDescriptorProto, EnumValueOptions>
{
private readonly EnumDescriptor enumDescriptor;
diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs index e7f5a3c1..c7d2e683 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs @@ -32,23 +32,22 @@ using System;
using System.Collections.Generic;
using System.Reflection;
-using Google.ProtocolBuffers.Collections;
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.Collections;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Descriptor for a field or extension within a message in a .proto file.
/// </summary>
public sealed class FieldDescriptor : IndexedDescriptorBase<FieldDescriptorProto, FieldOptions>,
- IComparable<FieldDescriptor>, IFieldDescriptorLite
+ IComparable<FieldDescriptor>
{
private readonly MessageDescriptor extensionScope;
private EnumDescriptor enumType;
private MessageDescriptor messageType;
private MessageDescriptor containingType;
private OneofDescriptor containingOneof;
- private object defaultValue;
private FieldType fieldType;
private MappedType mappedType;
@@ -58,7 +57,7 @@ namespace Google.ProtocolBuffers.Descriptors MessageDescriptor parent, int index, bool isExtension)
: base(proto, file, ComputeFullName(file, parent, proto.Name), index)
{
- if (proto.HasType)
+ if (proto.Type != 0)
{
fieldType = GetFieldTypeFromProtoType(proto.Type);
mappedType = FieldTypeToMappedTypeMap[fieldType];
@@ -72,7 +71,7 @@ namespace Google.ProtocolBuffers.Descriptors if (isExtension)
{
- if (!proto.HasExtendee)
+ if (proto.Extendee != "")
{
throw new DescriptorValidationException(this,
"FieldDescriptorProto.Extendee not set for extension field.");
@@ -89,15 +88,10 @@ namespace Google.ProtocolBuffers.Descriptors }
else
{
- if (proto.HasExtendee)
- {
- throw new DescriptorValidationException(this,
- "FieldDescriptorProto.Extendee set for non-extension field.");
- }
containingType = parent;
- if (proto.HasOneofIndex)
+ if (proto.OneofIndex != 0)
{
- if (proto.OneofIndex < 0 || proto.OneofIndex >= parent.Proto.OneofDeclCount)
+ if (proto.OneofIndex < 0 || proto.OneofIndex >= parent.Proto.OneofDecl.Count)
{
throw new DescriptorValidationException(this,
"FieldDescriptorProto.oneof_index is out of range for type " + parent.Name);
@@ -213,48 +207,15 @@ namespace Google.ProtocolBuffers.Descriptors get { return Proto.Options.Packed; }
}
- /// <valule>
- /// Indicates whether or not the field had an explicitly-defined default value.
- /// </value>
- public bool HasDefaultValue
- {
- get { return Proto.HasDefaultValue; }
- }
-
/// <value>
- /// The field's default value. Valid for all types except messages
- /// and groups. For all other types, the object returned is of the
- /// same class that would be returned by IMessage[this].
- /// For repeated fields this will always be an empty immutable list compatible with IList[object].
- /// For message fields it will always be null. For singular values, it will depend on the descriptor.
+ /// Indicates whether or not this field is an extension. (Only relevant when parsing
+ /// the proto2 descriptor...)
/// </value>
- public object DefaultValue
+ internal bool IsExtension
{
- get
- {
- if (MappedType == MappedType.Message)
- {
- throw new InvalidOperationException(
- "FieldDescriptor.DefaultValue called on an embedded message field.");
- }
- return defaultValue;
- }
+ get { return Proto.Extendee != ""; }
}
- /// <value>
- /// Indicates whether or not this field is an extension.
- /// </value>
- public bool IsExtension
- {
- get { return Proto.HasExtendee; }
- }
-
- /*
- * Get the field's containing type. For extensions, this is the type being
- * extended, not the location where the extension was defined. See
- * {@link #getExtensionScope()}.
- */
-
/// <summary>
/// Get the field's containing type. For extensions, this is the type being
/// extended, not the location where the extension was defined. See
@@ -336,27 +297,6 @@ namespace Google.ProtocolBuffers.Descriptors }
/// <summary>
- /// Compares this descriptor with another one, ordering in "canonical" order
- /// which simply means ascending order by field number. <paramref name="other"/>
- /// must be a field of the same type, i.e. the <see cref="ContainingType"/> of
- /// both fields must be the same.
- /// </summary>
- public int CompareTo(IFieldDescriptorLite other)
- {
- return FieldNumber - other.FieldNumber;
- }
-
- IEnumLiteMap IFieldDescriptorLite.EnumType
- {
- get { return EnumType; }
- }
-
- bool IFieldDescriptorLite.MessageSetWireFormat
- {
- get { return ContainingType.Options.MessageSetWireFormat; }
- }
-
- /// <summary>
/// For enum fields, returns the field's type.
/// </summary>
public EnumDescriptor EnumType
@@ -410,29 +350,12 @@ namespace Google.ProtocolBuffers.Descriptors /// </summary>
internal void CrossLink()
{
- if (Proto.HasExtendee)
- {
- IDescriptor extendee = File.DescriptorPool.LookupSymbol(Proto.Extendee, this);
- if (!(extendee is MessageDescriptor))
- {
- throw new DescriptorValidationException(this, "\"" + Proto.Extendee + "\" is not a message type.");
- }
- containingType = (MessageDescriptor) extendee;
-
- if (!containingType.IsExtensionNumber(FieldNumber))
- {
- throw new DescriptorValidationException(this,
- "\"" + containingType.FullName + "\" does not declare " +
- FieldNumber + " as an extension number.");
- }
- }
-
- if (Proto.HasTypeName)
+ if (Proto.TypeName != "")
{
IDescriptor typeDescriptor =
File.DescriptorPool.LookupSymbol(Proto.TypeName, this);
- if (!Proto.HasType)
+ if (Proto.Type != 0)
{
// Choose field type based on symbol.
if (typeDescriptor is MessageDescriptor)
@@ -460,7 +383,7 @@ namespace Google.ProtocolBuffers.Descriptors }
messageType = (MessageDescriptor) typeDescriptor;
- if (Proto.HasDefaultValue)
+ if (Proto.DefaultValue != "")
{
throw new DescriptorValidationException(this, "Messages can't have default values.");
}
@@ -486,126 +409,14 @@ namespace Google.ProtocolBuffers.Descriptors }
}
- // We don't attempt to parse the default value until here because for
- // enums we need the enum type's descriptor.
- if (Proto.HasDefaultValue)
- {
- if (IsRepeated)
- {
- throw new DescriptorValidationException(this, "Repeated fields cannot have default values.");
- }
-
- try
- {
- switch (FieldType)
- {
- case FieldType.Int32:
- case FieldType.SInt32:
- case FieldType.SFixed32:
- defaultValue = TextFormat.ParseInt32(Proto.DefaultValue);
- break;
- case FieldType.UInt32:
- case FieldType.Fixed32:
- defaultValue = TextFormat.ParseUInt32(Proto.DefaultValue);
- break;
- case FieldType.Int64:
- case FieldType.SInt64:
- case FieldType.SFixed64:
- defaultValue = TextFormat.ParseInt64(Proto.DefaultValue);
- break;
- case FieldType.UInt64:
- case FieldType.Fixed64:
- defaultValue = TextFormat.ParseUInt64(Proto.DefaultValue);
- break;
- case FieldType.Float:
- defaultValue = TextFormat.ParseFloat(Proto.DefaultValue);
- break;
- case FieldType.Double:
- defaultValue = TextFormat.ParseDouble(Proto.DefaultValue);
- break;
- case FieldType.Bool:
- if (Proto.DefaultValue == "true")
- {
- defaultValue = true;
- }
- else if (Proto.DefaultValue == "false")
- {
- defaultValue = false;
- }
- else
- {
- throw new FormatException("Boolean values must be \"true\" or \"false\"");
- }
- break;
- case FieldType.String:
- defaultValue = Proto.DefaultValue;
- break;
- case FieldType.Bytes:
- try
- {
- defaultValue = TextFormat.UnescapeBytes(Proto.DefaultValue);
- }
- catch (FormatException e)
- {
- throw new DescriptorValidationException(this,
- "Couldn't parse default value: " + e.Message);
- }
- break;
- case FieldType.Enum:
- defaultValue = enumType.FindValueByName(Proto.DefaultValue);
- if (defaultValue == null)
- {
- throw new DescriptorValidationException(this,
- "Unknown enum default value: \"" +
- Proto.DefaultValue + "\"");
- }
- break;
- case FieldType.Message:
- case FieldType.Group:
- throw new DescriptorValidationException(this, "Message type had default value.");
- }
- }
- catch (FormatException e)
- {
- DescriptorValidationException validationException =
- new DescriptorValidationException(this,
- "Could not parse default value: \"" + Proto.DefaultValue +
- "\"", e);
- throw validationException;
- }
- }
- else
- {
- // Determine the default default for this field.
- if (IsRepeated)
- {
- defaultValue = Lists<object>.Empty;
- }
- else
- {
- switch (MappedType)
- {
- case MappedType.Enum:
- // We guarantee elsewhere that an enum type always has at least
- // one possible value.
- defaultValue = enumType.Values[0];
- break;
- case MappedType.Message:
- defaultValue = null;
- break;
- default:
- defaultValue = GetDefaultValueForMappedType(MappedType);
- break;
- }
- }
- }
+ // Note: no attempt to perform any default value parsing
if (!IsExtension)
{
File.DescriptorPool.AddFieldByNumber(this);
}
- if (containingType != null && containingType.Options.MessageSetWireFormat)
+ if (containingType != null && containingType.Options != null && containingType.Options.MessageSetWireFormat)
{
if (IsExtension)
{
diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs index 752ecf66..ab15eb01 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs @@ -32,9 +32,9 @@ using System;
using System.Collections.Generic;
using System.Reflection;
-using Google.ProtocolBuffers.Collections;
+using Google.Protobuf.Collections;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Defined specifically for the <see cref="FieldType" /> enumeration,
diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs index 056d3d45..f7ec898e 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs @@ -30,7 +30,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Enumeration of all the possible field types. The odd formatting is to make it very clear
diff --git a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs index fed032bf..164406f9 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs @@ -33,10 +33,10 @@ using System; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
-using Google.ProtocolBuffers.DescriptorProtos;
-using FileOptions = Google.ProtocolBuffers.DescriptorProtos.FileOptions;
+using Google.Protobuf.DescriptorProtos;
+using FileOptions = Google.Protobuf.DescriptorProtos.FileOptions;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Describes a .proto file, including everything defined within.
@@ -75,19 +75,19 @@ namespace Google.ProtocolBuffers.Descriptors pool.AddPackage(Package, this);
- messageTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.MessageTypeList,
+ messageTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.MessageType,
(message, index) =>
new MessageDescriptor(message, this, null, index));
- enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumTypeList,
+ enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumType,
(enumType, index) =>
new EnumDescriptor(enumType, this, null, index));
- services = DescriptorUtil.ConvertAndMakeReadOnly(proto.ServiceList,
+ services = DescriptorUtil.ConvertAndMakeReadOnly(proto.Service,
(service, index) =>
new ServiceDescriptor(service, this, index));
- extensions = DescriptorUtil.ConvertAndMakeReadOnly(proto.ExtensionList,
+ extensions = DescriptorUtil.ConvertAndMakeReadOnly(proto.Extension,
(field, index) =>
new FieldDescriptor(field, this, null, index, true));
}
@@ -104,14 +104,14 @@ namespace Google.ProtocolBuffers.Descriptors nameToFileMap[file.Name] = file;
}
var publicDependencies = new List<FileDescriptor>();
- for (int i = 0; i < proto.PublicDependencyCount; i++)
+ for (int i = 0; i < proto.PublicDependency.Count; i++)
{
- int index = proto.PublicDependencyList[i];
- if (index < 0 || index >= proto.DependencyCount)
+ int index = proto.PublicDependency[i];
+ if (index < 0 || index >= proto.Dependency.Count)
{
throw new DescriptorValidationException(@this, "Invalid public dependency index.");
}
- string name = proto.DependencyList[index];
+ string name = proto.Dependency[index];
FileDescriptor file = nameToFileMap[name];
if (file == null)
{
@@ -371,7 +371,7 @@ namespace Google.ProtocolBuffers.Descriptors /// </summary>
public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData, FileDescriptor[] dependencies)
{
- return InternalBuildGeneratedFileFrom(descriptorData, dependencies, x => null);
+ return InternalBuildGeneratedFileFrom(descriptorData, dependencies, x => { });
}
/// <summary>
@@ -384,9 +384,7 @@ namespace Google.ProtocolBuffers.Descriptors /// in descriptor.proto. The callback may also return null to indicate that
/// no extensions are used in the descriptor.
/// </summary>
- /// <param name="descriptor"></param>
- /// <returns></returns>
- public delegate ExtensionRegistry InternalDescriptorAssigner(FileDescriptor descriptor);
+ public delegate void InternalDescriptorAssigner(FileDescriptor descriptor);
public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData,
FileDescriptor[] dependencies,
@@ -395,7 +393,7 @@ namespace Google.ProtocolBuffers.Descriptors FileDescriptorProto proto;
try
{
- proto = FileDescriptorProto.ParseFrom(descriptorData);
+ proto = FileDescriptorProto.Parser.ParseFrom(descriptorData);
}
catch (InvalidProtocolBufferException e)
{
@@ -414,22 +412,7 @@ namespace Google.ProtocolBuffers.Descriptors throw new ArgumentException("Invalid embedded descriptor for \"" + proto.Name + "\".", e);
}
- ExtensionRegistry registry = descriptorAssigner(result);
-
- if (registry != null)
- {
- // We must re-parse the proto using the registry.
- try
- {
- proto = FileDescriptorProto.ParseFrom(descriptorData, registry);
- }
- catch (InvalidProtocolBufferException e)
- {
- throw new ArgumentException("Failed to parse protocol buffer descriptor for generated code.", e);
- }
-
- result.ReplaceProto(proto);
- }
+ descriptorAssigner(result);
return result;
}
@@ -449,22 +432,22 @@ namespace Google.ProtocolBuffers.Descriptors for (int i = 0; i < messageTypes.Count; i++)
{
- messageTypes[i].ReplaceProto(proto.GetMessageType(i));
+ messageTypes[i].ReplaceProto(proto.MessageType[i]);
}
for (int i = 0; i < enumTypes.Count; i++)
{
- enumTypes[i].ReplaceProto(proto.GetEnumType(i));
+ enumTypes[i].ReplaceProto(proto.EnumType[i]);
}
for (int i = 0; i < services.Count; i++)
{
- services[i].ReplaceProto(proto.GetService(i));
+ services[i].ReplaceProto(proto.Service[i]);
}
for (int i = 0; i < extensions.Count; i++)
{
- extensions[i].ReplaceProto(proto.GetExtension(i));
+ extensions[i].ReplaceProto(proto.Extension[i]);
}
}
diff --git a/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs index 899c1560..afed09a9 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs @@ -30,7 +30,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// The non-generic form of the IDescriptor interface. Useful for describing a general
@@ -48,7 +48,7 @@ namespace Google.ProtocolBuffers.Descriptors /// Strongly-typed form of the IDescriptor interface.
/// </summary>
/// <typeparam name="TProto">Protocol buffer type underlying this descriptor type</typeparam>
- public interface IDescriptor<TProto> : IDescriptor where TProto : IMessage
+ internal interface IDescriptor<TProto> : IDescriptor where TProto : IMessage
{
new TProto Proto { get; }
}
diff --git a/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs b/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs index bdb4eb82..3bc3a911 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs @@ -29,9 +29,9 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Base class for descriptors which are also indexed. This is all of them other than
diff --git a/csharp/src/ProtocolBuffers/Descriptors/MappedType.cs b/csharp/src/ProtocolBuffers/Descriptors/MappedType.cs index 0a555307..97eed683 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/MappedType.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/MappedType.cs @@ -30,7 +30,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Type as it's mapped onto a .NET type.
diff --git a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs index c00711b9..f0ac70ff 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs @@ -31,9 +31,9 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Describes a message type.
@@ -53,33 +53,33 @@ namespace Google.ProtocolBuffers.Descriptors {
containingType = parent;
- oneofs = DescriptorUtil.ConvertAndMakeReadOnly(proto.OneofDeclList,
+ oneofs = DescriptorUtil.ConvertAndMakeReadOnly(proto.OneofDecl,
(oneof, index) =>
new OneofDescriptor(oneof, file, this, index));
- nestedTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.NestedTypeList,
+ nestedTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.NestedType,
(type, index) =>
new MessageDescriptor(type, file, this, index));
- enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumTypeList,
+ enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumType,
(type, index) =>
new EnumDescriptor(type, file, this, index));
// TODO(jonskeet): Sort fields first?
- fields = DescriptorUtil.ConvertAndMakeReadOnly(proto.FieldList,
+ fields = DescriptorUtil.ConvertAndMakeReadOnly(proto.Field,
(field, index) =>
new FieldDescriptor(field, file, this, index, false));
- extensions = DescriptorUtil.ConvertAndMakeReadOnly(proto.ExtensionList,
+ extensions = DescriptorUtil.ConvertAndMakeReadOnly(proto.Extension,
(field, index) =>
new FieldDescriptor(field, file, this, index, true));
- for (int i = 0; i < proto.OneofDeclCount; i++)
+ for (int i = 0; i < proto.OneofDecl.Count; i++)
{
oneofs[i].fields = new FieldDescriptor[oneofs[i].FieldCount];
oneofs[i].fieldCount = 0;
}
- for (int i = 0; i< proto.FieldCount; i++)
+ for (int i = 0; i< proto.Field.Count; i++)
{
OneofDescriptor oneofDescriptor = fields[i].ContainingOneof;
if (oneofDescriptor != null)
@@ -151,7 +151,7 @@ namespace Google.ProtocolBuffers.Descriptors /// </summary>
public bool IsExtensionNumber(int number)
{
- foreach (DescriptorProto.Types.ExtensionRange range in Proto.ExtensionRangeList)
+ foreach (DescriptorProto.Types.ExtensionRange range in Proto.ExtensionRange)
{
if (range.Start <= number && number < range.End)
{
@@ -244,7 +244,7 @@ namespace Google.ProtocolBuffers.Descriptors // If the type allows extensions, an extension with message type could contain
// required fields, so we have to be conservative and assume such an
// extension exists.
- if (Proto.ExtensionRangeCount != 0)
+ if (Proto.ExtensionRange.Count != 0)
{
return true;
}
@@ -275,22 +275,22 @@ namespace Google.ProtocolBuffers.Descriptors for (int i = 0; i < nestedTypes.Count; i++)
{
- nestedTypes[i].ReplaceProto(newProto.GetNestedType(i));
+ nestedTypes[i].ReplaceProto(newProto.NestedType[i]);
}
for (int i = 0; i < enumTypes.Count; i++)
{
- enumTypes[i].ReplaceProto(newProto.GetEnumType(i));
+ enumTypes[i].ReplaceProto(newProto.EnumType[i]);
}
for (int i = 0; i < fields.Count; i++)
{
- fields[i].ReplaceProto(newProto.GetField(i));
+ fields[i].ReplaceProto(newProto.Field[i]);
}
for (int i = 0; i < extensions.Count; i++)
{
- extensions[i].ReplaceProto(newProto.GetExtension(i));
+ extensions[i].ReplaceProto(newProto.Extension[i]);
}
}
}
diff --git a/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs index f9ede245..c7c5f9db 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs @@ -29,9 +29,9 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Describes a single method in a service.
diff --git a/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs index aa62853b..8997cb63 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs @@ -31,9 +31,9 @@ using System; using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
public sealed class OneofDescriptor
{
diff --git a/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs index 02549f9c..f63b9cf4 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs @@ -30,7 +30,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Represents a package in the symbol table. We use PackageDescriptors
diff --git a/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs index 417c0838..52a5cb8f 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs @@ -31,9 +31,9 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
-using Google.ProtocolBuffers.DescriptorProtos;
+using Google.Protobuf.DescriptorProtos;
-namespace Google.ProtocolBuffers.Descriptors
+namespace Google.Protobuf.Descriptors
{
/// <summary>
/// Describes a service type.
@@ -45,7 +45,7 @@ namespace Google.ProtocolBuffers.Descriptors public ServiceDescriptor(ServiceDescriptorProto proto, FileDescriptor file, int index)
: base(proto, file, ComputeFullName(file, null, proto.Name), index)
{
- methods = DescriptorUtil.ConvertAndMakeReadOnly(proto.MethodList,
+ methods = DescriptorUtil.ConvertAndMakeReadOnly(proto.Method,
(method, i) => new MethodDescriptor(method, file, this, i));
file.DescriptorPool.AddSymbol(this);
@@ -82,7 +82,7 @@ namespace Google.ProtocolBuffers.Descriptors base.ReplaceProto(newProto);
for (int i = 0; i < methods.Count; i++)
{
- methods[i].ReplaceProto(newProto.GetMethod(i));
+ methods[i].ReplaceProto(newProto.Method[i]);
}
}
}
diff --git a/csharp/src/ProtocolBuffers/DynamicMessage.cs b/csharp/src/ProtocolBuffers/DynamicMessage.cs deleted file mode 100644 index 0a8772ca..00000000 --- a/csharp/src/ProtocolBuffers/DynamicMessage.cs +++ /dev/null @@ -1,624 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// An implementation of IMessage that can represent arbitrary types, given a MessageaDescriptor.
- /// </summary>
- public sealed partial class DynamicMessage : AbstractMessage<DynamicMessage, DynamicMessage.Builder>
- {
- private readonly MessageDescriptor type;
- private readonly FieldSet fields;
- private readonly FieldDescriptor[] oneofCase;
- private readonly UnknownFieldSet unknownFields;
- private int memoizedSize = -1;
-
- /// <summary>
- /// Creates a DynamicMessage with the given FieldSet.
- /// </summary>
- /// <param name="type"></param>
- /// <param name="fields"></param>
- /// <param name="unknownFields"></param>
- private DynamicMessage(MessageDescriptor type, FieldSet fields,
- FieldDescriptor[] oneofCase, UnknownFieldSet unknownFields)
- {
- this.type = type;
- this.fields = fields;
- this.oneofCase = oneofCase;
- this.unknownFields = unknownFields;
- }
-
- /// <summary>
- /// Returns a DynamicMessage representing the default instance of the given type.
- /// </summary>
- /// <param name="type"></param>
- /// <returns></returns>
- public static DynamicMessage GetDefaultInstance(MessageDescriptor type)
- {
- int oneofDescriptorCount = type.Proto.OneofDeclCount;
- FieldDescriptor[] oneofCase = new FieldDescriptor[oneofDescriptorCount];
- return new DynamicMessage(type, FieldSet.DefaultInstance, oneofCase, UnknownFieldSet.DefaultInstance);
- }
-
- /// <summary>
- /// Parses a message of the given type from the given stream.
- /// </summary>
- public static DynamicMessage ParseFrom(MessageDescriptor type, ICodedInputStream input)
- {
- Builder builder = CreateBuilder(type);
- Builder dynamicBuilder = builder.MergeFrom(input);
- return dynamicBuilder.BuildParsed();
- }
-
- /// <summary>
- /// Parse a message of the given type from the given stream and extension registry.
- /// </summary>
- /// <param name="type"></param>
- /// <param name="input"></param>
- /// <param name="extensionRegistry"></param>
- /// <returns></returns>
- public static DynamicMessage ParseFrom(MessageDescriptor type, ICodedInputStream input,
- ExtensionRegistry extensionRegistry)
- {
- Builder builder = CreateBuilder(type);
- Builder dynamicBuilder = builder.MergeFrom(input, extensionRegistry);
- return dynamicBuilder.BuildParsed();
- }
-
- /// <summary>
- /// Parses a message of the given type from the given stream.
- /// </summary>
- public static DynamicMessage ParseFrom(MessageDescriptor type, Stream input)
- {
- Builder builder = CreateBuilder(type);
- Builder dynamicBuilder = builder.MergeFrom(input);
- return dynamicBuilder.BuildParsed();
- }
-
- /// <summary>
- /// Parse a message of the given type from the given stream and extension registry.
- /// </summary>
- /// <param name="type"></param>
- /// <param name="input"></param>
- /// <param name="extensionRegistry"></param>
- /// <returns></returns>
- public static DynamicMessage ParseFrom(MessageDescriptor type, Stream input, ExtensionRegistry extensionRegistry)
- {
- Builder builder = CreateBuilder(type);
- Builder dynamicBuilder = builder.MergeFrom(input, extensionRegistry);
- return dynamicBuilder.BuildParsed();
- }
-
- /// <summary>
- /// Parse <paramref name="data"/> as a message of the given type and return it.
- /// </summary>
- public static DynamicMessage ParseFrom(MessageDescriptor type, ByteString data)
- {
- Builder builder = CreateBuilder(type);
- Builder dynamicBuilder = builder.MergeFrom(data);
- return dynamicBuilder.BuildParsed();
- }
-
- /// <summary>
- /// Parse <paramref name="data"/> as a message of the given type and return it.
- /// </summary>
- public static DynamicMessage ParseFrom(MessageDescriptor type, ByteString data,
- ExtensionRegistry extensionRegistry)
- {
- Builder builder = CreateBuilder(type);
- Builder dynamicBuilder = builder.MergeFrom(data, extensionRegistry);
- return dynamicBuilder.BuildParsed();
- }
-
- /// <summary>
- /// Parse <paramref name="data"/> as a message of the given type and return it.
- /// </summary>
- public static DynamicMessage ParseFrom(MessageDescriptor type, byte[] data)
- {
- Builder builder = CreateBuilder(type);
- Builder dynamicBuilder = builder.MergeFrom(data);
- return dynamicBuilder.BuildParsed();
- }
-
- /// <summary>
- /// Parse <paramref name="data"/> as a message of the given type and return it.
- /// </summary>
- public static DynamicMessage ParseFrom(MessageDescriptor type, byte[] data, ExtensionRegistry extensionRegistry)
- {
- Builder builder = CreateBuilder(type);
- Builder dynamicBuilder = builder.MergeFrom(data, extensionRegistry);
- return dynamicBuilder.BuildParsed();
- }
-
- /// <summary>
- /// Constructs a builder for the given type.
- /// </summary>
- public static Builder CreateBuilder(MessageDescriptor type)
- {
- return new Builder(type);
- }
-
- /// <summary>
- /// Constructs a builder for a message of the same type as <paramref name="prototype"/>,
- /// and initializes it with the same contents.
- /// </summary>
- /// <param name="prototype"></param>
- /// <returns></returns>
- public static Builder CreateBuilder(IMessage prototype)
- {
- return new Builder(prototype.DescriptorForType).MergeFrom(prototype);
- }
-
- // -----------------------------------------------------------------
- // Implementation of IMessage interface.
-
- public override MessageDescriptor DescriptorForType
- {
- get { return type; }
- }
-
- public override DynamicMessage DefaultInstanceForType
- {
- get { return GetDefaultInstance(type); }
- }
-
- public override IDictionary<FieldDescriptor, object> AllFields
- {
- get { return fields.AllFieldDescriptors; }
- }
-
- public override bool HasOneof(OneofDescriptor oneof)
- {
- VerifyContainingOneofType(oneof);
- FieldDescriptor field = oneofCase[oneof.Index];
- if (field == null)
- {
- return false;
- }
- return true;
- }
-
- public override FieldDescriptor OneofFieldDescriptor(OneofDescriptor oneof)
- {
- VerifyContainingOneofType(oneof);
- return oneofCase[oneof.Index];
- }
-
- public override bool HasField(FieldDescriptor field)
- {
- VerifyContainingType(field);
- return fields.HasField(field);
- }
-
- public override object this[FieldDescriptor field]
- {
- get
- {
- VerifyContainingType(field);
- object result = fields[field];
- if (result == null)
- {
- result = GetDefaultInstance(field.MessageType);
- }
- return result;
- }
- }
-
- public override int GetRepeatedFieldCount(FieldDescriptor field)
- {
- VerifyContainingType(field);
- return fields.GetRepeatedFieldCount(field);
- }
-
- public override object this[FieldDescriptor field, int index]
- {
- get
- {
- VerifyContainingType(field);
- return fields[field, index];
- }
- }
-
- public override UnknownFieldSet UnknownFields
- {
- get { return unknownFields; }
- }
-
- public bool Initialized
- {
- get { return fields.IsInitializedWithRespectTo(type.Fields); }
- }
-
- public override void WriteTo(ICodedOutputStream output)
- {
- fields.WriteTo(output);
- if (type.Options.MessageSetWireFormat)
- {
- unknownFields.WriteAsMessageSetTo(output);
- }
- else
- {
- unknownFields.WriteTo(output);
- }
- }
-
- public override int SerializedSize
- {
- get
- {
- int size = memoizedSize;
- if (size != -1)
- {
- return size;
- }
-
- size = fields.SerializedSize;
- if (type.Options.MessageSetWireFormat)
- {
- size += unknownFields.SerializedSizeAsMessageSet;
- }
- else
- {
- size += unknownFields.SerializedSize;
- }
-
- memoizedSize = size;
- return size;
- }
- }
-
- public override Builder CreateBuilderForType()
- {
- return new Builder(type);
- }
-
- public override Builder ToBuilder()
- {
- return CreateBuilderForType().MergeFrom(this);
- }
-
- /// <summary>
- /// Verifies that the field is a field of this message.
- /// </summary>
- private void VerifyContainingType(FieldDescriptor field)
- {
- if (field.ContainingType != type)
- {
- throw new ArgumentException("FieldDescriptor does not match message type.");
- }
- }
-
- /// <summary>
- /// Verifies that the oneof is an oneof of this message.
- /// </summary>
- private void VerifyContainingOneofType(OneofDescriptor oneof)
- {
- if (oneof.ContainingType != type)
- {
- throw new ArgumentException("OneofDescritpor does not match message type");
- }
- }
-
- /// <summary>
- /// Builder for dynamic messages. Instances are created with DynamicMessage.CreateBuilder.
- /// </summary>
- public sealed partial class Builder : AbstractBuilder<DynamicMessage, Builder>
- {
- private readonly MessageDescriptor type;
- private FieldSet fields;
- private FieldDescriptor[] oneofCase;
- private UnknownFieldSet unknownFields;
-
- internal Builder(MessageDescriptor type)
- {
- this.type = type;
- this.fields = FieldSet.CreateInstance();
- this.unknownFields = UnknownFieldSet.DefaultInstance;
- this.oneofCase = new FieldDescriptor[type.Proto.OneofDeclCount];
- }
-
- protected override Builder ThisBuilder
- {
- get { return this; }
- }
-
- public override Builder Clear()
- {
- fields.Clear();
- return this;
- }
-
- public override Builder MergeFrom(IMessage other)
- {
- if (other.DescriptorForType != type)
- {
- throw new ArgumentException("MergeFrom(IMessage) can only merge messages of the same type.");
- }
- fields.MergeFrom(other);
- MergeUnknownFields(other.UnknownFields);
- for (int i = 0; i < oneofCase.Length; i++)
- {
- if (other.HasOneof(type.Oneofs[i]))
- {
- if (oneofCase[i] == null)
- {
- oneofCase[i] = other.OneofFieldDescriptor(type.Oneofs[i]);
- } else
- {
- if (oneofCase[i] != other.OneofFieldDescriptor(type.Oneofs[i]))
- {
- fields.ClearField(oneofCase[i]);
- oneofCase[i] = other.OneofFieldDescriptor(type.Oneofs[i]);
- }
- }
- }
- }
- return this;
- }
-
- public override Builder MergeFrom(DynamicMessage other)
- {
- IMessage downcast = other;
- return MergeFrom(downcast);
- }
-
- public override DynamicMessage Build()
- {
- if (fields != null && !IsInitialized)
- {
- throw new UninitializedMessageException(new DynamicMessage(type, fields, oneofCase, unknownFields));
- }
- return BuildPartial();
- }
-
- /// <summary>
- /// Helper for DynamicMessage.ParseFrom() methods to call. Throws
- /// InvalidProtocolBufferException
- /// </summary>
- /// <returns></returns>
- internal DynamicMessage BuildParsed()
- {
- if (!IsInitialized)
- {
- throw new UninitializedMessageException(new DynamicMessage(type, fields, oneofCase, unknownFields)).
- AsInvalidProtocolBufferException();
- }
- return BuildPartial();
- }
-
- public override DynamicMessage BuildPartial()
- {
- if (fields == null)
- {
- throw new InvalidOperationException("Build() has already been called on this Builder.");
- }
- fields.MakeImmutable();
- DynamicMessage result = new DynamicMessage(type, fields, oneofCase, unknownFields);
- fields = null;
- unknownFields = null;
- return result;
- }
-
- public override Builder Clone()
- {
- Builder result = new Builder(type);
- result.fields.MergeFrom(fields);
- result.oneofCase = oneofCase;
- return result;
- }
-
- public override bool IsInitialized
- {
- get { return fields.IsInitializedWithRespectTo(type.Fields); }
- }
-
- public override Builder MergeFrom(ICodedInputStream input, ExtensionRegistry extensionRegistry)
- {
- UnknownFieldSet.Builder unknownFieldsBuilder = UnknownFieldSet.CreateBuilder(unknownFields);
- unknownFieldsBuilder.MergeFrom(input, extensionRegistry, this);
- unknownFields = unknownFieldsBuilder.Build();
- return this;
- }
-
- public override MessageDescriptor DescriptorForType
- {
- get { return type; }
- }
-
- public override DynamicMessage DefaultInstanceForType
- {
- get { return GetDefaultInstance(type); }
- }
-
- public override IDictionary<FieldDescriptor, object> AllFields
- {
- get { return fields.AllFieldDescriptors; }
- }
-
- public override IBuilder CreateBuilderForField(FieldDescriptor field)
- {
- VerifyContainingType(field);
- if (field.MappedType != MappedType.Message)
- {
- throw new ArgumentException("CreateBuilderForField is only valid for fields with message type.");
- }
- return new Builder(field.MessageType);
- }
-
- public override bool HasOneof(OneofDescriptor oneof)
- {
- VerifyContainingOneofType(oneof);
- FieldDescriptor field = oneofCase[oneof.Index];
- if (field == null)
- {
- return false;
- }
- return true;
- }
-
- public override FieldDescriptor OneofFieldDescriptor(OneofDescriptor oneof)
- {
- VerifyContainingOneofType(oneof);
- return oneofCase[oneof.Index];
- }
-
- public override bool HasField(FieldDescriptor field)
- {
- VerifyContainingType(field);
- return fields.HasField(field);
- }
-
- public override object this[FieldDescriptor field, int index]
- {
- get
- {
- VerifyContainingType(field);
- return fields[field, index];
- }
- set
- {
- VerifyContainingType(field);
- fields[field, index] = value;
- }
- }
-
- public override object this[FieldDescriptor field]
- {
- get
- {
- VerifyContainingType(field);
- object result = fields[field];
- if (result == null)
- {
- result = GetDefaultInstance(field.MessageType);
- }
- return result;
- }
- set
- {
- VerifyContainingType(field);
- OneofDescriptor oneof = field.ContainingOneof;
- if (oneof != null)
- {
- int index = oneof.Index;
- FieldDescriptor oldField = oneofCase[index];
- if ((oldField != null) && (oldField != field))
- {
- fields.ClearField(oldField);
- }
- oneofCase[index] = field;
- }
- fields[field] = value;
- }
- }
-
- public override Builder ClearField(FieldDescriptor field)
- {
- VerifyContainingType(field);
- OneofDescriptor oneof = field.ContainingOneof;
- if (oneof != null)
- {
- int index = oneof.Index;
- if (oneofCase[index] == field)
- {
- oneofCase[index] = null;
- }
- }
- fields.ClearField(field);
- return this;
- }
-
- public override Builder ClearOneof(OneofDescriptor oneof)
- {
- VerifyContainingOneofType(oneof);
- FieldDescriptor field = oneofCase[oneof.Index];
- if (field != null)
- {
- ClearField(field);
- }
- return this;
- }
-
- public override int GetRepeatedFieldCount(FieldDescriptor field)
- {
- VerifyContainingType(field);
- return fields.GetRepeatedFieldCount(field);
- }
-
- public override Builder AddRepeatedField(FieldDescriptor field, object value)
- {
- VerifyContainingType(field);
- fields.AddRepeatedField(field, value);
- return this;
- }
-
- public override UnknownFieldSet UnknownFields
- {
- get { return unknownFields; }
- set { unknownFields = value; }
- }
-
- /// <summary>
- /// Verifies that the field is a field of this message.
- /// </summary>
- /// <param name="field"></param>
- private void VerifyContainingType(FieldDescriptor field)
- {
- if (field.ContainingType != type)
- {
- throw new ArgumentException("FieldDescriptor does not match message type.");
- }
- }
-
- /// <summary>
- /// Verifies that the oneof is an oneof of this message.
- /// </summary>
- private void VerifyContainingOneofType(OneofDescriptor oneof)
- {
- if (oneof.ContainingType != type)
- {
- throw new ArgumentException("OneofDescriptor does not match message type");
- }
- }
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/EnumLite.cs b/csharp/src/ProtocolBuffers/EnumLite.cs deleted file mode 100644 index 1301ec2a..00000000 --- a/csharp/src/ProtocolBuffers/EnumLite.cs +++ /dev/null @@ -1,234 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-
-namespace Google.ProtocolBuffers
-{
- ///<summary>
- ///Interface for an enum value or value descriptor, to be used in FieldSet.
- ///The lite library stores enum values directly in FieldSets but the full
- ///library stores EnumValueDescriptors in order to better support reflection.
- ///</summary>
- public interface IEnumLite
- {
- int Number { get; }
- string Name { get; }
- }
-
- ///<summary>
- ///Interface for an object which maps integers to {@link EnumLite}s.
- ///{@link Descriptors.EnumDescriptor} implements this interface by mapping
- ///numbers to {@link Descriptors.EnumValueDescriptor}s. Additionally,
- ///every generated enum type has a static method internalGetValueMap() which
- ///returns an implementation of this type that maps numbers to enum values.
- ///</summary>
- public interface IEnumLiteMap<T> : IEnumLiteMap
- where T : IEnumLite
- {
- new T FindValueByNumber(int number);
- }
-
- public interface IEnumLiteMap
- {
- bool IsValidValue(IEnumLite value);
- IEnumLite FindValueByNumber(int number);
- IEnumLite FindValueByName(string name);
- }
-
- public class EnumLiteMap<TEnum> : IEnumLiteMap<IEnumLite>
- where TEnum : struct, IComparable, IFormattable
- {
- private struct EnumValue : IEnumLite
- {
- private readonly TEnum value;
-
- public EnumValue(TEnum value)
- {
- this.value = value;
- }
-
- int IEnumLite.Number
- {
- get { return Convert.ToInt32(value); }
- }
-
- string IEnumLite.Name
- {
- get { return value.ToString(); }
- }
- }
-
- public IEnumLite FindValueByNumber(int number)
- {
- TEnum val = default(TEnum);
- if (EnumParser<TEnum>.TryConvert(number, ref val))
- {
- return new EnumValue(val);
- }
- return null;
- }
-
- public IEnumLite FindValueByName(string name)
- {
- TEnum val = default(TEnum);
- if (EnumParser<TEnum>.TryConvert(name, ref val))
- {
- return new EnumValue(val);
- }
- return null;
- }
-
- public bool IsValidValue(IEnumLite value)
- {
- TEnum val = default(TEnum);
- return EnumParser<TEnum>.TryConvert(value.Number, ref val);
- }
- }
-
- public static class EnumParser<T> where T : struct, IComparable, IFormattable
- {
- private static readonly Dictionary<int, T> _byNumber;
- private static Dictionary<string, T> _byName;
-
- static EnumParser()
- {
- int[] array;
- try
- {
-#if CLIENTPROFILE
- // It will actually be a T[], but the CLR will let us convert.
- array = (int[])Enum.GetValues(typeof(T));
-#else
- var temp = new List<T>();
- foreach (var fld in typeof (T).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static))
- {
- if (fld.IsLiteral && fld.FieldType == typeof(T))
- {
- temp.Add((T)fld.GetValue(null));
- }
- }
- array = (int[])(object)temp.ToArray();
-#endif
- }
- catch
- {
- _byNumber = null;
- return;
- }
-
- _byNumber = new Dictionary<int, T>(array.Length);
- foreach (int i in array)
- {
- _byNumber[i] = (T)(object)i;
- }
- }
-
- public static bool TryConvert(object input, ref T value)
- {
- if (input is int || input is T)
- {
- return TryConvert((int)input, ref value);
- }
- if (input is string)
- {
- return TryConvert((string)input, ref value);
- }
- return false;
- }
-
- /// <summary>
- /// Tries to convert an integer to its enum representation. This would take an out parameter,
- /// but the caller uses ref, so this approach is simpler.
- /// </summary>
- public static bool TryConvert(int number, ref T value)
- {
- // null indicates an exception at construction, use native IsDefined.
- if (_byNumber == null)
- {
- return Enum.IsDefined(typeof(T), number);
- }
- T converted;
- if (_byNumber != null && _byNumber.TryGetValue(number, out converted))
- {
- value = converted;
- return true;
- }
-
- return false;
- }
-
- /// <summary>
- /// Tries to convert a string to its enum representation. This would take an out parameter,
- /// but the caller uses ref, so this approach is simpler.
- /// </summary>
- public static bool TryConvert(string name, ref T value)
- {
- // null indicates an exception at construction, use native IsDefined/Parse.
- if (_byNumber == null)
- {
- if (Enum.IsDefined(typeof(T), name))
- {
- value = (T)Enum.Parse(typeof(T), name, false);
- return true;
- }
- return false;
- }
-
- // known race, possible multiple threads each build their own copy; however, last writer will win
- var map = _byName;
- if (map == null)
- {
- map = new Dictionary<string, T>(StringComparer.Ordinal);
- foreach (var possible in _byNumber.Values)
- {
- map[possible.ToString()] = possible;
- }
- _byName = map;
- }
-
- T converted;
- if (map.TryGetValue(name, out converted))
- {
- value = converted;
- return true;
- }
-
- return false;
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ExtendableBuilder.cs b/csharp/src/ProtocolBuffers/ExtendableBuilder.cs deleted file mode 100644 index 62508e02..00000000 --- a/csharp/src/ProtocolBuffers/ExtendableBuilder.cs +++ /dev/null @@ -1,212 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- public abstract partial class ExtendableBuilder<TMessage, TBuilder> : GeneratedBuilder<TMessage, TBuilder>
- where TMessage : ExtendableMessage<TMessage, TBuilder>
- where TBuilder : GeneratedBuilder<TMessage, TBuilder>, new()
- {
- protected ExtendableBuilder()
- {
- }
-
- /// <summary>
- /// Checks if a singular extension is present
- /// </summary>
- public bool HasExtension<TExtension>(GeneratedExtensionBase<TExtension> extension)
- {
- return MessageBeingBuilt.HasExtension(extension);
- }
-
- /// <summary>
- /// Returns the number of elements in a repeated extension.
- /// </summary>
- public int GetExtensionCount<TExtension>(GeneratedExtensionBase<IList<TExtension>> extension)
- {
- return MessageBeingBuilt.GetExtensionCount(extension);
- }
-
- /// <summary>
- /// Returns the value of an extension.
- /// </summary>
- public TExtension GetExtension<TExtension>(GeneratedExtensionBase<TExtension> extension)
- {
- return MessageBeingBuilt.GetExtension(extension);
- }
-
- /// <summary>
- /// Returns one element of a repeated extension.
- /// </summary>
- public TExtension GetExtension<TExtension>(GeneratedExtensionBase<IList<TExtension>> extension, int index)
- {
- return MessageBeingBuilt.GetExtension(extension, index);
- }
-
- /// <summary>
- /// Sets the value of an extension.
- /// </summary>
- public TBuilder SetExtension<TExtension>(GeneratedExtensionBase<TExtension> extension, TExtension value)
- {
- ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt;
- message.VerifyExtensionContainingType(extension);
- message.Extensions[extension.Descriptor] = extension.ToReflectionType(value);
- return ThisBuilder;
- }
-
- /// <summary>
- /// Sets the value of one element of a repeated extension.
- /// </summary>
- public TBuilder SetExtension<TExtension>(GeneratedExtensionBase<IList<TExtension>> extension, int index,
- TExtension value)
- {
- ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt;
- message.VerifyExtensionContainingType(extension);
- message.Extensions[extension.Descriptor, index] = extension.SingularToReflectionType(value);
- return ThisBuilder;
- }
-
- /// <summary>
- /// Appends a value to a repeated extension.
- /// </summary>
- public TBuilder AddExtension<TExtension>(GeneratedExtensionBase<IList<TExtension>> extension, TExtension value)
- {
- ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt;
- message.VerifyExtensionContainingType(extension);
- message.Extensions.AddRepeatedField(extension.Descriptor, extension.SingularToReflectionType(value));
- return ThisBuilder;
- }
-
- /// <summary>
- /// Clears an extension.
- /// </summary>
- public TBuilder ClearExtension<TExtension>(GeneratedExtensionBase<TExtension> extension)
- {
- ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt;
- message.VerifyExtensionContainingType(extension);
- message.Extensions.ClearField(extension.Descriptor);
- return ThisBuilder;
- }
-
- /// <summary>
- /// Called by subclasses to parse an unknown field or an extension.
- /// </summary>
- /// <returns>true unless the tag is an end-group tag</returns>
- protected override bool ParseUnknownField(ICodedInputStream input, UnknownFieldSet.Builder unknownFields,
- ExtensionRegistry extensionRegistry, uint tag, string fieldName)
- {
- return unknownFields.MergeFieldFrom(input, extensionRegistry, this, tag, fieldName);
- }
-
- // ---------------------------------------------------------------
- // Reflection
-
-
- public override object this[FieldDescriptor field, int index]
- {
- set
- {
- if (field.IsExtension)
- {
- ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt;
- message.VerifyContainingType(field);
- message.Extensions[field, index] = value;
- }
- else
- {
- base[field, index] = value;
- }
- }
- }
-
-
- public override object this[FieldDescriptor field]
- {
- set
- {
- if (field.IsExtension)
- {
- ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt;
- message.VerifyContainingType(field);
- message.Extensions[field] = value;
- }
- else
- {
- base[field] = value;
- }
- }
- }
-
- public override TBuilder ClearField(FieldDescriptor field)
- {
- if (field.IsExtension)
- {
- ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt;
- message.VerifyContainingType(field);
- message.Extensions.ClearField(field);
- return ThisBuilder;
- }
- else
- {
- return base.ClearField(field);
- }
- }
-
- public override TBuilder AddRepeatedField(FieldDescriptor field, object value)
- {
- if (field.IsExtension)
- {
- ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt;
- message.VerifyContainingType(field);
- message.Extensions.AddRepeatedField(field, value);
- return ThisBuilder;
- }
- else
- {
- return base.AddRepeatedField(field, value);
- }
- }
-
- protected void MergeExtensionFields(ExtendableMessage<TMessage, TBuilder> other)
- {
- MessageBeingBuilt.Extensions.MergeFrom(other.Extensions);
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ExtendableBuilderLite.cs b/csharp/src/ProtocolBuffers/ExtendableBuilderLite.cs deleted file mode 100644 index 7f97ccfb..00000000 --- a/csharp/src/ProtocolBuffers/ExtendableBuilderLite.cs +++ /dev/null @@ -1,345 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- public abstract partial class ExtendableBuilderLite<TMessage, TBuilder> : GeneratedBuilderLite<TMessage, TBuilder>
- where TMessage : ExtendableMessageLite<TMessage, TBuilder>
- where TBuilder : GeneratedBuilderLite<TMessage, TBuilder>
- {
- protected ExtendableBuilderLite()
- {
- }
-
- /// <summary>
- /// Checks if a singular extension is present
- /// </summary>
- public bool HasExtension<TExtension>(GeneratedExtensionLite<TMessage, TExtension> extension)
- {
- return MessageBeingBuilt.HasExtension(extension);
- }
-
- /// <summary>
- /// Returns the number of elements in a repeated extension.
- /// </summary>
- public int GetExtensionCount<TExtension>(GeneratedExtensionLite<TMessage, IList<TExtension>> extension)
- {
- return MessageBeingBuilt.GetExtensionCount(extension);
- }
-
- /// <summary>
- /// Returns the value of an extension.
- /// </summary>
- public TExtension GetExtension<TExtension>(GeneratedExtensionLite<TMessage, TExtension> extension)
- {
- return MessageBeingBuilt.GetExtension(extension);
- }
-
- /// <summary>
- /// Returns one element of a repeated extension.
- /// </summary>
- public TExtension GetExtension<TExtension>(GeneratedExtensionLite<TMessage, IList<TExtension>> extension,
- int index)
- {
- return MessageBeingBuilt.GetExtension(extension, index);
- }
-
- /// <summary>
- /// Sets the value of an extension.
- /// </summary>
- public TBuilder SetExtension<TExtension>(GeneratedExtensionLite<TMessage, TExtension> extension,
- TExtension value)
- {
- ExtendableMessageLite<TMessage, TBuilder> message = MessageBeingBuilt;
- message.VerifyExtensionContainingType(extension);
- message.Extensions[extension.Descriptor] = extension.ToReflectionType(value);
- return ThisBuilder;
- }
-
- /// <summary>
- /// Sets the value of one element of a repeated extension.
- /// </summary>
- public TBuilder SetExtension<TExtension>(GeneratedExtensionLite<TMessage, IList<TExtension>> extension,
- int index, TExtension value)
- {
- ExtendableMessageLite<TMessage, TBuilder> message = MessageBeingBuilt;
- message.VerifyExtensionContainingType(extension);
- message.Extensions[extension.Descriptor, index] = extension.SingularToReflectionType(value);
- return ThisBuilder;
- }
-
- /// <summary>
- /// Appends a value to a repeated extension.
- /// </summary>
- public TBuilder AddExtension<TExtension>(GeneratedExtensionLite<TMessage, IList<TExtension>> extension,
- TExtension value)
- {
- ExtendableMessageLite<TMessage, TBuilder> message = MessageBeingBuilt;
- message.VerifyExtensionContainingType(extension);
- message.Extensions.AddRepeatedField(extension.Descriptor, extension.SingularToReflectionType(value));
- return ThisBuilder;
- }
-
- /// <summary>
- /// Clears an extension.
- /// </summary>
- public TBuilder ClearExtension<TExtension>(GeneratedExtensionLite<TMessage, TExtension> extension)
- {
- ExtendableMessageLite<TMessage, TBuilder> message = MessageBeingBuilt;
- message.VerifyExtensionContainingType(extension);
- message.Extensions.ClearField(extension.Descriptor);
- return ThisBuilder;
- }
-
- /// <summary>
- /// Called by subclasses to parse an unknown field or an extension.
- /// </summary>
- /// <returns>true unless the tag is an end-group tag</returns>
- protected override bool ParseUnknownField(ICodedInputStream input,
- ExtensionRegistry extensionRegistry, uint tag, string fieldName)
- {
- FieldSet extensions = MessageBeingBuilt.Extensions;
-
- WireFormat.WireType wireType = WireFormat.GetTagWireType(tag);
- int fieldNumber = WireFormat.GetTagFieldNumber(tag);
- IGeneratedExtensionLite extension = extensionRegistry[DefaultInstanceForType, fieldNumber];
-
- if (extension == null) //unknown field
- {
- return input.SkipField();
- }
-
- IFieldDescriptorLite field = extension.Descriptor;
-
-
- // Unknown field or wrong wire type. Skip.
- if (field == null)
- {
- return input.SkipField();
- }
- WireFormat.WireType expectedType = field.IsPacked
- ? WireFormat.WireType.LengthDelimited
- : WireFormat.GetWireType(field.FieldType);
- if (wireType != expectedType)
- {
- expectedType = WireFormat.GetWireType(field.FieldType);
- if (wireType == expectedType)
- {
- //Allowed as of 2.3, this is unpacked data for a packed array
- }
- else if (field.IsRepeated && wireType == WireFormat.WireType.LengthDelimited &&
- (expectedType == WireFormat.WireType.Varint || expectedType == WireFormat.WireType.Fixed32 ||
- expectedType == WireFormat.WireType.Fixed64))
- {
- //Allowed as of 2.3, this is packed data for an unpacked array
- }
- else
- {
- return input.SkipField();
- }
- }
- if (!field.IsRepeated && wireType != WireFormat.GetWireType(field.FieldType)) //invalid wire type
- {
- return input.SkipField();
- }
-
- switch (field.FieldType)
- {
- case FieldType.Group:
- case FieldType.Message:
- {
- if (!field.IsRepeated)
- {
- IMessageLite message = extensions[extension.Descriptor] as IMessageLite;
- IBuilderLite subBuilder = (message ?? extension.MessageDefaultInstance).WeakToBuilder();
-
- if (field.FieldType == FieldType.Group)
- {
- input.ReadGroup(field.FieldNumber, subBuilder, extensionRegistry);
- }
- else
- {
- input.ReadMessage(subBuilder, extensionRegistry);
- }
-
- extensions[field] = subBuilder.WeakBuild();
- }
- else
- {
- List<IMessageLite> list = new List<IMessageLite>();
- if (field.FieldType == FieldType.Group)
- {
- input.ReadGroupArray(tag, fieldName, list, extension.MessageDefaultInstance,
- extensionRegistry);
- }
- else
- {
- input.ReadMessageArray(tag, fieldName, list, extension.MessageDefaultInstance,
- extensionRegistry);
- }
-
- foreach (IMessageLite m in list)
- {
- extensions.AddRepeatedField(field, m);
- }
- return true;
- }
- break;
- }
- case FieldType.Enum:
- {
- if (!field.IsRepeated)
- {
- object unknown;
- IEnumLite value = null;
- if (input.ReadEnum(ref value, out unknown, field.EnumType))
- {
- extensions[field] = value;
- }
- }
- else
- {
- ICollection<object> unknown;
- List<IEnumLite> list = new List<IEnumLite>();
- input.ReadEnumArray(tag, fieldName, list, out unknown, field.EnumType);
-
- foreach (IEnumLite en in list)
- {
- extensions.AddRepeatedField(field, en);
- }
- }
- break;
- }
- default:
- {
- if (!field.IsRepeated)
- {
- object value = null;
- if (input.ReadPrimitiveField(field.FieldType, ref value))
- {
- extensions[field] = value;
- }
- }
- else
- {
- List<object> list = new List<object>();
- input.ReadPrimitiveArray(field.FieldType, tag, fieldName, list);
- foreach (object oval in list)
- {
- extensions.AddRepeatedField(field, oval);
- }
- }
- break;
- }
- }
-
- return true;
- }
-
- #region Reflection
-
- public object this[IFieldDescriptorLite field, int index]
- {
- set
- {
- if (field.IsExtension)
- {
- ExtendableMessageLite<TMessage, TBuilder> message = MessageBeingBuilt;
- message.Extensions[field, index] = value;
- }
- else
- {
- throw new NotSupportedException("Not supported in the lite runtime.");
- }
- }
- }
-
- public object this[IFieldDescriptorLite field]
- {
- set
- {
- if (field.IsExtension)
- {
- ExtendableMessageLite<TMessage, TBuilder> message = MessageBeingBuilt;
- message.Extensions[field] = value;
- }
- else
- {
- throw new NotSupportedException("Not supported in the lite runtime.");
- }
- }
- }
-
- public TBuilder ClearField(IFieldDescriptorLite field)
- {
- if (field.IsExtension)
- {
- ExtendableMessageLite<TMessage, TBuilder> message = MessageBeingBuilt;
- message.Extensions.ClearField(field);
- return ThisBuilder;
- }
- else
- {
- throw new NotSupportedException("Not supported in the lite runtime.");
- }
- }
-
- public TBuilder AddRepeatedField(IFieldDescriptorLite field, object value)
- {
- if (field.IsExtension)
- {
- ExtendableMessageLite<TMessage, TBuilder> message = MessageBeingBuilt;
- message.Extensions.AddRepeatedField(field, value);
- return ThisBuilder;
- }
- else
- {
- throw new NotSupportedException("Not supported in the lite runtime.");
- }
- }
-
- protected void MergeExtensionFields(ExtendableMessageLite<TMessage, TBuilder> other)
- {
- MessageBeingBuilt.Extensions.MergeFrom(other.Extensions);
- }
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ExtendableMessage.cs b/csharp/src/ProtocolBuffers/ExtendableMessage.cs deleted file mode 100644 index 71cd1b38..00000000 --- a/csharp/src/ProtocolBuffers/ExtendableMessage.cs +++ /dev/null @@ -1,274 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using Google.ProtocolBuffers.Collections;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- public abstract partial class ExtendableMessage<TMessage, TBuilder> : GeneratedMessage<TMessage, TBuilder>
- where TMessage : GeneratedMessage<TMessage, TBuilder>
- where TBuilder : GeneratedBuilder<TMessage, TBuilder>, new()
- {
- protected ExtendableMessage()
- {
- }
-
- private readonly FieldSet extensions = FieldSet.CreateInstance();
-
- /// <summary>
- /// Access for the builder.
- /// </summary>
- internal FieldSet Extensions
- {
- get { return extensions; }
- }
-
- /// <summary>
- /// Checks if a singular extension is present.
- /// </summary>
- public bool HasExtension<TExtension>(GeneratedExtensionBase<TExtension> extension)
- {
- return extensions.HasField(extension.Descriptor);
- }
-
- /// <summary>
- /// Returns the number of elements in a repeated extension.
- /// </summary>
- public int GetExtensionCount<TExtension>(GeneratedExtensionBase<IList<TExtension>> extension)
- {
- return extensions.GetRepeatedFieldCount(extension.Descriptor);
- }
-
- /// <summary>
- /// Returns the value of an extension.
- /// </summary>
- public TExtension GetExtension<TExtension>(GeneratedExtensionBase<TExtension> extension)
- {
- object value = extensions[extension.Descriptor];
- if (value == null)
- {
- return (TExtension) extension.MessageDefaultInstance;
- }
- else
- {
- return (TExtension) extension.FromReflectionType(value);
- }
- }
-
- /// <summary>
- /// Returns one element of a repeated extension.
- /// </summary>
- public TExtension GetExtension<TExtension>(GeneratedExtensionBase<IList<TExtension>> extension, int index)
- {
- return (TExtension) extension.SingularFromReflectionType(extensions[extension.Descriptor, index]);
- }
-
- /// <summary>
- /// Called to check if all extensions are initialized.
- /// </summary>
- protected bool ExtensionsAreInitialized
- {
- get { return extensions.IsInitialized; }
- }
-
- public override bool IsInitialized
- {
- get { return base.IsInitialized && ExtensionsAreInitialized; }
- }
-
- #region Reflection
-
- public override IDictionary<FieldDescriptor, object> AllFields
- {
- get
- {
- IDictionary<FieldDescriptor, object> result = GetMutableFieldMap();
- foreach (KeyValuePair<IFieldDescriptorLite, object> entry in extensions.AllFields)
- {
- result[(FieldDescriptor) entry.Key] = entry.Value;
- }
- return Dictionaries.AsReadOnly(result);
- }
- }
-
- public override bool HasField(FieldDescriptor field)
- {
- if (field.IsExtension)
- {
- VerifyContainingType(field);
- return extensions.HasField(field);
- }
- else
- {
- return base.HasField(field);
- }
- }
-
- public override object this[FieldDescriptor field]
- {
- get
- {
- if (field.IsExtension)
- {
- VerifyContainingType(field);
- object value = extensions[field];
- if (value == null)
- {
- // Lacking an ExtensionRegistry, we have no way to determine the
- // extension's real type, so we return a DynamicMessage.
- // TODO(jonskeet): Work out what this means
- return DynamicMessage.GetDefaultInstance(field.MessageType);
- }
- else
- {
- return value;
- }
- }
- else
- {
- return base[field];
- }
- }
- }
-
- public override int GetRepeatedFieldCount(FieldDescriptor field)
- {
- if (field.IsExtension)
- {
- VerifyContainingType(field);
- return extensions.GetRepeatedFieldCount(field);
- }
- else
- {
- return base.GetRepeatedFieldCount(field);
- }
- }
-
- public override object this[FieldDescriptor field, int index]
- {
- get
- {
- if (field.IsExtension)
- {
- VerifyContainingType(field);
- return extensions[field, index];
- }
- else
- {
- return base[field, index];
- }
- }
- }
-
- internal void VerifyContainingType(FieldDescriptor field)
- {
- if (field.ContainingType != DescriptorForType)
- {
- throw new ArgumentException("FieldDescriptor does not match message type.");
- }
- }
-
- #endregion
-
- /// <summary>
- /// Used by subclasses to serialize extensions. Extension ranges may be
- /// interleaves with field numbers, but we must write them in canonical
- /// (sorted by field number) order. This class helps us to write individual
- /// ranges of extensions at once.
- ///
- /// TODO(jonskeet): See if we can improve this in terms of readability.
- /// </summary>
- protected class ExtensionWriter
- {
- private readonly IEnumerator<KeyValuePair<IFieldDescriptorLite, object>> iterator;
- private readonly FieldSet extensions;
- private KeyValuePair<IFieldDescriptorLite, object>? next = null;
-
- internal ExtensionWriter(ExtendableMessage<TMessage, TBuilder> message)
- {
- extensions = message.extensions;
- iterator = message.extensions.GetEnumerator();
- if (iterator.MoveNext())
- {
- next = iterator.Current;
- }
- }
-
- public void WriteUntil(int end, ICodedOutputStream output)
- {
- while (next != null && next.Value.Key.FieldNumber < end)
- {
- extensions.WriteField(next.Value.Key, next.Value.Value, output);
- if (iterator.MoveNext())
- {
- next = iterator.Current;
- }
- else
- {
- next = null;
- }
- }
- }
- }
-
- protected ExtensionWriter CreateExtensionWriter(ExtendableMessage<TMessage, TBuilder> message)
- {
- return new ExtensionWriter(message);
- }
-
- /// <summary>
- /// Called by subclasses to compute the size of extensions.
- /// </summary>
- protected int ExtensionsSerializedSize
- {
- get { return extensions.SerializedSize; }
- }
-
- internal void VerifyExtensionContainingType<TExtension>(GeneratedExtensionBase<TExtension> extension)
- {
- if (extension.Descriptor.ContainingType != DescriptorForType)
- {
- // This can only happen if someone uses unchecked operations.
- throw new ArgumentException("Extension is for type \"" + extension.Descriptor.ContainingType.FullName
- + "\" which does not match message type \"" + DescriptorForType.FullName +
- "\".");
- }
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ExtendableMessageLite.cs b/csharp/src/ProtocolBuffers/ExtendableMessageLite.cs deleted file mode 100644 index e682475d..00000000 --- a/csharp/src/ProtocolBuffers/ExtendableMessageLite.cs +++ /dev/null @@ -1,221 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using Google.ProtocolBuffers.Collections;
-
-namespace Google.ProtocolBuffers
-{
- public abstract partial class ExtendableMessageLite<TMessage, TBuilder> : GeneratedMessageLite<TMessage, TBuilder>
- where TMessage : GeneratedMessageLite<TMessage, TBuilder>
- where TBuilder : GeneratedBuilderLite<TMessage, TBuilder>
- {
- protected ExtendableMessageLite()
- {
- }
-
- private readonly FieldSet extensions = FieldSet.CreateInstance();
-
- /// <summary>
- /// Access for the builder.
- /// </summary>
- internal FieldSet Extensions
- {
- get { return extensions; }
- }
-
- public override bool Equals(object obj)
- {
- ExtendableMessageLite<TMessage, TBuilder> other = obj as ExtendableMessageLite<TMessage, TBuilder>;
- return !ReferenceEquals(null, other) &&
- Dictionaries.Equals(extensions.AllFields, other.extensions.AllFields);
- }
-
- public override int GetHashCode()
- {
- return Dictionaries.GetHashCode(extensions.AllFields);
- }
-
- /// <summary>
- /// writes the extensions to the text stream
- /// </summary>
- public override void PrintTo(TextWriter writer)
- {
- foreach (KeyValuePair<IFieldDescriptorLite, object> entry in extensions.AllFields)
- {
- string fn = string.Format("[{0}]", entry.Key.FullName);
- if (entry.Key.IsRepeated)
- {
- foreach (object o in ((IEnumerable) entry.Value))
- {
- PrintField(fn, true, o, writer);
- }
- }
- else
- {
- PrintField(fn, true, entry.Value, writer);
- }
- }
- }
-
- /// <summary>
- /// Checks if a singular extension is present.
- /// </summary>
- public bool HasExtension<TExtension>(GeneratedExtensionLite<TMessage, TExtension> extension)
- {
- VerifyExtensionContainingType(extension);
- return extensions.HasField(extension.Descriptor);
- }
-
- /// <summary>
- /// Returns the number of elements in a repeated extension.
- /// </summary>
- public int GetExtensionCount<TExtension>(GeneratedExtensionLite<TMessage, IList<TExtension>> extension)
- {
- VerifyExtensionContainingType(extension);
- return extensions.GetRepeatedFieldCount(extension.Descriptor);
- }
-
- /// <summary>
- /// Returns the value of an extension.
- /// </summary>
- public TExtension GetExtension<TExtension>(GeneratedExtensionLite<TMessage, TExtension> extension)
- {
- VerifyExtensionContainingType(extension);
- object value = extensions[extension.Descriptor];
- if (value == null)
- {
- return extension.DefaultValue;
- }
- else
- {
- return (TExtension) extension.FromReflectionType(value);
- }
- }
-
- /// <summary>
- /// Returns one element of a repeated extension.
- /// </summary>
- public TExtension GetExtension<TExtension>(GeneratedExtensionLite<TMessage, IList<TExtension>> extension,
- int index)
- {
- VerifyExtensionContainingType(extension);
- return (TExtension) extension.SingularFromReflectionType(extensions[extension.Descriptor, index]);
- }
-
- /// <summary>
- /// Called to check if all extensions are initialized.
- /// </summary>
- protected bool ExtensionsAreInitialized
- {
- get { return extensions.IsInitialized; }
- }
-
- public override bool IsInitialized
- {
- get { return ExtensionsAreInitialized; }
- }
-
- /// <summary>
- /// Used by subclasses to serialize extensions. Extension ranges may be
- /// interleaves with field numbers, but we must write them in canonical
- /// (sorted by field number) order. This class helps us to write individual
- /// ranges of extensions at once.
- ///
- /// TODO(jonskeet): See if we can improve this in terms of readability.
- /// </summary>
- protected class ExtensionWriter
- {
- private readonly IEnumerator<KeyValuePair<IFieldDescriptorLite, object>> iterator;
- private readonly FieldSet extensions;
- private KeyValuePair<IFieldDescriptorLite, object>? next = null;
-
- internal ExtensionWriter(ExtendableMessageLite<TMessage, TBuilder> message)
- {
- extensions = message.extensions;
- iterator = message.extensions.GetEnumerator();
- if (iterator.MoveNext())
- {
- next = iterator.Current;
- }
- }
-
- public void WriteUntil(int end, ICodedOutputStream output)
- {
- while (next != null && next.Value.Key.FieldNumber < end)
- {
- extensions.WriteField(next.Value.Key, next.Value.Value, output);
- if (iterator.MoveNext())
- {
- next = iterator.Current;
- }
- else
- {
- next = null;
- }
- }
- }
- }
-
- protected ExtensionWriter CreateExtensionWriter(ExtendableMessageLite<TMessage, TBuilder> message)
- {
- return new ExtensionWriter(message);
- }
-
- /// <summary>
- /// Called by subclasses to compute the size of extensions.
- /// </summary>
- protected int ExtensionsSerializedSize
- {
- get { return extensions.SerializedSize; }
- }
-
- internal void VerifyExtensionContainingType<TExtension>(GeneratedExtensionLite<TMessage, TExtension> extension)
- {
- if (!ReferenceEquals(extension.ContainingTypeDefaultInstance, DefaultInstanceForType))
- {
- // This can only happen if someone uses unchecked operations.
- throw new ArgumentException(
- String.Format("Extension is for type \"{0}\" which does not match message type \"{1}\".",
- extension.ContainingTypeDefaultInstance, DefaultInstanceForType
- ));
- }
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ExtensionInfo.cs b/csharp/src/ProtocolBuffers/ExtensionInfo.cs deleted file mode 100644 index 4f11d3bb..00000000 --- a/csharp/src/ProtocolBuffers/ExtensionInfo.cs +++ /dev/null @@ -1,88 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- public sealed class ExtensionInfo : IGeneratedExtensionLite
- {
- /// <summary>
- /// The extension's descriptor
- /// </summary>
- public FieldDescriptor Descriptor { get; private set; }
-
- IFieldDescriptorLite IGeneratedExtensionLite.Descriptor
- {
- get { return Descriptor; }
- }
-
- /// <summary>
- /// A default instance of the extensions's type, if it has a message type,
- /// or null otherwise.
- /// </summary>
- public IMessageLite DefaultInstance { get; private set; }
-
- internal ExtensionInfo(FieldDescriptor descriptor) : this(descriptor, null)
- {
- }
-
- internal ExtensionInfo(FieldDescriptor descriptor, IMessageLite defaultInstance)
- {
- Descriptor = descriptor;
- DefaultInstance = defaultInstance;
- }
-
- #region IGeneratedExtensionLite Members
-
- int IGeneratedExtensionLite.Number
- {
- get { return Descriptor.FieldNumber; }
- }
-
- object IGeneratedExtensionLite.ContainingType
- {
- get { return Descriptor.ContainingType; }
- }
-
- IMessageLite IGeneratedExtensionLite.MessageDefaultInstance
- {
- get { return DefaultInstance; }
- }
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ExtensionRegistry.cs b/csharp/src/ProtocolBuffers/ExtensionRegistry.cs deleted file mode 100644 index 7c9467b5..00000000 --- a/csharp/src/ProtocolBuffers/ExtensionRegistry.cs +++ /dev/null @@ -1,215 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// A table of known extensions, searchable by name or field number. When
- /// parsing a protocol message that might have extensions, you must provide
- /// an <see cref="ExtensionRegistry"/> in which you have registered any extensions
- /// that you want to be able to parse. Otherwise, those extensions will just
- /// be treated like unknown fields.
- /// </summary>
- /// <example>
- /// For example, if you had the <c>.proto</c> file:
- /// <code>
- /// option java_class = "MyProto";
- ///
- /// message Foo {
- /// extensions 1000 to max;
- /// }
- ///
- /// extend Foo {
- /// optional int32 bar;
- /// }
- /// </code>
- ///
- /// Then you might write code like:
- ///
- /// <code>
- /// ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
- /// registry.Add(MyProto.Bar);
- /// MyProto.Foo message = MyProto.Foo.ParseFrom(input, registry);
- /// </code>
- /// </example>
- ///
- /// <remarks>
- /// <para>You might wonder why this is necessary. Two alternatives might come to
- /// mind. First, you might imagine a system where generated extensions are
- /// automatically registered when their containing classes are loaded. This
- /// is a popular technique, but is bad design; among other things, it creates a
- /// situation where behavior can change depending on what classes happen to be
- /// loaded. It also introduces a security vulnerability, because an
- /// unprivileged class could cause its code to be called unexpectedly from a
- /// privileged class by registering itself as an extension of the right type.
- /// </para>
- /// <para>Another option you might consider is lazy parsing: do not parse an
- /// extension until it is first requested, at which point the caller must
- /// provide a type to use. This introduces a different set of problems. First,
- /// it would require a mutex lock any time an extension was accessed, which
- /// would be slow. Second, corrupt data would not be detected until first
- /// access, at which point it would be much harder to deal with it. Third, it
- /// could violate the expectation that message objects are immutable, since the
- /// type provided could be any arbitrary message class. An unprivileged user
- /// could take advantage of this to inject a mutable object into a message
- /// belonging to privileged code and create mischief.</para>
- /// </remarks>
- public sealed partial class ExtensionRegistry
- {
- /// <summary>
- /// Finds an extension by fully-qualified field name, in the
- /// proto namespace, i.e. result.Descriptor.FullName will match
- /// <paramref name="fullName"/> if a match is found. A null
- /// reference is returned if the extension can't be found.
- /// </summary>
- [Obsolete("Please use the FindByName method instead.", true)]
- public ExtensionInfo this[string fullName]
- {
- get
- {
- foreach (IGeneratedExtensionLite ext in extensionsByNumber.Values)
- {
- if (StringComparer.Ordinal.Equals(ext.Descriptor.FullName, fullName))
- {
- return ext as ExtensionInfo;
- }
- }
- return null;
- }
- }
-
-#if !LITE
- /// <summary>
- /// Finds an extension by containing type and field number.
- /// A null reference is returned if the extension can't be found.
- /// </summary>
- public ExtensionInfo this[MessageDescriptor containingType, int fieldNumber]
- {
- get
- {
- IGeneratedExtensionLite ret;
- extensionsByNumber.TryGetValue(new ExtensionIntPair(containingType, fieldNumber), out ret);
- return ret as ExtensionInfo;
- }
- }
-
- public ExtensionInfo FindByName(MessageDescriptor containingType, string fieldName)
- {
- return FindExtensionByName(containingType, fieldName) as ExtensionInfo;
- }
-#endif
-
- /// <summary>
- /// Add an extension from a generated file to the registry.
- /// </summary>
- public void Add<TExtension>(GeneratedExtensionBase<TExtension> extension)
- {
- if (extension.Descriptor.MappedType == MappedType.Message)
- {
- Add(new ExtensionInfo(extension.Descriptor, extension.MessageDefaultInstance));
- }
- else
- {
- Add(new ExtensionInfo(extension.Descriptor, null));
- }
- }
-
- /// <summary>
- /// Adds a non-message-type extension to the registry by descriptor.
- /// </summary>
- /// <param name="type"></param>
- public void Add(FieldDescriptor type)
- {
- if (type.MappedType == MappedType.Message)
- {
- throw new ArgumentException("ExtensionRegistry.Add() must be provided a default instance "
- + "when adding an embedded message extension.");
- }
- Add(new ExtensionInfo(type, null));
- }
-
- /// <summary>
- /// Adds a message-type-extension to the registry by descriptor.
- /// </summary>
- /// <param name="type"></param>
- /// <param name="defaultInstance"></param>
- public void Add(FieldDescriptor type, IMessage defaultInstance)
- {
- if (type.MappedType != MappedType.Message)
- {
- throw new ArgumentException("ExtensionRegistry.Add() provided a default instance for a "
- + "non-message extension.");
- }
- Add(new ExtensionInfo(type, defaultInstance));
- }
-
- private void Add(ExtensionInfo extension)
- {
- if (readOnly)
- {
- throw new InvalidOperationException("Cannot add entries to a read-only extension registry");
- }
- if (!extension.Descriptor.IsExtension)
- {
- throw new ArgumentException("ExtensionRegistry.add() was given a FieldDescriptor for a "
- + "regular (non-extension) field.");
- }
-
- IGeneratedExtensionLite liteExtension = extension;
- Add(liteExtension);
-
- FieldDescriptor field = extension.Descriptor;
- if (field.ContainingType.Options.MessageSetWireFormat
- && field.FieldType == FieldType.Message
- && field.IsOptional
- && field.ExtensionScope == field.MessageType)
- {
- // This is an extension of a MessageSet type defined within the extension
- // type's own scope. For backwards-compatibility, allow it to be looked
- // up by type name.
- Dictionary<string, IGeneratedExtensionLite> map;
- if (extensionsByName.TryGetValue(liteExtension.ContainingType, out map))
- {
- map[field.MessageType.FullName] = extension;
- }
- }
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ExtensionRegistryLite.cs b/csharp/src/ProtocolBuffers/ExtensionRegistryLite.cs deleted file mode 100644 index cc4a50bb..00000000 --- a/csharp/src/ProtocolBuffers/ExtensionRegistryLite.cs +++ /dev/null @@ -1,232 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using ExtensionByNameMap = System.Collections.Generic.Dictionary<object, System.Collections.Generic.Dictionary<string, Google.ProtocolBuffers.IGeneratedExtensionLite>>;
-using ExtensionByIdMap = System.Collections.Generic.Dictionary<Google.ProtocolBuffers.ExtensionRegistry.ExtensionIntPair, Google.ProtocolBuffers.IGeneratedExtensionLite>;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// A table of known extensions, searchable by name or field number. When
- /// parsing a protocol message that might have extensions, you must provide
- /// an <see cref="ExtensionRegistry"/> in which you have registered any extensions
- /// that you want to be able to parse. Otherwise, those extensions will just
- /// be treated like unknown fields.
- /// </summary>
- /// <example>
- /// For example, if you had the <c>.proto</c> file:
- /// <code>
- /// option java_class = "MyProto";
- ///
- /// message Foo {
- /// extensions 1000 to max;
- /// }
- ///
- /// extend Foo {
- /// optional int32 bar;
- /// }
- /// </code>
- ///
- /// Then you might write code like:
- ///
- /// <code>
- /// extensionRegistry registry = extensionRegistry.CreateInstance();
- /// registry.Add(MyProto.Bar);
- /// MyProto.Foo message = MyProto.Foo.ParseFrom(input, registry);
- /// </code>
- /// </example>
- ///
- /// <remarks>
- /// <para>You might wonder why this is necessary. Two alternatives might come to
- /// mind. First, you might imagine a system where generated extensions are
- /// automatically registered when their containing classes are loaded. This
- /// is a popular technique, but is bad design; among other things, it creates a
- /// situation where behavior can change depending on what classes happen to be
- /// loaded. It also introduces a security vulnerability, because an
- /// unprivileged class could cause its code to be called unexpectedly from a
- /// privileged class by registering itself as an extension of the right type.
- /// </para>
- /// <para>Another option you might consider is lazy parsing: do not parse an
- /// extension until it is first requested, at which point the caller must
- /// provide a type to use. This introduces a different set of problems. First,
- /// it would require a mutex lock any time an extension was accessed, which
- /// would be slow. Second, corrupt data would not be detected until first
- /// access, at which point it would be much harder to deal with it. Third, it
- /// could violate the expectation that message objects are immutable, since the
- /// type provided could be any arbitrary message class. An unprivileged user
- /// could take advantage of this to inject a mutable object into a message
- /// belonging to privileged code and create mischief.</para>
- /// </remarks>
- public sealed partial class ExtensionRegistry
- {
- private static readonly ExtensionRegistry empty = new ExtensionRegistry(
- new ExtensionByNameMap(),
- new ExtensionByIdMap(new ExtensionIntPairEqualityComparer()),
- true);
-
- private readonly ExtensionByNameMap extensionsByName;
- private readonly ExtensionByIdMap extensionsByNumber;
-
- private readonly bool readOnly;
-
- private ExtensionRegistry(ExtensionByNameMap byName, ExtensionByIdMap byNumber, bool readOnly)
- {
- this.extensionsByName = byName;
- this.extensionsByNumber = byNumber;
- this.readOnly = readOnly;
- }
-
- /// <summary>
- /// Construct a new, empty instance.
- /// </summary>
- public static ExtensionRegistry CreateInstance()
- {
- return new ExtensionRegistry(new ExtensionByNameMap(), new ExtensionByIdMap(new ExtensionIntPairEqualityComparer()), false);
- }
-
- public ExtensionRegistry AsReadOnly()
- {
- return new ExtensionRegistry(extensionsByName, extensionsByNumber, true);
- }
-
- /// <summary>
- /// Get the unmodifiable singleton empty instance.
- /// </summary>
- public static ExtensionRegistry Empty
- {
- get { return empty; }
- }
-
- /// <summary>
- /// Finds an extension by containing type and field number.
- /// A null reference is returned if the extension can't be found.
- /// </summary>
- public IGeneratedExtensionLite this[IMessageLite containingType, int fieldNumber]
- {
- get
- {
- IGeneratedExtensionLite ret;
- extensionsByNumber.TryGetValue(new ExtensionIntPair(containingType, fieldNumber), out ret);
- return ret;
- }
- }
-
- public IGeneratedExtensionLite FindByName(IMessageLite defaultInstanceOfType, string fieldName)
- {
- return FindExtensionByName(defaultInstanceOfType, fieldName);
- }
-
- private IGeneratedExtensionLite FindExtensionByName(object forwhat, string fieldName)
- {
- IGeneratedExtensionLite extension = null;
- Dictionary<string, IGeneratedExtensionLite> map;
- if (extensionsByName.TryGetValue(forwhat, out map) && map.TryGetValue(fieldName, out extension))
- {
- return extension;
- }
- return null;
- }
-
- /// <summary>
- /// Add an extension from a generated file to the registry.
- /// </summary>
- public void Add(IGeneratedExtensionLite extension)
- {
- if (readOnly)
- {
- throw new InvalidOperationException("Cannot add entries to a read-only extension registry");
- }
- extensionsByNumber.Add(new ExtensionIntPair(extension.ContainingType, extension.Number), extension);
-
- Dictionary<string, IGeneratedExtensionLite> map;
- if (!extensionsByName.TryGetValue(extension.ContainingType, out map))
- {
- extensionsByName.Add(extension.ContainingType, map = new Dictionary<string, IGeneratedExtensionLite>());
- }
- map[extension.Descriptor.Name] = extension;
- map[extension.Descriptor.FullName] = extension;
- }
-
- /// <summary>
- /// Nested type just used to represent a pair of MessageDescriptor and int, as
- /// the key into the "by number" map.
- /// </summary>
- internal struct ExtensionIntPair : IEquatable<ExtensionIntPair>
- {
- private readonly object msgType;
- private readonly int number;
-
- internal ExtensionIntPair(object msgType, int number)
- {
- this.msgType = msgType;
- this.number = number;
- }
-
- public override int GetHashCode()
- {
- return msgType.GetHashCode()*((1 << 16) - 1) + number;
- }
-
- public override bool Equals(object obj)
- {
- if (!(obj is ExtensionIntPair))
- {
- return false;
- }
- return Equals((ExtensionIntPair) obj);
- }
-
- public bool Equals(ExtensionIntPair other)
- {
- return msgType.Equals(other.msgType) && number == other.number;
- }
- }
-
- internal class ExtensionIntPairEqualityComparer : IEqualityComparer<ExtensionIntPair>
- {
- public bool Equals(ExtensionIntPair x, ExtensionIntPair y)
- {
- return x.Equals(y);
- }
- public int GetHashCode(ExtensionIntPair obj)
- {
- return obj.GetHashCode();
- }
- }
- }
-}
diff --git a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs new file mode 100644 index 00000000..51b94931 --- /dev/null +++ b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using Google.Protobuf; +using Google.Protobuf.FieldAccess; + +namespace Google.Protobuf.FieldAccess +{ + /// <summary> + /// Base class for field accessors. + /// </summary> + /// <typeparam name="T">Type of message containing the field</typeparam> + internal abstract class FieldAccessorBase<T> : IFieldAccessor<T> where T : IMessage<T> + { + private readonly Func<T, object> getValueDelegate; + + internal FieldAccessorBase(string name) + { + PropertyInfo property = typeof(T).GetProperty(name); + if (property == null || !property.CanRead) + { + throw new ArgumentException("Not all required properties/methods available"); + } + getValueDelegate = ReflectionUtil.CreateUpcastDelegate<T>(property.GetGetMethod()); + } + + public object GetValue(T message) + { + return getValueDelegate(message); + } + + public abstract bool HasValue(T message); + public abstract void Clear(T message); + public abstract void SetValue(T message, object value); + } +} diff --git a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs index ad1a4382..c3dbb75a 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs @@ -30,108 +30,51 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
-using Google.ProtocolBuffers.Descriptors;
+using Google.Protobuf.Descriptors;
-namespace Google.ProtocolBuffers.FieldAccess
+namespace Google.Protobuf.FieldAccess
{
/// <summary>
/// Provides access to fields in generated messages via reflection.
- /// This type is public to allow it to be used by generated messages, which
- /// create appropriate instances in the .proto file description class.
- /// TODO(jonskeet): See if we can hide it somewhere...
/// </summary>
- public sealed class FieldAccessorTable<TMessage, TBuilder>
- where TMessage : IMessage<TMessage, TBuilder>
- where TBuilder : IBuilder<TMessage, TBuilder>
+ public sealed class FieldAccessorTable<T> where T : IMessage<T>
{
- private readonly IFieldAccessor<TMessage, TBuilder>[] accessors;
- private readonly OneofAccessor<TMessage, TBuilder>[] oneofs;
-
+ private readonly IFieldAccessor<T>[] accessors;
private readonly MessageDescriptor descriptor;
- public MessageDescriptor Descriptor
- {
- get { return descriptor; }
- }
-
/// <summary>
/// Constructs a FieldAccessorTable for a particular message class.
/// Only one FieldAccessorTable should be constructed per class.
- /// The property names should all actually correspond with the field descriptor's
- /// CSharpOptions.PropertyName property, but bootstrapping issues currently
- /// prevent us from using that. This may be addressed at a future time, in which case
- /// we can keep this constructor for backwards compatibility, just ignoring the parameter.
- /// TODO(jonskeet): Make it so.
/// </summary>
/// <param name="descriptor">The type's descriptor</param>
/// <param name="propertyNames">The Pascal-case names of all the field-based properties in the message.</param>
- public FieldAccessorTable(MessageDescriptor descriptor, String[] propertyNames)
+ public FieldAccessorTable(MessageDescriptor descriptor, string[] propertyNames)
{
this.descriptor = descriptor;
- accessors = new IFieldAccessor<TMessage, TBuilder>[descriptor.Fields.Count];
- oneofs = new OneofAccessor<TMessage, TBuilder>[descriptor.Oneofs.Count];
+ accessors = new IFieldAccessor<T>[descriptor.Fields.Count];
bool supportFieldPresence = descriptor.File.Syntax == FileDescriptor.ProtoSyntax.Proto2;
- int fieldSize = accessors.Length;
- for (int i = 0; i < fieldSize; i++)
- {
- FieldDescriptor field = descriptor.Fields[i];
- string containingOneofName = (field.ContainingOneof != null) ?
- propertyNames[fieldSize +field.ContainingOneof.Index] : null;
- accessors[i] = CreateAccessor(
- field, propertyNames[i], containingOneofName, supportFieldPresence);
- }
- for (int i = 0; i < oneofs.Length; i++)
+ for (int i = 0; i < accessors.Length; i++)
{
- oneofs[i] = new OneofAccessor<TMessage, TBuilder>(descriptor, propertyNames[i + accessors.Length]);
+ var field = descriptor.Fields[i];
+ var name = propertyNames[i];
+ accessors[i] = field.IsRepeated
+ ? (IFieldAccessor<T>) new RepeatedFieldAccessor<T>(propertyNames[i])
+ : new SingleFieldAccessor<T>(field, name, supportFieldPresence);
}
+ // TODO(jonskeet): Oneof support
}
- /// <summary>
- /// Creates an accessor for a single field
- /// </summary>
- private static IFieldAccessor<TMessage, TBuilder> CreateAccessor(
- FieldDescriptor field, string name, string containingOneofName, bool supportFieldPresence)
+ internal IFieldAccessor<T> this[int fieldNumber]
{
- if (field.IsRepeated)
- {
- switch (field.MappedType)
- {
- case MappedType.Message:
- return new RepeatedMessageAccessor<TMessage, TBuilder>(name);
- case MappedType.Enum:
- return new RepeatedEnumAccessor<TMessage, TBuilder>(field, name);
- default:
- return new RepeatedPrimitiveAccessor<TMessage, TBuilder>(name);
- }
- }
- else
+ get
{
- switch (field.MappedType)
- {
- case MappedType.Message:
- {
- if (field.ContainingOneof != null)
- {
- return new SingleMessageAccessor<TMessage, TBuilder>(
- field, name, containingOneofName, supportFieldPresence);
- }
- else
- {
- return new SingleMessageAccessor<TMessage, TBuilder>(
- field, name, containingOneofName, true);
- }
- }
- case MappedType.Enum:
- return new SingleEnumAccessor<TMessage, TBuilder>(
- field, name, containingOneofName, supportFieldPresence);
- default:
- return new SinglePrimitiveAccessor<TMessage, TBuilder>(
- field, name, containingOneofName, supportFieldPresence);
- }
+ FieldDescriptor field = descriptor.FindFieldByNumber(fieldNumber);
+ // TODO: Handle extensions.
+ return accessors[field.Index];
}
}
- internal IFieldAccessor<TMessage, TBuilder> this[FieldDescriptor field]
+ internal IFieldAccessor<T> this[FieldDescriptor field]
{
get
{
@@ -148,14 +91,5 @@ namespace Google.ProtocolBuffers.FieldAccess return accessors[field.Index];
}
}
-
- internal OneofAccessor<TMessage, TBuilder> Oneof(OneofDescriptor oneof)
- {
- if (oneof.ContainingType != descriptor)
- {
- throw new ArgumentException("OneofDescriptor does not match message type");
- }
- return oneofs[oneof.Index];
- }
}
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs index 39d3b85b..7767fb02 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs @@ -30,66 +30,39 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-namespace Google.ProtocolBuffers.FieldAccess
+namespace Google.Protobuf.FieldAccess
{
/// <summary>
/// Allows fields to be reflectively accessed in a smart manner.
/// The property descriptors for each field are created once and then cached.
/// In addition, this interface holds knowledge of repeated fields, builders etc.
/// </summary>
- internal interface IFieldAccessor<TMessage, TBuilder>
- where TMessage : IMessage<TMessage, TBuilder>
- where TBuilder : IBuilder<TMessage, TBuilder>
+ internal interface IFieldAccessor<T> where T : IMessage<T>
{
/// <summary>
- /// Indicates whether the specified message contains the field.
+ /// Indicates whether the specified message contains the field. For primitive fields
+ /// declared in proto3-syntax messages, this simply checks whether the value is the default one.
/// </summary>
- bool Has(TMessage message);
+ /// <exception cref="InvalidOperationException">The field is a repeated field, or a single primitive field.</exception>
+ bool HasValue(T message);
/// <summary>
- /// Gets the count of the repeated field in the specified message.
+ /// Clears the field in the specified message. (For repeated fields,
+ /// this clears the list.)
/// </summary>
- int GetRepeatedCount(TMessage message);
+ void Clear(T message);
/// <summary>
- /// Clears the field in the specified builder.
+ /// Fetches the field value. For repeated values, this will be an
+ /// <see cref="IList"/> implementation.
/// </summary>
- /// <param name="builder"></param>
- void Clear(TBuilder builder);
+ object GetValue(T message);
/// <summary>
- /// Creates a builder for the type of this field (which must be a message field).
+ /// Mutator for single fields only. (Repeated fields must be mutated
+ /// by fetching the list, then mutating that.)
/// </summary>
- IBuilder CreateBuilder();
-
- /// <summary>
- /// Accessor for single fields
- /// </summary>
- object GetValue(TMessage message);
-
- /// <summary>
- /// Mutator for single fields
- /// </summary>
- void SetValue(TBuilder builder, object value);
-
- /// <summary>
- /// Accessor for repeated fields
- /// </summary>
- object GetRepeatedValue(TMessage message, int index);
-
- /// <summary>
- /// Mutator for repeated fields
- /// </summary>
- void SetRepeated(TBuilder builder, int index, object value);
-
- /// <summary>
- /// Adds the specified value to the field in the given builder.
- /// </summary>
- void AddRepeated(TBuilder builder, object value);
-
- /// <summary>
- /// Returns a read-only wrapper around the value of a repeated field.
- /// </summary>
- object GetRepeatedWrapper(TBuilder builder);
+ /// <exception cref="InvalidOperationException">The field is a repeated field.</exception>
+ void SetValue(T message, object value);
}
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs index 1a4bda76..85a929b7 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs @@ -29,17 +29,18 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Reflection;
-using Google.ProtocolBuffers.Descriptors;
+using Google.Protobuf.Descriptors;
-namespace Google.ProtocolBuffers.FieldAccess
+namespace Google.Protobuf.FieldAccess
{
+ // TODO(jonskeet): Add "new" oneof API support
+
/// <summary>
/// Access for an oneof
/// </summary>
- internal class OneofAccessor<TMessage, TBuilder>
- where TMessage : IMessage<TMessage, TBuilder>
- where TBuilder : IBuilder<TMessage, TBuilder>
+ internal class OneofAccessor<TMessage> where TMessage : IMessage<TMessage>
{
+ /*
private readonly Func<TMessage, object> caseDelegate;
private readonly Func<TBuilder, IBuilder> clearDelegate;
private MessageDescriptor descriptor;
@@ -86,6 +87,6 @@ namespace Google.ProtocolBuffers.FieldAccess return descriptor.FindFieldByNumber(fieldNumber);
}
return null;
- }
+ }*/
}
}
diff --git a/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs b/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs index 798f0dd7..b3d1c90d 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs @@ -32,7 +32,7 @@ using System;
using System.Reflection;
-namespace Google.ProtocolBuffers.FieldAccess
+namespace Google.Protobuf.FieldAccess
{
/// <summary>
/// The methods in this class are somewhat evil, and should not be tampered with lightly.
@@ -72,7 +72,7 @@ namespace Google.ProtocolBuffers.FieldAccess Func<TSource, TResult> getter = ReflectionUtil.CreateDelegateFunc<TSource, TResult>(method);
// Implicit upcast to object (within the delegate)
- return delegate(TSource source) { return getter(source); };
+ return source => getter(source);
}
/// <summary>
@@ -92,7 +92,7 @@ namespace Google.ProtocolBuffers.FieldAccess // call Method(x, y)
Action<TSource, TParam> call = ReflectionUtil.CreateDelegateAction<TSource, TParam>(method);
- return delegate(TSource source, object parameter) { call(source, (TParam) parameter); };
+ return (source, parameter) => call(source, (TParam) parameter);
}
/// <summary>
@@ -117,73 +117,34 @@ namespace Google.ProtocolBuffers.FieldAccess return delegate(TSource source, object parameter) { call(source, (TParam) parameter); };
}
- /// <summary>
- /// Creates a delegate which will execute the given static method and cast the result up to IBuilder.
- /// </summary>
- public static Func<IBuilder> CreateStaticUpcastDelegate(MethodInfo method)
- {
- MethodInfo openImpl = typeof(ReflectionUtil).GetMethod("CreateStaticUpcastDelegateImpl");
- MethodInfo closedImpl = openImpl.MakeGenericMethod(method.ReturnType);
- return (Func<IBuilder>) closedImpl.Invoke(null, new object[] {method});
- }
-
- public static Func<IBuilder> CreateStaticUpcastDelegateImpl<T>(MethodInfo method)
- {
- Func<T> call = ReflectionUtil.CreateDelegateFunc<T>(method);
- return delegate { return (IBuilder) call(); };
- }
-
-
internal static Func<TResult> CreateDelegateFunc<TResult>(MethodInfo method)
{
-#if !CF20
object tdelegate = Delegate.CreateDelegate(typeof(Func<TResult>), null, method);
return (Func<TResult>)tdelegate;
-#else
- return delegate() { return (TResult)method.Invoke(null, null); };
-#endif
}
internal static Func<T, TResult> CreateDelegateFunc<T, TResult>(MethodInfo method)
{
-#if !CF20
object tdelegate = Delegate.CreateDelegate(typeof(Func<T, TResult>), null, method);
return (Func<T, TResult>)tdelegate;
-#else
- if (method.IsStatic)
- {
- return delegate(T arg1) { return (TResult) method.Invoke(null, new object[] {arg1}); };
- }
- return delegate(T arg1) { return (TResult)method.Invoke(arg1, null); };
-#endif
}
internal static Func<T1, T2, TResult> CreateDelegateFunc<T1, T2, TResult>(MethodInfo method)
{
-#if !CF20
object tdelegate = Delegate.CreateDelegate(typeof(Func<T1, T2, TResult>), null, method);
return (Func<T1, T2, TResult>)tdelegate;
-#else
- if (method.IsStatic)
- {
- return delegate(T1 arg1, T2 arg2) { return (TResult) method.Invoke(null, new object[] {arg1, arg2}); };
- }
- return delegate(T1 arg1, T2 arg2) { return (TResult)method.Invoke(arg1, new object[] { arg2 }); };
-#endif
+ }
+
+ internal static Action<T> CreateDelegateAction<T>(MethodInfo method)
+ {
+ object tdelegate = Delegate.CreateDelegate(typeof(Action<T>), null, method);
+ return (Action<T>)tdelegate;
}
internal static Action<T1, T2> CreateDelegateAction<T1, T2>(MethodInfo method)
{
-#if !CF20
object tdelegate = Delegate.CreateDelegate(typeof(Action<T1, T2>), null, method);
return (Action<T1, T2>)tdelegate;
-#else
- if (method.IsStatic)
- {
- return delegate(T1 arg1, T2 arg2) { method.Invoke(null, new object[] {arg1, arg2}); };
- }
- return delegate(T1 arg1, T2 arg2) { method.Invoke(arg1, new object[] { arg2 }); };
-#endif
}
}
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedEnumAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedEnumAccessor.cs deleted file mode 100644 index 152c2e0a..00000000 --- a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedEnumAccessor.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-using System.Collections;
-using System.Collections.Generic;
-using Google.ProtocolBuffers.Collections;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers.FieldAccess
-{
- /// <summary>
- /// Accessor for a repeated enum field.
- /// </summary>
- internal sealed class RepeatedEnumAccessor<TMessage, TBuilder> : RepeatedPrimitiveAccessor<TMessage, TBuilder>
- where TMessage : IMessage<TMessage, TBuilder>
- where TBuilder : IBuilder<TMessage, TBuilder>
- {
- private readonly EnumDescriptor enumDescriptor;
-
- internal RepeatedEnumAccessor(FieldDescriptor field, string name) : base(name)
- {
- enumDescriptor = field.EnumType;
- }
-
- public override object GetValue(TMessage message)
- {
- List<EnumValueDescriptor> ret = new List<EnumValueDescriptor>();
- foreach (int rawValue in (IEnumerable) base.GetValue(message))
- {
- ret.Add(enumDescriptor.FindValueByNumber(rawValue));
- }
- return Lists.AsReadOnly(ret);
- }
-
- public override object GetRepeatedValue(TMessage message, int index)
- {
- // Note: This relies on the fact that the CLR allows unboxing from an enum to
- // its underlying value
- int rawValue = (int) base.GetRepeatedValue(message, index);
- return enumDescriptor.FindValueByNumber(rawValue);
- }
-
- public override void AddRepeated(TBuilder builder, object value)
- {
- ThrowHelper.ThrowIfNull(value, "value");
- base.AddRepeated(builder, ((EnumValueDescriptor) value).Number);
- }
-
- public override void SetRepeated(TBuilder builder, int index, object value)
- {
- ThrowHelper.ThrowIfNull(value, "value");
- base.SetRepeated(builder, index, ((EnumValueDescriptor) value).Number);
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs new file mode 100644 index 00000000..aea721de --- /dev/null +++ b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Google.Protobuf; + +namespace Google.Protobuf.FieldAccess +{ + /// <summary> + /// Accessor for repeated fields. + /// </summary> + /// <typeparam name="T">The type of message containing the field.</typeparam> + internal sealed class RepeatedFieldAccessor<T> : FieldAccessorBase<T> where T : IMessage<T> + { + internal RepeatedFieldAccessor(string name) : base(name) + { + } + + public override void Clear(T message) + { + IList list = (IList) GetValue(message); + list.Clear(); + } + + public override bool HasValue(T message) + { + throw new NotImplementedException("HasValue is not implemented for repeated fields"); + } + + public override void SetValue(T message, object value) + { + throw new NotImplementedException("SetValue is not implemented for repeated fields"); + } + + } +} diff --git a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedMessageAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedMessageAccessor.cs deleted file mode 100644 index fd18b904..00000000 --- a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedMessageAccessor.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-using System;
-using System.Reflection;
-
-namespace Google.ProtocolBuffers.FieldAccess
-{
- /// <summary>
- /// Accessor for a repeated message field.
- ///
- /// TODO(jonskeet): Try to extract the commonality between this and SingleMessageAccessor.
- /// We almost want multiple inheritance...
- /// </summary>
- internal sealed class RepeatedMessageAccessor<TMessage, TBuilder> : RepeatedPrimitiveAccessor<TMessage, TBuilder>
- where TMessage : IMessage<TMessage, TBuilder>
- where TBuilder : IBuilder<TMessage, TBuilder>
- {
- /// <summary>
- /// The static method to create a builder for the property type. For example,
- /// in a message type "Foo", a field called "bar" might be of type "Baz". This
- /// method is Baz.CreateBuilder.
- /// </summary>
- private readonly Func<IBuilder> createBuilderDelegate;
-
- internal RepeatedMessageAccessor(string name) : base(name)
- {
- MethodInfo createBuilderMethod = ClrType.GetMethod("CreateBuilder", EmptyTypes);
- if (createBuilderMethod == null)
- {
- throw new ArgumentException("No public static CreateBuilder method declared in " + ClrType.Name);
- }
- createBuilderDelegate = ReflectionUtil.CreateStaticUpcastDelegate(createBuilderMethod);
- }
-
- /// <summary>
- /// Creates a message of the appropriate CLR type from the given value,
- /// which may already be of the right type or may be a dynamic message.
- /// </summary>
- private object CoerceType(object value)
- {
- ThrowHelper.ThrowIfNull(value, "value");
- // If it's already of the right type, we're done
- if (ClrType.IsInstanceOfType(value))
- {
- return value;
- }
-
- // No... so let's create a builder of the right type, and merge the value in.
- IMessageLite message = (IMessageLite) value;
- return CreateBuilder().WeakMergeFrom(message).WeakBuild();
- }
-
- public override void SetRepeated(TBuilder builder, int index, object value)
- {
- base.SetRepeated(builder, index, CoerceType(value));
- }
-
- public override IBuilder CreateBuilder()
- {
- return createBuilderDelegate();
- }
-
- public override void AddRepeated(TBuilder builder, object value)
- {
- base.AddRepeated(builder, CoerceType(value));
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs deleted file mode 100644 index d3b926bc..00000000 --- a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs +++ /dev/null @@ -1,158 +0,0 @@ -// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-using System;
-using System.Collections;
-using System.Reflection;
-
-namespace Google.ProtocolBuffers.FieldAccess
-{
- /// <summary>
- /// Accessor for a repeated field of type int, ByteString etc.
- /// </summary>
- internal class RepeatedPrimitiveAccessor<TMessage, TBuilder> : IFieldAccessor<TMessage, TBuilder>
- where TMessage : IMessage<TMessage, TBuilder>
- where TBuilder : IBuilder<TMessage, TBuilder>
- {
- private readonly Type clrType;
- private readonly Func<TMessage, object> getValueDelegate;
- private readonly Func<TBuilder, IBuilder> clearDelegate;
- private readonly Action<TBuilder, object> addValueDelegate;
- private readonly Func<TBuilder, object> getRepeatedWrapperDelegate;
- private readonly Func<TMessage, int> countDelegate;
- private readonly MethodInfo getElementMethod;
- private readonly MethodInfo setElementMethod;
-
- // Replacement for Type.EmptyTypes which apparently isn't available on the compact framework
- internal static readonly Type[] EmptyTypes = new Type[0];
-
- /// <summary>
- /// The CLR type of the field (int, the enum type, ByteString, the message etc).
- /// This is taken from the return type of the method used to retrieve a single
- /// value.
- /// </summary>
- protected Type ClrType
- {
- get { return clrType; }
- }
-
- internal RepeatedPrimitiveAccessor(string name)
- {
- PropertyInfo messageProperty = typeof(TMessage).GetProperty(name + "List");
- PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name + "List");
- PropertyInfo countProperty = typeof(TMessage).GetProperty(name + "Count");
- MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name, EmptyTypes);
- getElementMethod = typeof(TMessage).GetMethod("Get" + name, new Type[] {typeof(int)});
- clrType = getElementMethod.ReturnType;
- MethodInfo addMethod = typeof(TBuilder).GetMethod("Add" + name, new Type[] {ClrType});
- setElementMethod = typeof(TBuilder).GetMethod("Set" + name, new Type[] {typeof(int), ClrType});
- if (messageProperty == null
- || builderProperty == null
- || countProperty == null
- || clearMethod == null
- || addMethod == null
- || getElementMethod == null
- || setElementMethod == null)
- {
- throw new ArgumentException("Not all required properties/methods available");
- }
- clearDelegate = ReflectionUtil.CreateDelegateFunc<TBuilder, IBuilder>(clearMethod);
- countDelegate = ReflectionUtil.CreateDelegateFunc<TMessage, int>(countProperty.GetGetMethod());
- getValueDelegate = ReflectionUtil.CreateUpcastDelegate<TMessage>(messageProperty.GetGetMethod());
- addValueDelegate = ReflectionUtil.CreateDowncastDelegateIgnoringReturn<TBuilder>(addMethod);
- getRepeatedWrapperDelegate = ReflectionUtil.CreateUpcastDelegate<TBuilder>(builderProperty.GetGetMethod());
- }
-
- public bool Has(TMessage message)
- {
- throw new InvalidOperationException();
- }
-
- public virtual IBuilder CreateBuilder()
- {
- throw new InvalidOperationException();
- }
-
- public virtual object GetValue(TMessage message)
- {
- return getValueDelegate(message);
- }
-
- public void SetValue(TBuilder builder, object value)
- {
- // Add all the elements individually. This serves two purposes:
- // 1) Verifies that each element has the correct type.
- // 2) Insures that the caller cannot modify the list later on and
- // have the modifications be reflected in the message.
- Clear(builder);
- foreach (object element in (IEnumerable) value)
- {
- AddRepeated(builder, element);
- }
- }
-
- public void Clear(TBuilder builder)
- {
- clearDelegate(builder);
- }
-
- public int GetRepeatedCount(TMessage message)
- {
- return countDelegate(message);
- }
-
- public virtual object GetRepeatedValue(TMessage message, int index)
- {
- return getElementMethod.Invoke(message, new object[] {index});
- }
-
- public virtual void SetRepeated(TBuilder builder, int index, object value)
- {
- ThrowHelper.ThrowIfNull(value, "value");
- setElementMethod.Invoke(builder, new object[] {index, value});
- }
-
- public virtual void AddRepeated(TBuilder builder, object value)
- {
- ThrowHelper.ThrowIfNull(value, "value");
- addValueDelegate(builder, value);
- }
-
- /// <summary>
- /// The builder class's accessor already builds a read-only wrapper for
- /// us, which is exactly what we want.
- /// </summary>
- public object GetRepeatedWrapper(TBuilder builder)
- {
- return getRepeatedWrapperDelegate(builder);
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/SingleEnumAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/SingleEnumAccessor.cs deleted file mode 100644 index 89e10179..00000000 --- a/csharp/src/ProtocolBuffers/FieldAccess/SingleEnumAccessor.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers.FieldAccess
-{
- /// <summary>
- /// Accessor for fields representing a non-repeated enum value.
- /// </summary>
- internal sealed class SingleEnumAccessor<TMessage, TBuilder> : SinglePrimitiveAccessor<TMessage, TBuilder>
- where TMessage : IMessage<TMessage, TBuilder>
- where TBuilder : IBuilder<TMessage, TBuilder>
- {
- private readonly EnumDescriptor enumDescriptor;
-
- internal SingleEnumAccessor(FieldDescriptor field, string name, string containingOneofName, bool supportFieldPresence)
- : base(field, name, containingOneofName, supportFieldPresence)
- {
- enumDescriptor = field.EnumType;
- }
-
- /// <summary>
- /// Returns an EnumValueDescriptor representing the value in the builder.
- /// Note that if an enum has multiple values for the same number, the descriptor
- /// for the first value with that number will be returned.
- /// </summary>
- public override object GetValue(TMessage message)
- {
- // Note: This relies on the fact that the CLR allows unboxing from an enum to
- // its underlying value
- int rawValue = (int) base.GetValue(message);
- return enumDescriptor.FindValueByNumber(rawValue);
- }
-
- /// <summary>
- /// Sets the value as an enum (via an int) in the builder,
- /// from an EnumValueDescriptor parameter.
- /// </summary>
- public override void SetValue(TBuilder builder, object value)
- {
- ThrowHelper.ThrowIfNull(value, "value");
- EnumValueDescriptor valueDescriptor = (EnumValueDescriptor) value;
- base.SetValue(builder, valueDescriptor.Number);
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs new file mode 100644 index 00000000..a352d3a2 --- /dev/null +++ b/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using Google.Protobuf; +using Google.Protobuf.Descriptors; +using Google.Protobuf.FieldAccess; + +namespace Google.Protobuf.FieldAccess +{ + /// <summary> + /// Accessor for single fields. + /// </summary> + /// <typeparam name="T">The type of message containing the field.</typeparam> + internal sealed class SingleFieldAccessor<T> : FieldAccessorBase<T> where T : IMessage<T> + { + // All the work here is actually done in the constructor - it creates the appropriate delegates. + // There are various cases to consider, based on the property type (message, string/bytes, or "genuine" primitive) + // and proto2 vs proto3 for non-message types, as proto3 doesn't support "full" presence detection or default + // values. + + private readonly Action<T, object> setValueDelegate; + private readonly Action<T> clearDelegate; + private readonly Func<T, bool> hasValueDelegate; + + internal SingleFieldAccessor(FieldDescriptor descriptor, string name, bool supportsFieldPresence) : base(name) + { + PropertyInfo property = typeof(T).GetProperty(name); + // We know there *is* such a property, or the base class constructor would have thrown. We should be able to write + // to it though. + if (!property.CanWrite) + { + throw new ArgumentException("Not all required properties/methods available"); + } + setValueDelegate = ReflectionUtil.CreateDowncastDelegate<T>(property.GetSetMethod()); + + var clrType = property.PropertyType; + + if (typeof(IMessage).IsAssignableFrom(clrType)) + { + // Message types are simple - we only need to detect nullity. + clearDelegate = message => SetValue(message, null); + hasValueDelegate = message => GetValue(message) == null; + } + + if (supportsFieldPresence) + { + // Proto2: we expect a HasFoo property and a ClearFoo method. + // For strings and byte arrays, setting the property to null would have the equivalent effect, + // but we generate the method for consistency, which makes this simpler. + PropertyInfo hasProperty = typeof(T).GetProperty("Has" + name); + MethodInfo clearMethod = typeof(T).GetMethod("Clear" + name); + if (hasProperty == null || clearMethod == null || !hasProperty.CanRead) + { + throw new ArgumentException("Not all required properties/methods available"); + } + hasValueDelegate = ReflectionUtil.CreateDelegateFunc<T, bool>(hasProperty.GetGetMethod()); + clearDelegate = ReflectionUtil.CreateDelegateAction<T>(clearMethod); + } + else + { + /* + // TODO(jonskeet): Reimplement. We need a better way of working out default values. + // Proto3: for field detection, we just need the default value of the field (0, "", byte[0] etc) + // To clear a field, we set the value to that default. + object defaultValue = descriptor.DefaultValue; + hasValueDelegate = message => GetValue(message).Equals(defaultValue); + clearDelegate = message => SetValue(message, defaultValue); + */ + } + } + + public override bool HasValue(T message) + { + return hasValueDelegate(message); + } + + public override void Clear(T message) + { + clearDelegate(message); + } + + public override void SetValue(T message, object value) + { + setValueDelegate(message, value); + } + } +} diff --git a/csharp/src/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs deleted file mode 100644 index 9068d40a..00000000 --- a/csharp/src/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-using System;
-using System.Reflection;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers.FieldAccess
-{
- /// <summary>
- /// Accessor for fields representing a non-repeated message value.
- /// </summary>
- internal sealed class SingleMessageAccessor<TMessage, TBuilder> : SinglePrimitiveAccessor<TMessage, TBuilder>
- where TMessage : IMessage<TMessage, TBuilder>
- where TBuilder : IBuilder<TMessage, TBuilder>
- {
- /// <summary>
- /// The static method to create a builder for the property type. For example,
- /// in a message type "Foo", a field called "bar" might be of type "Baz". This
- /// method is Baz.CreateBuilder.
- /// </summary>
- private readonly Func<IBuilder> createBuilderDelegate;
-
- internal SingleMessageAccessor(FieldDescriptor field, string name, string containingOneofName, bool supportFieldPresence)
- : base(field, name, containingOneofName, supportFieldPresence)
- {
- MethodInfo createBuilderMethod = ClrType.GetMethod("CreateBuilder", ReflectionUtil.EmptyTypes);
- if (createBuilderMethod == null)
- {
- throw new ArgumentException("No public static CreateBuilder method declared in " + ClrType.Name);
- }
- createBuilderDelegate = ReflectionUtil.CreateStaticUpcastDelegate(createBuilderMethod);
- }
-
- /// <summary>
- /// Creates a message of the appropriate CLR type from the given value,
- /// which may already be of the right type or may be a dynamic message.
- /// </summary>
- private object CoerceType(object value)
- {
- ThrowHelper.ThrowIfNull(value, "value");
- // If it's already of the right type, we're done
- if (ClrType.IsInstanceOfType(value))
- {
- return value;
- }
-
- // No... so let's create a builder of the right type, and merge the value in.
- IMessageLite message = (IMessageLite) value;
- return CreateBuilder().WeakMergeFrom(message).WeakBuild();
- }
-
- public override void SetValue(TBuilder builder, object value)
- {
- base.SetValue(builder, CoerceType(value));
- }
-
- public override IBuilder CreateBuilder()
- {
- return createBuilderDelegate();
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs deleted file mode 100644 index 035fcf3c..00000000 --- a/csharp/src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs +++ /dev/null @@ -1,162 +0,0 @@ -// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-using System;
-using System.Reflection;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers.FieldAccess
-{
- /// <summary>
- /// Access for a non-repeated field of a "primitive" type (i.e. not another message or an enum).
- /// </summary>
- internal class SinglePrimitiveAccessor<TMessage, TBuilder> : IFieldAccessor<TMessage, TBuilder>
- where TMessage : IMessage<TMessage, TBuilder>
- where TBuilder : IBuilder<TMessage, TBuilder>
- {
- private readonly Type clrType;
- private readonly Func<TMessage, object> getValueDelegate;
- private readonly Action<TBuilder, object> setValueDelegate;
- private readonly Func<TMessage, bool> hasDelegate;
- private readonly Func<TBuilder, IBuilder> clearDelegate;
- private readonly Func<TMessage, object> caseDelegate;
-
- /// <summary>
- /// The CLR type of the field (int, the enum type, ByteString, the message etc).
- /// As declared by the property.
- /// </summary>
- protected Type ClrType
- {
- get { return clrType; }
- }
-
- internal SinglePrimitiveAccessor(
- FieldDescriptor fieldDescriptor, string name, string containingOneofName, bool supportFieldPresence)
- {
- PropertyInfo messageProperty = typeof(TMessage).GetProperty(name, null, ReflectionUtil.EmptyTypes);
- PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name, null, ReflectionUtil.EmptyTypes);
- MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name);
- if (messageProperty == null || builderProperty == null || clearMethod == null)
- {
- throw new ArgumentException("Not all required properties/methods available");
- }
-
- if (supportFieldPresence)
- {
- PropertyInfo hasProperty = typeof(TMessage).GetProperty("Has" + name);
- if (hasProperty == null)
- {
- throw new ArgumentException("Has properties not available");
- }
- hasDelegate = ReflectionUtil.CreateDelegateFunc<TMessage, bool>(hasProperty.GetGetMethod());
- } else
- {
- if (fieldDescriptor.ContainingOneof != null)
- {
- PropertyInfo caseProperty = typeof(TMessage).GetProperty(containingOneofName + "Case");
- caseDelegate = ReflectionUtil.CreateUpcastDelegate<TMessage>(caseProperty.GetGetMethod());
- hasDelegate = message => OneofFieldNumber(message).Equals(fieldDescriptor.FieldNumber);
- }
- else
- {
- hasDelegate = message => !GetValue(message).Equals(fieldDescriptor.DefaultValue);
- }
- }
-
- clrType = messageProperty.PropertyType;
- clearDelegate = ReflectionUtil.CreateDelegateFunc<TBuilder, IBuilder>(clearMethod);
- getValueDelegate = ReflectionUtil.CreateUpcastDelegate<TMessage>(messageProperty.GetGetMethod());
- setValueDelegate = ReflectionUtil.CreateDowncastDelegate<TBuilder>(builderProperty.GetSetMethod());
- }
-
- private int OneofFieldNumber(TMessage message)
- {
- return (int) caseDelegate(message);
- }
-
- public bool Has(TMessage message)
- {
- return hasDelegate(message);
- }
-
- public void Clear(TBuilder builder)
- {
- clearDelegate(builder);
- }
-
- /// <summary>
- /// Only valid for message types - this implementation throws InvalidOperationException.
- /// </summary>
- public virtual IBuilder CreateBuilder()
- {
- throw new InvalidOperationException();
- }
-
- public virtual object GetValue(TMessage message)
- {
- return getValueDelegate(message);
- }
-
- public virtual void SetValue(TBuilder builder, object value)
- {
- setValueDelegate(builder, value);
- }
-
- #region Methods only related to repeated values
-
- public int GetRepeatedCount(TMessage message)
- {
- throw new InvalidOperationException();
- }
-
- public object GetRepeatedValue(TMessage message, int index)
- {
- throw new InvalidOperationException();
- }
-
- public void SetRepeated(TBuilder builder, int index, object value)
- {
- throw new InvalidOperationException();
- }
-
- public void AddRepeated(TBuilder builder, object value)
- {
- throw new InvalidOperationException();
- }
-
- public object GetRepeatedWrapper(TBuilder builder)
- {
- throw new InvalidOperationException();
- }
-
- #endregion
- }
-}
diff --git a/csharp/src/ProtocolBuffers/FieldSet.cs b/csharp/src/ProtocolBuffers/FieldSet.cs deleted file mode 100644 index 4177400f..00000000 --- a/csharp/src/ProtocolBuffers/FieldSet.cs +++ /dev/null @@ -1,632 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using Google.ProtocolBuffers.Collections;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- public interface IFieldDescriptorLite : IComparable<IFieldDescriptorLite>
- {
- bool IsRepeated { get; }
- bool IsRequired { get; }
- bool IsPacked { get; }
- bool IsExtension { get; }
- bool MessageSetWireFormat { get; } //field.ContainingType.Options.MessageSetWireFormat
- int FieldNumber { get; }
- string Name { get; }
- string FullName { get; }
- IEnumLiteMap EnumType { get; }
- FieldType FieldType { get; }
- MappedType MappedType { get; }
- object DefaultValue { get; }
- }
-
- /// <summary>
- /// A class which represents an arbitrary set of fields of some message type.
- /// This is used to implement DynamicMessage, and also to represent extensions
- /// in GeneratedMessage. This class is internal, since outside users should probably
- /// be using DynamicMessage.
- ///
- /// As in the Java implementation, this class goes against the rest of the framework
- /// in terms of mutability. Instead of having a mutable Builder class and an immutable
- /// FieldSet class, FieldSet just has a MakeImmutable() method. This is safe so long as
- /// all callers are careful not to let a mutable FieldSet escape into the open. This would
- /// be impossible to guarantee if this were a public class, of course.
- ///
- /// All repeated fields are stored as IList[object] even
- /// TODO(jonskeet): Finish this comment!
- /// </summary>
- internal sealed class FieldSet
- {
- private static readonly FieldSet defaultInstance =
- new FieldSet(new Dictionary<IFieldDescriptorLite, object>()).MakeImmutable();
-
- private IDictionary<IFieldDescriptorLite, object> fields;
-
- private FieldSet(IDictionary<IFieldDescriptorLite, object> fields)
- {
- this.fields = fields;
- }
-
- public static FieldSet CreateInstance()
- {
- // Use SortedList to keep fields in the canonical order
- return new FieldSet(new SortedDictionary<IFieldDescriptorLite, object>());
- }
-
- /// <summary>
- /// Makes this FieldSet immutable, and returns it for convenience. Any
- /// mutable repeated fields are made immutable, as well as the map itself.
- /// </summary>
- internal FieldSet MakeImmutable()
- {
- // First check if we have any repeated values
- bool hasRepeats = false;
- foreach (object value in fields.Values)
- {
- IList<object> list = value as IList<object>;
- if (list != null && !list.IsReadOnly)
- {
- hasRepeats = true;
- break;
- }
- }
-
- if (hasRepeats)
- {
- var tmp = new SortedDictionary<IFieldDescriptorLite, object>();
- foreach (KeyValuePair<IFieldDescriptorLite, object> entry in fields)
- {
- IList<object> list = entry.Value as IList<object>;
- tmp[entry.Key] = list == null ? entry.Value : Lists.AsReadOnly(list);
- }
- fields = tmp;
- }
-
- fields = Dictionaries.AsReadOnly(fields);
-
- return this;
- }
-
- /// <summary>
- /// Returns the default, immutable instance with no fields defined.
- /// </summary>
- internal static FieldSet DefaultInstance
- {
- get { return defaultInstance; }
- }
-
- /// <summary>
- /// Returns an immutable mapping of fields. Note that although the mapping itself
- /// is immutable, the entries may not be (i.e. any repeated values are represented by
- /// mutable lists). The behaviour is not specified if the contents are mutated.
- /// </summary>
- internal IDictionary<IFieldDescriptorLite, object> AllFields
- {
- get { return Dictionaries.AsReadOnly(fields); }
- }
-
-#if !LITE
- /// <summary>
- /// Force coercion to full descriptor dictionary.
- /// </summary>
- internal IDictionary<FieldDescriptor, object> AllFieldDescriptors
- {
- get
- {
- SortedDictionary<FieldDescriptor, object> copy =
- new SortedDictionary<FieldDescriptor, object>();
- foreach (KeyValuePair<IFieldDescriptorLite, object> fd in fields)
- {
- copy.Add((FieldDescriptor) fd.Key, fd.Value);
- }
- return Dictionaries.AsReadOnly(copy);
- }
- }
-#endif
-
- /// <summary>
- /// See <see cref="IMessageLite.HasField"/>.
- /// </summary>
- public bool HasField(IFieldDescriptorLite field)
- {
- if (field.IsRepeated)
- {
- throw new ArgumentException("HasField() can only be called on non-repeated fields.");
- }
-
- return fields.ContainsKey(field);
- }
-
- /// <summary>
- /// Clears all fields.
- /// </summary>
- internal void Clear()
- {
- fields.Clear();
- }
-
- /// <summary>
- /// See <see cref="IMessageLite.Item(IFieldDescriptorLite)"/>
- /// </summary>
- /// <remarks>
- /// If the field is not set, the behaviour when fetching this property varies by field type:
- /// <list>
- /// <item>For singular message values, null is returned.</item>
- /// <item>For singular non-message values, the default value of the field is returned.</item>
- /// <item>For repeated values, an empty immutable list is returned. This will be compatible
- /// with IList[object], regardless of the type of the repeated item.</item>
- /// </list>
- /// This method returns null if the field is a singular message type
- /// and is not set; in this case it is up to the caller to fetch the
- /// message's default instance. For repeated fields of message types,
- /// an empty collection is returned. For repeated fields of non-message
- /// types, null is returned.
- /// <para />
- /// When setting this property, any list values are copied, and each element is checked
- /// to ensure it is of an appropriate type.
- /// </remarks>
- ///
- internal object this[IFieldDescriptorLite field]
- {
- get
- {
- object result;
- if (fields.TryGetValue(field, out result))
- {
- return result;
- }
- if (field.MappedType == MappedType.Message)
- {
- if (field.IsRepeated)
- {
- return new List<object>();
- }
- else
- {
- return null;
- }
- }
- return field.DefaultValue;
- }
- set
- {
- if (field.IsRepeated)
- {
- List<object> list = value as List<object>;
- if (list == null)
- {
- throw new ArgumentException("Wrong object type used with protocol message reflection.");
- }
-
- // Wrap the contents in a new list so that the caller cannot change
- // the list's contents after setting it.
- List<object> newList = new List<object>(list);
- foreach (object element in newList)
- {
- VerifyType(field, element);
- }
- value = newList;
- }
- else
- {
- VerifyType(field, value);
- }
- fields[field] = value;
- }
- }
-
- /// <summary>
- /// See <see cref="IMessageLite.Item(IFieldDescriptorLite,int)" />
- /// </summary>
- internal object this[IFieldDescriptorLite field, int index]
- {
- get
- {
- if (!field.IsRepeated)
- {
- throw new ArgumentException(
- "Indexer specifying field and index can only be called on repeated fields.");
- }
-
- return ((IList<object>) this[field])[index];
- }
- set
- {
- if (!field.IsRepeated)
- {
- throw new ArgumentException(
- "Indexer specifying field and index can only be called on repeated fields.");
- }
- VerifyType(field, value);
- object list;
- if (!fields.TryGetValue(field, out list))
- {
- throw new ArgumentOutOfRangeException();
- }
- ((IList<object>) list)[index] = value;
- }
- }
-
- /// <summary>
- /// See <see cref="IBuilder{TMessage, TBuilder}.AddRepeatedField" />
- /// </summary>
- internal void AddRepeatedField(IFieldDescriptorLite field, object value)
- {
- if (!field.IsRepeated)
- {
- throw new ArgumentException("AddRepeatedField can only be called on repeated fields.");
- }
- VerifyType(field, value);
- object list;
- if (!fields.TryGetValue(field, out list))
- {
- list = new List<object>();
- fields[field] = list;
- }
- ((IList<object>) list).Add(value);
- }
-
- /// <summary>
- /// Returns an enumerator for the field map. Used to write the fields out.
- /// </summary>
- internal IEnumerator<KeyValuePair<IFieldDescriptorLite, object>> GetEnumerator()
- {
- return fields.GetEnumerator();
- }
-
- /// <summary>
- /// See <see cref="IMessageLite.IsInitialized" />
- /// </summary>
- /// <remarks>
- /// Since FieldSet itself does not have any way of knowing about
- /// required fields that aren't actually present in the set, it is up
- /// to the caller to check for genuinely required fields. This property
- /// merely checks that any messages present are themselves initialized.
- /// </remarks>
- internal bool IsInitialized
- {
- get
- {
- foreach (KeyValuePair<IFieldDescriptorLite, object> entry in fields)
- {
- IFieldDescriptorLite field = entry.Key;
- if (field.MappedType == MappedType.Message)
- {
- if (field.IsRepeated)
- {
- foreach (IMessageLite message in (IEnumerable) entry.Value)
- {
- if (!message.IsInitialized)
- {
- return false;
- }
- }
- }
- else
- {
- if (!((IMessageLite) entry.Value).IsInitialized)
- {
- return false;
- }
- }
- }
- }
- return true;
- }
- }
-
- /// <summary>
- /// Verifies whether all the required fields in the specified message
- /// descriptor are present in this field set, as well as whether
- /// all the embedded messages are themselves initialized.
- /// </summary>
- internal bool IsInitializedWithRespectTo(IEnumerable typeFields)
- {
- foreach (IFieldDescriptorLite field in typeFields)
- {
- if (field.IsRequired && !HasField(field))
- {
- return false;
- }
- }
- return IsInitialized;
- }
-
- /// <summary>
- /// See <see cref="IBuilder{TMessage, TBuilder}.ClearField" />
- /// </summary>
- public void ClearField(IFieldDescriptorLite field)
- {
- fields.Remove(field);
- }
-
- /// <summary>
- /// See <see cref="IMessageLite.GetRepeatedFieldCount" />
- /// </summary>
- public int GetRepeatedFieldCount(IFieldDescriptorLite field)
- {
- if (!field.IsRepeated)
- {
- throw new ArgumentException("GetRepeatedFieldCount() can only be called on repeated fields.");
- }
-
- return ((IList<object>) this[field]).Count;
- }
-
-#if !LITE
- /// <summary>
- /// See <see cref="IBuilder{TMessage, TBuilder}.MergeFrom(IMessageLite)" />
- /// </summary>
- public void MergeFrom(IMessage other)
- {
- foreach (KeyValuePair<FieldDescriptor, object> fd in other.AllFields)
- {
- MergeField(fd.Key, fd.Value);
- }
- }
-#endif
-
- /// <summary>
- /// Implementation of both <c>MergeFrom</c> methods.
- /// </summary>
- /// <param name="otherFields"></param>
- public void MergeFrom(FieldSet other)
- {
- // Note: We don't attempt to verify that other's fields have valid
- // types. Doing so would be a losing battle. We'd have to verify
- // all sub-messages as well, and we'd have to make copies of all of
- // them to insure that they don't change after verification (since
- // the IMessageLite interface itself cannot enforce immutability of
- // implementations).
- // TODO(jonskeet): Provide a function somewhere called MakeDeepCopy()
- // which allows people to make secure deep copies of messages.
-
- foreach (KeyValuePair<IFieldDescriptorLite, object> entry in other.fields)
- {
- MergeField(entry.Key, entry.Value);
- }
- }
-
- private void MergeField(IFieldDescriptorLite field, object mergeValue)
- {
- object existingValue;
- fields.TryGetValue(field, out existingValue);
- if (field.IsRepeated)
- {
- if (existingValue == null)
- {
- existingValue = new List<object>();
- fields[field] = existingValue;
- }
- IList<object> list = (IList<object>) existingValue;
- foreach (object otherValue in (IEnumerable) mergeValue)
- {
- list.Add(otherValue);
- }
- }
- else if (field.MappedType == MappedType.Message && existingValue != null)
- {
- IMessageLite existingMessage = (IMessageLite) existingValue;
- IMessageLite merged = existingMessage.WeakToBuilder()
- .WeakMergeFrom((IMessageLite) mergeValue)
- .WeakBuild();
- this[field] = merged;
- }
- else
- {
- this[field] = mergeValue;
- }
- }
-
- /// <summary>
- /// See <see cref="IMessageLite.WriteTo(CodedOutputStream)" />.
- /// </summary>
- public void WriteTo(ICodedOutputStream output)
- {
- foreach (KeyValuePair<IFieldDescriptorLite, object> entry in fields)
- {
- WriteField(entry.Key, entry.Value, output);
- }
- }
-
- /// <summary>
- /// Writes a single field to a CodedOutputStream.
- /// </summary>
- public void WriteField(IFieldDescriptorLite field, Object value, ICodedOutputStream output)
- {
- if (field.IsExtension && field.MessageSetWireFormat)
- {
- output.WriteMessageSetExtension(field.FieldNumber, field.Name, (IMessageLite) value);
- }
- else
- {
- if (field.IsRepeated)
- {
- IEnumerable valueList = (IEnumerable) value;
- if (field.IsPacked)
- {
- output.WritePackedArray(field.FieldType, field.FieldNumber, field.Name, valueList);
- }
- else
- {
- output.WriteArray(field.FieldType, field.FieldNumber, field.Name, valueList);
- }
- }
- else
- {
- output.WriteField(field.FieldType, field.FieldNumber, field.Name, value);
- }
- }
- }
-
- /// <summary>
- /// See <see cref="IMessageLite.SerializedSize" />. It's up to the caller to
- /// cache the resulting size if desired.
- /// </summary>
- public int SerializedSize
- {
- get
- {
- int size = 0;
- foreach (KeyValuePair<IFieldDescriptorLite, object> entry in fields)
- {
- IFieldDescriptorLite field = entry.Key;
- object value = entry.Value;
-
- if (field.IsExtension && field.MessageSetWireFormat)
- {
- size += CodedOutputStream.ComputeMessageSetExtensionSize(field.FieldNumber, (IMessageLite) value);
- }
- else
- {
- if (field.IsRepeated)
- {
- IEnumerable valueList = (IEnumerable) value;
- if (field.IsPacked)
- {
- int dataSize = 0;
- foreach (object element in valueList)
- {
- dataSize += CodedOutputStream.ComputeFieldSizeNoTag(field.FieldType, element);
- }
- size += dataSize + CodedOutputStream.ComputeTagSize(field.FieldNumber) +
- CodedOutputStream.ComputeRawVarint32Size((uint) dataSize);
- }
- else
- {
- foreach (object element in valueList)
- {
- size += CodedOutputStream.ComputeFieldSize(field.FieldType, field.FieldNumber,
- element);
- }
- }
- }
- else
- {
- size += CodedOutputStream.ComputeFieldSize(field.FieldType, field.FieldNumber, value);
- }
- }
- }
- return size;
- }
- }
-
- /// <summary>
- /// Verifies that the given object is of the correct type to be a valid
- /// value for the given field.
- /// </summary>
- /// <remarks>
- /// For repeated fields, this checks if the object is of the right
- /// element type, not whether it's a list.
- /// </remarks>
- /// <exception cref="ArgumentException">The value is not of the right type.</exception>
- /// <exception cref="ArgumentNullException">The value is null.</exception>
- private static void VerifyType(IFieldDescriptorLite field, object value)
- {
- ThrowHelper.ThrowIfNull(value, "value");
- bool isValid = false;
- switch (field.MappedType)
- {
- case MappedType.Int32:
- isValid = value is int;
- break;
- case MappedType.Int64:
- isValid = value is long;
- break;
- case MappedType.UInt32:
- isValid = value is uint;
- break;
- case MappedType.UInt64:
- isValid = value is ulong;
- break;
- case MappedType.Single:
- isValid = value is float;
- break;
- case MappedType.Double:
- isValid = value is double;
- break;
- case MappedType.Boolean:
- isValid = value is bool;
- break;
- case MappedType.String:
- isValid = value is string;
- break;
- case MappedType.ByteString:
- isValid = value is ByteString;
- break;
- case MappedType.Enum:
- IEnumLite enumValue = value as IEnumLite;
- isValid = enumValue != null && field.EnumType.IsValidValue(enumValue);
- break;
- case MappedType.Message:
- IMessageLite messageValue = value as IMessageLite;
- isValid = messageValue != null;
-#if !LITE
- if (isValid && messageValue is IMessage && field is FieldDescriptor)
- {
- isValid = ((IMessage) messageValue).DescriptorForType == ((FieldDescriptor) field).MessageType;
- }
-#endif
- break;
- }
-
- if (!isValid)
- {
- // When chaining calls to SetField(), it can be hard to tell from
- // the stack trace which exact call failed, since the whole chain is
- // considered one line of code. So, let's make sure to include the
- // field name and other useful info in the exception.
- string message = "Wrong object type used with protocol message reflection.";
-#if !LITE
- FieldDescriptor fieldinfo =
- field as FieldDescriptor;
- if (fieldinfo != null)
- {
- message += "Message type \"" + fieldinfo.ContainingType.FullName;
- message += "\", field \"" + (fieldinfo.IsExtension ? fieldinfo.FullName : fieldinfo.Name);
- message += "\", value was type \"" + value.GetType().Name + "\".";
- }
-#endif
- throw new ArgumentException(message);
- }
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FrameworkPortability.cs b/csharp/src/ProtocolBuffers/FrameworkPortability.cs index 8ce81987..06246a9e 100644 --- a/csharp/src/ProtocolBuffers/FrameworkPortability.cs +++ b/csharp/src/ProtocolBuffers/FrameworkPortability.cs @@ -35,77 +35,19 @@ #endregion
using System;
-using System.Globalization;
-using System.Reflection;
using System.Text.RegularExpressions;
-namespace Google.ProtocolBuffers
+namespace Google.Protobuf
{
/// <summary>
/// Class containing helpful workarounds for various platform compatibility
/// </summary>
internal static class FrameworkPortability
{
-#if COMPACT_FRAMEWORK
- internal const string NewLine = "\n";
-#else
- internal static readonly string NewLine = System.Environment.NewLine;
-#endif
-
-#if CLIENTPROFILE
- internal const RegexOptions CompiledRegexWhereAvailable = RegexOptions.Compiled;
-#else
- internal const RegexOptions CompiledRegexWhereAvailable = RegexOptions.None;
-#endif
-
- internal static CultureInfo InvariantCulture
- {
- get { return CultureInfo.InvariantCulture; }
- }
-
- internal static double Int64ToDouble(long value)
- {
-#if CLIENTPROFILE
- return BitConverter.Int64BitsToDouble(value);
-#else
- double[] arresult = new double[1];
- Buffer.BlockCopy(new[] { value }, 0, arresult, 0, 8);
- return arresult[0];
-#endif
- }
-
- internal static long DoubleToInt64(double value)
- {
-#if CLIENTPROFILE
- return BitConverter.DoubleToInt64Bits(value);
-#else
- long[] arresult = new long[1];
- Buffer.BlockCopy(new[] { value }, 0, arresult, 0, 8);
- return arresult[0];
-#endif
- }
-
- internal static bool TryParseInt32(string text, out int number)
- {
- return TryParseInt32(text, NumberStyles.Any, InvariantCulture, out number);
- }
-
- internal static bool TryParseInt32(string text, NumberStyles style, IFormatProvider format, out int number)
- {
-#if COMPACT_FRAMEWORK
- try
- {
- number = int.Parse(text, style, format);
- return true;
- }
- catch
- {
- number = 0;
- return false;
- }
-#else
- return int.TryParse(text, style, format, out number);
-#endif
- }
+ // The value of RegexOptions.Compiled is 8. We can test for the presence at
+ // execution time using Enum.IsDefined, so a single build will do the right thing
+ // on each platform.
+ internal static readonly RegexOptions CompiledRegexWhereAvailable =
+ Enum.IsDefined(typeof(RegexOptions), 8) ? (RegexOptions)8 : RegexOptions.None;
}
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/GeneratedBuilder.cs b/csharp/src/ProtocolBuffers/GeneratedBuilder.cs deleted file mode 100644 index 0f121ae8..00000000 --- a/csharp/src/ProtocolBuffers/GeneratedBuilder.cs +++ /dev/null @@ -1,230 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using Google.ProtocolBuffers.Descriptors;
-using Google.ProtocolBuffers.FieldAccess;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// All generated protocol message builder classes extend this class. It implements
- /// most of the IBuilder interface using reflection. Users can ignore this class
- /// as an implementation detail.
- /// </summary>
- public abstract partial class GeneratedBuilder<TMessage, TBuilder> : AbstractBuilder<TMessage, TBuilder>
- where TMessage : GeneratedMessage<TMessage, TBuilder>
- where TBuilder : GeneratedBuilder<TMessage, TBuilder>, new()
- {
- /// <summary>
- /// Returns the message being built at the moment.
- /// </summary>
- protected abstract TMessage MessageBeingBuilt { get; }
-
- protected internal FieldAccessorTable<TMessage, TBuilder> InternalFieldAccessors
- {
- get { return DefaultInstanceForType.FieldAccessorsFromBuilder; }
- }
-
- public override IDictionary<FieldDescriptor, object> AllFields
- {
- get { return MessageBeingBuilt.AllFields; }
- }
-
- public override object this[FieldDescriptor field]
- {
- get
- {
- // For repeated fields, the underlying list object is still modifiable at this point.
- // Make sure not to expose the modifiable list to the caller.
- return field.IsRepeated
- ? InternalFieldAccessors[field].GetRepeatedWrapper(ThisBuilder)
- : MessageBeingBuilt[field];
- }
- set { InternalFieldAccessors[field].SetValue(ThisBuilder, value); }
- }
-
- /// <summary>
- /// Called by derived classes to parse an unknown field.
- /// </summary>
- /// <returns>true unless the tag is an end-group tag</returns>
- protected virtual bool ParseUnknownField(ICodedInputStream input, UnknownFieldSet.Builder unknownFields,
- ExtensionRegistry extensionRegistry, uint tag, string fieldName)
- {
- return unknownFields.MergeFieldFrom(tag, input);
- }
-
- public override MessageDescriptor DescriptorForType
- {
- get { return DefaultInstanceForType.DescriptorForType; }
- }
-
- public override int GetRepeatedFieldCount(FieldDescriptor field)
- {
- return MessageBeingBuilt.GetRepeatedFieldCount(field);
- }
-
- public override object this[FieldDescriptor field, int index]
- {
- get { return MessageBeingBuilt[field, index]; }
- set { InternalFieldAccessors[field].SetRepeated(ThisBuilder, index, value); }
- }
-
- public override bool HasOneof(OneofDescriptor oneof)
- {
- return MessageBeingBuilt.HasOneof(oneof);
- }
-
- public override FieldDescriptor OneofFieldDescriptor(OneofDescriptor oneof)
- {
- return MessageBeingBuilt.OneofFieldDescriptor(oneof);
- }
-
- public override bool HasField(FieldDescriptor field)
- {
- return MessageBeingBuilt.HasField(field);
- }
-
- public override IBuilder CreateBuilderForField(FieldDescriptor field)
- {
- return InternalFieldAccessors[field].CreateBuilder();
- }
-
- public override TBuilder ClearField(FieldDescriptor field)
- {
- InternalFieldAccessors[field].Clear(ThisBuilder);
- return ThisBuilder;
- }
-
- public override TBuilder ClearOneof(OneofDescriptor oneof)
- {
- InternalFieldAccessors.Oneof(oneof).Clear(ThisBuilder);
- return ThisBuilder;
- }
-
- public override TBuilder MergeFrom(TMessage other)
- {
- if (other.DescriptorForType != InternalFieldAccessors.Descriptor)
- {
- throw new ArgumentException("Message type mismatch");
- }
-
- foreach (KeyValuePair<FieldDescriptor, object> entry in other.AllFields)
- {
- FieldDescriptor field = entry.Key;
- if (field.IsRepeated)
- {
- // Concatenate repeated fields
- foreach (object element in (IEnumerable) entry.Value)
- {
- AddRepeatedField(field, element);
- }
- }
- else if (field.MappedType == MappedType.Message && HasField(field))
- {
- // Merge singular embedded messages
- IMessageLite oldValue = (IMessageLite) this[field];
- this[field] = oldValue.WeakCreateBuilderForType()
- .WeakMergeFrom(oldValue)
- .WeakMergeFrom((IMessageLite) entry.Value)
- .WeakBuildPartial();
- }
- else
- {
- // Just overwrite
- this[field] = entry.Value;
- }
- }
-
- //Fix for unknown fields not merging, see java's AbstractMessage.Builder<T> line 236
- MergeUnknownFields(other.UnknownFields);
-
- return ThisBuilder;
- }
-
- public override TBuilder MergeUnknownFields(UnknownFieldSet unknownFields)
- {
- if (unknownFields != UnknownFieldSet.DefaultInstance)
- {
- TMessage result = MessageBeingBuilt;
- result.SetUnknownFields(UnknownFieldSet.CreateBuilder(result.UnknownFields)
- .MergeFrom(unknownFields)
- .Build());
- }
- return ThisBuilder;
- }
-
- public override TBuilder AddRepeatedField(FieldDescriptor field, object value)
- {
- InternalFieldAccessors[field].AddRepeated(ThisBuilder, value);
- return ThisBuilder;
- }
-
- /// <summary>
- /// Like Build(), but will wrap UninitializedMessageException in
- /// InvalidProtocolBufferException.
- /// </summary>
- public TMessage BuildParsed()
- {
- if (!IsInitialized)
- {
- throw new UninitializedMessageException(MessageBeingBuilt).AsInvalidProtocolBufferException();
- }
- return BuildPartial();
- }
-
- /// <summary>
- /// Implementation of <see cref="IBuilder{TMessage, TBuilder}.Build" />.
- /// </summary>
- public override TMessage Build()
- {
- // If the message is null, we'll throw a more appropriate exception in BuildPartial.
- if (!IsInitialized)
- {
- throw new UninitializedMessageException(MessageBeingBuilt);
- }
- return BuildPartial();
- }
-
- public override UnknownFieldSet UnknownFields
- {
- get { return MessageBeingBuilt.UnknownFields; }
- set { MessageBeingBuilt.SetUnknownFields(value); }
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/GeneratedBuilderLite.cs b/csharp/src/ProtocolBuffers/GeneratedBuilderLite.cs deleted file mode 100644 index 5783c987..00000000 --- a/csharp/src/ProtocolBuffers/GeneratedBuilderLite.cs +++ /dev/null @@ -1,100 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// All generated protocol message builder classes extend this class. It implements
- /// most of the IBuilder interface using reflection. Users can ignore this class
- /// as an implementation detail.
- /// </summary>
- public abstract partial class GeneratedBuilderLite<TMessage, TBuilder> : AbstractBuilderLite<TMessage, TBuilder>
- where TMessage : GeneratedMessageLite<TMessage, TBuilder>
- where TBuilder : GeneratedBuilderLite<TMessage, TBuilder>
- {
- /// <summary>
- /// Returns the message being built at the moment.
- /// </summary>
- protected abstract TMessage MessageBeingBuilt { get; }
-
- public override TBuilder MergeFrom(IMessageLite other)
- {
- //do nothing, Lite runtime does not support cross-message merges
- return ThisBuilder;
- }
-
- public abstract TBuilder MergeFrom(TMessage other);
-
- /// <summary>
- /// Called by derived classes to parse an unknown field.
- /// </summary>
- /// <returns>true unless the tag is an end-group tag</returns>
- protected virtual bool ParseUnknownField(ICodedInputStream input,
- ExtensionRegistry extensionRegistry, uint tag, string fieldName)
- {
- return input.SkipField();
- }
-
- /// <summary>
- /// Like Build(), but will wrap UninitializedMessageException in
- /// InvalidProtocolBufferException.
- /// </summary>
- public TMessage BuildParsed()
- {
- if (!IsInitialized)
- {
- throw new UninitializedMessageException(MessageBeingBuilt).AsInvalidProtocolBufferException();
- }
- return BuildPartial();
- }
-
- /// <summary>
- /// Implementation of <see cref="IBuilder{TMessage, TBuilder}.Build" />.
- /// </summary>
- public override TMessage Build()
- {
- // If the message is null, we'll throw a more appropriate exception in BuildPartial.
- if (!IsInitialized)
- {
- throw new UninitializedMessageException(MessageBeingBuilt);
- }
- return BuildPartial();
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/GeneratedExtensionBase.cs b/csharp/src/ProtocolBuffers/GeneratedExtensionBase.cs deleted file mode 100644 index 424b981a..00000000 --- a/csharp/src/ProtocolBuffers/GeneratedExtensionBase.cs +++ /dev/null @@ -1,185 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Reflection;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Base type for all generated extensions.
- /// </summary>
- /// <remarks>
- /// The protocol compiler generates a static singleton instance of this
- /// class for each extension. For exmaple, imagine a .proto file with:
- /// <code>
- /// message Foo {
- /// extensions 1000 to max
- /// }
- ///
- /// extend Foo {
- /// optional int32 bar;
- /// }
- /// </code>
- /// Then MyProto.Foo.Bar has type GeneratedExtensionBase<MyProto.Foo,int>.
- /// <para />
- /// In general, users should ignore the details of this type, and
- /// simply use the static singletons as parameters to the extension accessors
- /// in ExtendableMessage and ExtendableBuilder.
- /// The interface implemented by both GeneratedException and GeneratedRepeatException,
- /// to make it easier to cope with repeats separately.
- /// </remarks>
- public abstract class GeneratedExtensionBase<TExtension>
- {
- private readonly FieldDescriptor descriptor;
- private readonly IMessageLite messageDefaultInstance;
-
- protected GeneratedExtensionBase(FieldDescriptor descriptor, Type singularExtensionType)
- {
- if (!descriptor.IsExtension)
- {
- throw new ArgumentException("GeneratedExtension given a regular (non-extension) field.");
- }
-
- this.descriptor = descriptor;
- if (descriptor.MappedType == MappedType.Message)
- {
- PropertyInfo defaultInstanceProperty = singularExtensionType
- .GetProperty("DefaultInstance", BindingFlags.Static | BindingFlags.Public);
- if (defaultInstanceProperty == null)
- {
- throw new ArgumentException("No public static DefaultInstance property for type " +
- typeof(TExtension).Name);
- }
-
- messageDefaultInstance = (IMessageLite) defaultInstanceProperty.GetValue(null, null);
- }
- }
-
- public FieldDescriptor Descriptor
- {
- get { return descriptor; }
- }
-
- public int Number
- {
- get { return Descriptor.FieldNumber; }
- }
-
- /// <summary>
- /// Returns the default message instance for extensions which are message types.
- /// </summary>
- public IMessageLite MessageDefaultInstance
- {
- get { return messageDefaultInstance; }
- }
-
- public object SingularFromReflectionType(object value)
- {
- switch (Descriptor.MappedType)
- {
- case MappedType.Message:
- if (value is TExtension)
- {
- return value;
- }
- else
- {
- // It seems the copy of the embedded message stored inside the
- // extended message is not of the exact type the user was
- // expecting. This can happen if a user defines a
- // GeneratedExtension manually and gives it a different type.
- // This should not happen in normal use. But, to be nice, we'll
- // copy the message to whatever type the caller was expecting.
- return MessageDefaultInstance.WeakCreateBuilderForType()
- .WeakMergeFrom((IMessageLite) value).WeakBuild();
- }
- case MappedType.Enum:
- // Just return a boxed int - that can be unboxed to the enum
- EnumValueDescriptor enumValue = (EnumValueDescriptor) value;
- return enumValue.Number;
- default:
- return value;
- }
- }
-
- /// <summary>
- /// Converts from the type used by the native accessors to the type
- /// used by reflection accessors. For example, the reflection accessors
- /// for enums use EnumValueDescriptors but the native accessors use
- /// the generated enum type.
- /// </summary>
- public object ToReflectionType(object value)
- {
- if (descriptor.IsRepeated)
- {
- if (descriptor.MappedType == MappedType.Enum)
- {
- // Must convert the whole list.
- IList<object> result = new List<object>();
- foreach (object element in (IEnumerable) value)
- {
- result.Add(SingularToReflectionType(element));
- }
- return result;
- }
- else
- {
- return value;
- }
- }
- else
- {
- return SingularToReflectionType(value);
- }
- }
-
- /// <summary>
- /// Like ToReflectionType(object) but for a single element.
- /// </summary>
- internal Object SingularToReflectionType(object value)
- {
- return descriptor.MappedType == MappedType.Enum
- ? descriptor.EnumType.FindValueByNumber((int) value)
- : value;
- }
-
- public abstract object FromReflectionType(object value);
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/GeneratedExtensionLite.cs b/csharp/src/ProtocolBuffers/GeneratedExtensionLite.cs deleted file mode 100644 index a1623348..00000000 --- a/csharp/src/ProtocolBuffers/GeneratedExtensionLite.cs +++ /dev/null @@ -1,354 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System.Collections;
-using System.Collections.Generic;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- public interface IGeneratedExtensionLite
- {
- int Number { get; }
- object ContainingType { get; }
- IMessageLite MessageDefaultInstance { get; }
- IFieldDescriptorLite Descriptor { get; }
- }
-
- public class ExtensionDescriptorLite : IFieldDescriptorLite
- {
- private readonly string fullName;
- private readonly IEnumLiteMap enumTypeMap;
- private readonly int number;
- private readonly FieldType type;
- private readonly bool isRepeated;
- private readonly bool isPacked;
- private readonly MappedType mapType;
- private readonly object defaultValue;
-
- public ExtensionDescriptorLite(string fullName, IEnumLiteMap enumTypeMap, int number, FieldType type,
- object defaultValue, bool isRepeated, bool isPacked)
- {
- this.fullName = fullName;
- this.enumTypeMap = enumTypeMap;
- this.number = number;
- this.type = type;
- this.mapType = FieldMappingAttribute.MappedTypeFromFieldType(type);
- this.isRepeated = isRepeated;
- this.isPacked = isPacked;
- this.defaultValue = defaultValue;
- }
-
- public string Name
- {
- get
- {
- string name = fullName;
- int offset = name.LastIndexOf('.');
- if (offset >= 0)
- {
- name = name.Substring(offset);
- }
- return name;
- }
- }
-
- public string FullName
- {
- get { return fullName; }
- }
-
- public bool IsRepeated
- {
- get { return isRepeated; }
- }
-
- public bool IsRequired
- {
- get { return false; }
- }
-
- public bool IsPacked
- {
- get { return isPacked; }
- }
-
- public bool IsExtension
- {
- get { return true; }
- }
-
- /// <summary>
- /// This is not supported and assertions are made to ensure this does not exist on extensions of Lite types
- /// </summary>
- public bool MessageSetWireFormat
- {
- get { return false; }
- }
-
- public int FieldNumber
- {
- get { return number; }
- }
-
- public IEnumLiteMap EnumType
- {
- get { return enumTypeMap; }
- }
-
- public FieldType FieldType
- {
- get { return type; }
- }
-
- public MappedType MappedType
- {
- get { return mapType; }
- }
-
- public object DefaultValue
- {
- get { return defaultValue; }
- }
-
- public int CompareTo(IFieldDescriptorLite other)
- {
- return FieldNumber.CompareTo(other.FieldNumber);
- }
- }
-
- public class GeneratedRepeatExtensionLite<TContainingType, TExtensionType> :
- GeneratedExtensionLite<TContainingType, IList<TExtensionType>>
- where TContainingType : IMessageLite
- {
- public GeneratedRepeatExtensionLite(string fullName, TContainingType containingTypeDefaultInstance,
- IMessageLite messageDefaultInstance, IEnumLiteMap enumTypeMap, int number,
- FieldType type, bool isPacked) :
- base(
- fullName, containingTypeDefaultInstance, new List<TExtensionType>(),
- messageDefaultInstance, enumTypeMap, number, type, isPacked)
- {
- }
-
- public override object ToReflectionType(object value)
- {
- IList<object> result = new List<object>();
- foreach (object element in (IEnumerable) value)
- {
- result.Add(SingularToReflectionType(element));
- }
- return result;
- }
-
- public override object FromReflectionType(object value)
- {
- // Must convert the whole list.
- List<TExtensionType> result = new List<TExtensionType>();
- foreach (object element in (IEnumerable) value)
- {
- result.Add((TExtensionType) SingularFromReflectionType(element));
- }
- return result;
- }
- }
-
- public class GeneratedExtensionLite<TContainingType, TExtensionType> : IGeneratedExtensionLite
- where TContainingType : IMessageLite
- {
- private readonly TContainingType containingTypeDefaultInstance;
- private readonly TExtensionType defaultValue;
- private readonly IMessageLite messageDefaultInstance;
- private readonly ExtensionDescriptorLite descriptor;
-
- // We can't always initialize a GeneratedExtension when we first construct
- // it due to initialization order difficulties (namely, the default
- // instances may not have been constructed yet). So, we construct an
- // uninitialized GeneratedExtension once, then call internalInit() on it
- // later. Generated code will always call internalInit() on all extensions
- // as part of the static initialization code, and internalInit() throws an
- // exception if called more than once, so this method is useless to users.
- protected GeneratedExtensionLite(
- TContainingType containingTypeDefaultInstance,
- TExtensionType defaultValue,
- IMessageLite messageDefaultInstance,
- ExtensionDescriptorLite descriptor)
- {
- this.containingTypeDefaultInstance = containingTypeDefaultInstance;
- this.messageDefaultInstance = messageDefaultInstance;
- this.defaultValue = defaultValue;
- this.descriptor = descriptor;
- }
-
- /** For use by generated code only. */
-
- public GeneratedExtensionLite(
- string fullName,
- TContainingType containingTypeDefaultInstance,
- TExtensionType defaultValue,
- IMessageLite messageDefaultInstance,
- IEnumLiteMap enumTypeMap,
- int number,
- FieldType type)
- : this(containingTypeDefaultInstance, defaultValue, messageDefaultInstance,
- new ExtensionDescriptorLite(fullName, enumTypeMap, number, type, defaultValue,
- false /* isRepeated */, false /* isPacked */))
- {
- }
-
- private static readonly IList<object> Empty = new object[0];
- /** Repeating fields: For use by generated code only. */
-
- protected GeneratedExtensionLite(
- string fullName,
- TContainingType containingTypeDefaultInstance,
- TExtensionType defaultValue,
- IMessageLite messageDefaultInstance,
- IEnumLiteMap enumTypeMap,
- int number,
- FieldType type,
- bool isPacked)
- : this(containingTypeDefaultInstance, defaultValue, messageDefaultInstance,
- new ExtensionDescriptorLite(fullName, enumTypeMap, number, type, Empty,
- true /* isRepeated */, isPacked))
- {
- }
-
- /// <summary>
- /// Returns information about this extension
- /// </summary>
- public IFieldDescriptorLite Descriptor
- {
- get { return descriptor; }
- }
-
- /// <summary>
- /// Returns the default value for this extension
- /// </summary>
- public TExtensionType DefaultValue
- {
- get { return defaultValue; }
- }
-
- /// <summary>
- /// used for the extension registry
- /// </summary>
- object IGeneratedExtensionLite.ContainingType
- {
- get { return ContainingTypeDefaultInstance; }
- }
-
- /**
- * Default instance of the type being extended, used to identify that type.
- */
-
- public TContainingType ContainingTypeDefaultInstance
- {
- get { return containingTypeDefaultInstance; }
- }
-
- /** Get the field number. */
-
- public int Number
- {
- get { return descriptor.FieldNumber; }
- }
-
- /**
- * If the extension is an embedded message, this is the default instance of
- * that type.
- */
-
- public IMessageLite MessageDefaultInstance
- {
- get { return messageDefaultInstance; }
- }
-
- /// <summary>
- /// Converts from the type used by the native accessors to the type
- /// used by reflection accessors. For example, the reflection accessors
- /// for enums use EnumValueDescriptors but the native accessors use
- /// the generated enum type.
- /// </summary>
- public virtual object ToReflectionType(object value)
- {
- return SingularToReflectionType(value);
- }
-
- /// <summary>
- /// Like ToReflectionType(object) but for a single element.
- /// </summary>
- public object SingularToReflectionType(object value)
- {
- return descriptor.MappedType == MappedType.Enum
- ? descriptor.EnumType.FindValueByNumber((int) value)
- : value;
- }
-
- public virtual object FromReflectionType(object value)
- {
- return SingularFromReflectionType(value);
- }
-
- public object SingularFromReflectionType(object value)
- {
- switch (Descriptor.MappedType)
- {
- case MappedType.Message:
- if (value is TExtensionType)
- {
- return value;
- }
- else
- {
- // It seems the copy of the embedded message stored inside the
- // extended message is not of the exact type the user was
- // expecting. This can happen if a user defines a
- // GeneratedExtension manually and gives it a different type.
- // This should not happen in normal use. But, to be nice, we'll
- // copy the message to whatever type the caller was expecting.
- return MessageDefaultInstance.WeakCreateBuilderForType()
- .WeakMergeFrom((IMessageLite) value).WeakBuild();
- }
- case MappedType.Enum:
- // Just return a boxed int - that can be unboxed to the enum
- IEnumLite enumValue = (IEnumLite) value;
- return enumValue.Number;
- default:
- return value;
- }
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/GeneratedMessage.cs b/csharp/src/ProtocolBuffers/GeneratedMessage.cs deleted file mode 100644 index ff3a0c2a..00000000 --- a/csharp/src/ProtocolBuffers/GeneratedMessage.cs +++ /dev/null @@ -1,191 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Xml;
-using Google.ProtocolBuffers.Collections;
-using Google.ProtocolBuffers.Descriptors;
-using Google.ProtocolBuffers.FieldAccess;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// All generated protocol message classes extend this class. It implements
- /// most of the IMessage interface using reflection. Users
- /// can ignore this class as an implementation detail.
- /// </summary>
- public abstract partial class GeneratedMessage<TMessage, TBuilder> : AbstractMessage<TMessage, TBuilder>
- where TMessage : GeneratedMessage<TMessage, TBuilder>
- where TBuilder : GeneratedBuilder<TMessage, TBuilder>, new()
- {
- private UnknownFieldSet unknownFields = UnknownFieldSet.DefaultInstance;
-
- /// <summary>
- /// Returns the message as a TMessage.
- /// </summary>
- protected abstract TMessage ThisMessage { get; }
-
- internal FieldAccessorTable<TMessage, TBuilder> FieldAccessorsFromBuilder
- {
- get { return InternalFieldAccessors; }
- }
-
- protected abstract FieldAccessorTable<TMessage, TBuilder> InternalFieldAccessors { get; }
-
- public override MessageDescriptor DescriptorForType
- {
- get { return InternalFieldAccessors.Descriptor; }
- }
-
- internal IDictionary<FieldDescriptor, Object> GetMutableFieldMap()
- {
- // Use a SortedDictionary so we'll end up serializing fields in order
- var ret = new SortedDictionary<FieldDescriptor, object>();
- MessageDescriptor descriptor = DescriptorForType;
- foreach (FieldDescriptor field in descriptor.Fields)
- {
- IFieldAccessor<TMessage, TBuilder> accessor = InternalFieldAccessors[field];
- if (field.IsRepeated)
- {
- if (accessor.GetRepeatedCount(ThisMessage) != 0)
- {
- ret[field] = accessor.GetValue(ThisMessage);
- }
- }
- else if (HasField(field))
- {
- ret[field] = accessor.GetValue(ThisMessage);
- }
- }
- return ret;
- }
-
- public override bool IsInitialized
- {
- get
- {
- foreach (FieldDescriptor field in DescriptorForType.Fields)
- {
- // Check that all required fields are present.
- if (field.IsRequired && !HasField(field))
- {
- return false;
- }
- // Check that embedded messages are initialized.
- // This code is similar to that in AbstractMessage, but we don't
- // fetch all the field values - just the ones we need to.
- if (field.MappedType == MappedType.Message)
- {
- if (field.IsRepeated)
- {
- // We know it's an IList<T>, but not the exact type - so
- // IEnumerable is the best we can do. (C# generics aren't covariant yet.)
- foreach (IMessageLite element in (IEnumerable) this[field])
- {
- if (!element.IsInitialized)
- {
- return false;
- }
- }
- }
- else
- {
- if (HasField(field) && !((IMessageLite) this[field]).IsInitialized)
- {
- return false;
- }
- }
- }
- }
- return true;
- }
- }
-
- public override IDictionary<FieldDescriptor, object> AllFields
- {
- get { return Dictionaries.AsReadOnly(GetMutableFieldMap()); }
- }
-
- public override bool HasOneof(OneofDescriptor oneof)
- {
- return InternalFieldAccessors.Oneof(oneof).Has(ThisMessage);
- }
-
- public override FieldDescriptor OneofFieldDescriptor(OneofDescriptor oneof)
- {
- return InternalFieldAccessors.Oneof(oneof).GetOneofFieldDescriptor(ThisMessage);
- }
-
- public override bool HasField(FieldDescriptor field)
- {
- return InternalFieldAccessors[field].Has(ThisMessage);
- }
-
- public override int GetRepeatedFieldCount(FieldDescriptor field)
- {
- return InternalFieldAccessors[field].GetRepeatedCount(ThisMessage);
- }
-
- public override object this[FieldDescriptor field, int index]
- {
- get { return InternalFieldAccessors[field].GetRepeatedValue(ThisMessage, index); }
- }
-
- public override object this[FieldDescriptor field]
- {
- get { return InternalFieldAccessors[field].GetValue(ThisMessage); }
- }
-
- public override UnknownFieldSet UnknownFields
- {
- get { return unknownFields; }
- }
-
- /// <summary>
- /// Replaces the set of unknown fields for this message. This should
- /// only be used before a message is built, by the builder. (In the
- /// Java code it is private, but the builder is nested so has access
- /// to it.)
- /// </summary>
- internal void SetUnknownFields(UnknownFieldSet fieldSet)
- {
- unknownFields = fieldSet;
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/GeneratedMessageLite.cs b/csharp/src/ProtocolBuffers/GeneratedMessageLite.cs deleted file mode 100644 index 0dfc976b..00000000 --- a/csharp/src/ProtocolBuffers/GeneratedMessageLite.cs +++ /dev/null @@ -1,182 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Text;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// All generated protocol message classes extend this class. It implements
- /// most of the IMessage interface using reflection. Users
- /// can ignore this class as an implementation detail.
- /// </summary>
- public abstract partial class GeneratedMessageLite<TMessage, TBuilder> : AbstractMessageLite<TMessage, TBuilder>
- where TMessage : GeneratedMessageLite<TMessage, TBuilder>
- where TBuilder : GeneratedBuilderLite<TMessage, TBuilder>
- {
- protected abstract TMessage ThisMessage { get; }
-
- public override sealed string ToString()
- {
- using (StringWriter wtr = new StringWriter())
- {
- PrintTo(wtr);
- return wtr.ToString();
- }
- }
-
- /// <summary>
- /// PrintTo() helper methods for Lite Runtime
- /// </summary>
- protected static void PrintField<T>(string name, IList<T> value, TextWriter writer)
- {
- foreach (T item in value)
- {
- PrintField(name, true, (object) item, writer);
- }
- }
-
- /// <summary>
- /// PrintTo() helper methods for Lite Runtime
- /// </summary>
- protected static void PrintField(string name, bool hasValue, object value, TextWriter writer)
- {
- if (!hasValue)
- {
- return;
- }
- if (value is IMessageLite)
- {
- writer.WriteLine("{0} {{", name);
- ((IMessageLite) value).PrintTo(writer);
- writer.WriteLine("}");
- }
- else if (value is ByteString || value is String)
- {
- writer.Write("{0}: \"", name);
- if (value is String)
- {
- EscapeBytes(Encoding.UTF8.GetBytes((string) value), writer);
- }
- else
- {
- EscapeBytes(((ByteString) value), writer);
- }
- writer.WriteLine("\"");
- }
- else if (value is bool)
- {
- writer.WriteLine("{0}: {1}", name, (bool) value ? "true" : "false");
- }
- else if (value is IEnumLite)
- {
- writer.WriteLine("{0}: {1}", name, ((IEnumLite) value).Name);
- }
- else
- {
- writer.WriteLine("{0}: {1}", name, ((IConvertible)value).ToString(FrameworkPortability.InvariantCulture));
- }
- }
-
- /// <summary>
- /// COPIED from TextFormat
- /// Escapes bytes in the format used in protocol buffer text format, which
- /// is the same as the format used for C string literals. All bytes
- /// that are not printable 7-bit ASCII characters are escaped, as well as
- /// backslash, single-quote, and double-quote characters. Characters for
- /// which no defined short-hand escape sequence is defined will be escaped
- /// using 3-digit octal sequences.
- /// The returned value is guaranteed to be entirely ASCII.
- /// </summary>
- private static void EscapeBytes(IEnumerable<byte> input, TextWriter writer)
- {
- foreach (byte b in input)
- {
- switch (b)
- {
- // C# does not use \a or \v
- case 0x07:
- writer.Write("\\a");
- break;
- case (byte) '\b':
- writer.Write("\\b");
- break;
- case (byte) '\f':
- writer.Write("\\f");
- break;
- case (byte) '\n':
- writer.Write("\\n");
- break;
- case (byte) '\r':
- writer.Write("\\r");
- break;
- case (byte) '\t':
- writer.Write("\\t");
- break;
- case 0x0b:
- writer.Write("\\v");
- break;
- case (byte) '\\':
- writer.Write("\\\\");
- break;
- case (byte) '\'':
- writer.Write("\\\'");
- break;
- case (byte) '"':
- writer.Write("\\\"");
- break;
- default:
- if (b >= 0x20 && b < 128)
- {
- writer.Write((char) b);
- }
- else
- {
- writer.Write('\\');
- writer.Write((char) ('0' + ((b >> 6) & 3)));
- writer.Write((char) ('0' + ((b >> 3) & 7)));
- writer.Write((char) ('0' + (b & 7)));
- }
- break;
- }
- }
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/GeneratedRepeatExtension.cs b/csharp/src/ProtocolBuffers/GeneratedRepeatExtension.cs deleted file mode 100644 index 7e7b088c..00000000 --- a/csharp/src/ProtocolBuffers/GeneratedRepeatExtension.cs +++ /dev/null @@ -1,88 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Class used to represent repeat extensions in generated classes.
- /// </summary>
- public sealed class GeneratedRepeatExtension<TExtensionElement> : GeneratedExtensionBase<IList<TExtensionElement>>
- {
- private GeneratedRepeatExtension(FieldDescriptor field) : base(field, typeof(TExtensionElement))
- {
- }
-
- public static GeneratedExtensionBase<IList<TExtensionElement>> CreateInstance(FieldDescriptor descriptor)
- {
- if (!descriptor.IsRepeated)
- {
- throw new ArgumentException("Must call GeneratedRepeatExtension.CreateInstance() for repeated types.");
- }
- return new GeneratedRepeatExtension<TExtensionElement>(descriptor);
- }
-
- /// <summary>
- /// Converts the list to the right type.
- /// TODO(jonskeet): Check where this is used, and whether we need to convert
- /// for primitive types.
- /// </summary>
- /// <param name="value"></param>
- /// <returns></returns>
- public override object FromReflectionType(object value)
- {
- if (Descriptor.MappedType == MappedType.Message ||
- Descriptor.MappedType == MappedType.Enum)
- {
- // Must convert the whole list.
- List<TExtensionElement> result = new List<TExtensionElement>();
- foreach (object element in (IEnumerable) value)
- {
- result.Add((TExtensionElement) SingularFromReflectionType(element));
- }
- return result;
- }
- else
- {
- return value;
- }
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/GeneratedSingleExtension.cs b/csharp/src/ProtocolBuffers/GeneratedSingleExtension.cs deleted file mode 100644 index f0f1979b..00000000 --- a/csharp/src/ProtocolBuffers/GeneratedSingleExtension.cs +++ /dev/null @@ -1,65 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Generated extension for a singular field.
- /// </remarks>
- public sealed class GeneratedSingleExtension<TExtension> : GeneratedExtensionBase<TExtension>
- {
- internal GeneratedSingleExtension(FieldDescriptor descriptor) : base(descriptor, typeof(TExtension))
- {
- }
-
- public static GeneratedSingleExtension<TExtension> CreateInstance(FieldDescriptor descriptor)
- {
- if (descriptor.IsRepeated)
- {
- throw new ArgumentException("Must call GeneratedRepeateExtension.CreateInstance() for repeated types.");
- }
- return new GeneratedSingleExtension<TExtension>(descriptor);
- }
-
- public override object FromReflectionType(object value)
- {
- return base.SingularFromReflectionType(value);
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/IBuilder.cs b/csharp/src/ProtocolBuffers/IBuilder.cs deleted file mode 100644 index e765464a..00000000 --- a/csharp/src/ProtocolBuffers/IBuilder.cs +++ /dev/null @@ -1,323 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Non-generic interface for all members whose signatures don't require knowledge of
- /// the type being built. The generic interface extends this one. Some methods return
- /// either an IBuilder or an IMessage; in these cases the generic interface redeclares
- /// the same method with a type-specific signature. Implementations are encouraged to
- /// use explicit interface implemenation for the non-generic form. This mirrors
- /// how IEnumerable and IEnumerable<T> work.
- /// </summary>
- public interface IBuilder : IBuilderLite
- {
- /// <summary>
- /// Returns true iff all required fields in the message and all
- /// embedded messages are set.
- /// </summary>
- new bool IsInitialized { get; }
-
- /// <summary>
- /// Only present in the nongeneric interface - useful for tests, but
- /// not as much in real life.
- /// </summary>
- IBuilder SetField(FieldDescriptor field, object value);
-
- /// <summary>
- /// Only present in the nongeneric interface - useful for tests, but
- /// not as much in real life.
- /// </summary>
- IBuilder SetRepeatedField(FieldDescriptor field, int index, object value);
-
- /// <summary>
- /// Behaves like the equivalent property in IMessage<T>.
- /// The returned map may or may not reflect future changes to the builder.
- /// Either way, the returned map is unmodifiable.
- /// </summary>
- IDictionary<FieldDescriptor, object> AllFields { get; }
-
- /// <summary>
- /// Allows getting and setting of a field.
- /// <see cref="IMessage{TMessage, TBuilder}.Item(FieldDescriptor)"/>
- /// </summary>
- /// <param name="field"></param>
- /// <returns></returns>
- object this[FieldDescriptor field] { get; set; }
-
- /// <summary>
- /// Get the message's type descriptor.
- /// <see cref="IMessage{TMessage, TBuilder}.DescriptorForType"/>
- /// </summary>
- MessageDescriptor DescriptorForType { get; }
-
- /// <summary>
- /// <see cref="IMessage{TMessage, TBuilder}.GetRepeatedFieldCount"/>
- /// </summary>
- /// <param name="field"></param>
- /// <returns></returns>
- int GetRepeatedFieldCount(FieldDescriptor field);
-
- /// <summary>
- /// Allows getting and setting of a repeated field value.
- /// <see cref="IMessage{TMessage, TBuilder}.Item(FieldDescriptor, int)"/>
- /// </summary>
- object this[FieldDescriptor field, int index] { get; set; }
-
-
- bool HasOneof(OneofDescriptor oneof);
-
- FieldDescriptor OneofFieldDescriptor(OneofDescriptor oneof);
-
- /// <summary>
- /// <see cref="IMessage{TMessage, TBuilder}.HasField"/>
- /// </summary>
- bool HasField(FieldDescriptor field);
-
- /// <summary>
- /// <see cref="IMessage{TMessage, TBuilder}.UnknownFields"/>
- /// </summary>
- UnknownFieldSet UnknownFields { get; set; }
-
- /// <summary>
- /// Create a builder for messages of the appropriate type for the given field.
- /// Messages built with this can then be passed to the various mutation properties
- /// and methods.
- /// </summary>
- IBuilder CreateBuilderForField(FieldDescriptor field);
-
- #region Methods which are like those of the generic form, but without any knowledge of the type parameters
-
- IBuilder WeakAddRepeatedField(FieldDescriptor field, object value);
- new IBuilder WeakClear();
- IBuilder WeakClearField(FieldDescriptor field);
- IBuilder WeakClearOneof(OneofDescriptor oneof);
- IBuilder WeakMergeFrom(IMessage message);
- new IBuilder WeakMergeFrom(ByteString data);
- new IBuilder WeakMergeFrom(ByteString data, ExtensionRegistry registry);
- new IBuilder WeakMergeFrom(ICodedInputStream input);
- new IBuilder WeakMergeFrom(ICodedInputStream input, ExtensionRegistry registry);
- new IMessage WeakBuild();
- new IMessage WeakBuildPartial();
- new IBuilder WeakClone();
- new IMessage WeakDefaultInstanceForType { get; }
-
- #endregion
- }
-
- /// <summary>
- /// Interface implemented by Protocol Message builders.
- /// TODO(jonskeet): Consider "SetXXX" methods returning the builder, as well as the properties.
- /// </summary>
- /// <typeparam name="TMessage">Type of message</typeparam>
- /// <typeparam name="TBuilder">Type of builder</typeparam>
- public interface IBuilder<TMessage, TBuilder> : IBuilder, IBuilderLite<TMessage, TBuilder>
- where TMessage : IMessage<TMessage, TBuilder>
- where TBuilder : IBuilder<TMessage, TBuilder>
- {
- TBuilder SetUnknownFields(UnknownFieldSet unknownFields);
-
- /// <summary>
- /// Resets all fields to their default values.
- /// </summary>
- new TBuilder Clear();
-
- /// <summary>
- /// Merge the specified other message which may be a different implementation of
- /// the same message descriptor.
- /// </summary>
- TBuilder MergeFrom(IMessage other);
-
- /// <summary>
- /// Constructs the final message. Once this is called, this Builder instance
- /// is no longer valid, and calling any other method may throw a
- /// NullReferenceException. If you need to continue working with the builder
- /// after calling Build, call Clone first.
- /// </summary>
- /// <exception cref="UninitializedMessageException">the message
- /// is missing one or more required fields; use BuildPartial to bypass
- /// this check</exception>
- new TMessage Build();
-
- /// <summary>
- /// Like Build(), but does not throw an exception if the message is missing
- /// required fields. Instead, a partial message is returned.
- /// </summary>
- new TMessage BuildPartial();
-
- /// <summary>
- /// Clones this builder.
- /// TODO(jonskeet): Explain depth of clone.
- /// </summary>
- new TBuilder Clone();
-
- /// <summary>
- /// Parses a message of this type from the input and merges it with this
- /// message, as if using MergeFrom(IMessage<T>).
- /// </summary>
- /// <remarks>
- /// Warning: This does not verify that all required fields are present
- /// in the input message. If you call Build() without setting all
- /// required fields, it will throw an UninitializedMessageException.
- /// There are a few good ways to deal with this:
- /// <list>
- /// <item>Call IsInitialized to verify to verify that all required fields are
- /// set before building.</item>
- /// <item>Parse the message separately using one of the static ParseFrom
- /// methods, then use MergeFrom(IMessage<T>) to merge it with
- /// this one. ParseFrom will throw an InvalidProtocolBufferException
- /// (an IOException) if some required fields are missing.
- /// Use BuildPartial to build, which ignores missing required fields.
- /// </list>
- /// </remarks>
- new TBuilder MergeFrom(ICodedInputStream input);
-
- /// <summary>
- /// Like MergeFrom(ICodedInputStream), but also parses extensions.
- /// The extensions that you want to be able to parse must be registered
- /// in <paramref name="extensionRegistry"/>. Extensions not in the registry
- /// will be treated as unknown fields.
- /// </summary>
- new TBuilder MergeFrom(ICodedInputStream input, ExtensionRegistry extensionRegistry);
-
- /// <summary>
- /// Get's the message's type's default instance.
- /// <see cref="IMessage{TMessage}.DefaultInstanceForType" />
- /// </summary>
- new TMessage DefaultInstanceForType { get; }
-
- /// <summary>
- /// Clears the field. This is exactly equivalent to calling the generated
- /// Clear method corresponding to the field.
- /// </summary>
- /// <param name="field"></param>
- /// <returns></returns>
- TBuilder ClearField(FieldDescriptor field);
-
- /// <summary>
- /// Clears the oneof. This is exactly equivalent to calling the generated
- /// Clear method corresponding to the oneof.
- /// </summary>
- /// <param name="oneof"></param>
- /// <returns></returns>
- TBuilder ClearOneof(OneofDescriptor oneof);
-
- /// <summary>
- /// Appends the given value as a new element for the specified repeated field.
- /// </summary>
- /// <exception cref="ArgumentException">the field is not a repeated field,
- /// the field does not belong to this builder's type, or the value is
- /// of the incorrect type
- /// </exception>
- TBuilder AddRepeatedField(FieldDescriptor field, object value);
-
- /// <summary>
- /// Merge some unknown fields into the set for this message.
- /// </summary>
- TBuilder MergeUnknownFields(UnknownFieldSet unknownFields);
-
- /// <summary>
- /// Like MergeFrom(Stream), but does not read until the end of the file.
- /// Instead, the size of the message (encoded as a varint) is read first,
- /// then the message data. Use Message.WriteDelimitedTo(Stream) to
- /// write messages in this format.
- /// </summary>
- /// <param name="input"></param>
- new TBuilder MergeDelimitedFrom(Stream input);
-
- /// <summary>
- /// Like MergeDelimitedFrom(Stream) but supporting extensions.
- /// </summary>
- new TBuilder MergeDelimitedFrom(Stream input, ExtensionRegistry extensionRegistry);
-
- #region Convenience methods
-
- /// <summary>
- /// Parse <paramref name="data"/> as a message of this type and merge
- /// it with the message being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream).
- /// </summary>
- new TBuilder MergeFrom(ByteString data);
-
- /// <summary>
- /// Parse <paramref name="data"/> as a message of this type and merge
- /// it with the message being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream, extensionRegistry).
- /// </summary>
- new TBuilder MergeFrom(ByteString data, ExtensionRegistry extensionRegistry);
-
- /// <summary>
- /// Parse <paramref name="data"/> as a message of this type and merge
- /// it with the message being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream).
- /// </summary>
- new TBuilder MergeFrom(byte[] data);
-
- /// <summary>
- /// Parse <paramref name="data"/> as a message of this type and merge
- /// it with the message being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream, extensionRegistry).
- /// </summary>
- new TBuilder MergeFrom(byte[] data, ExtensionRegistry extensionRegistry);
-
- /// <summary>
- /// Parse <paramref name="input"/> as a message of this type and merge
- /// it with the message being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream). Note that this method always reads
- /// the entire input (unless it throws an exception). If you want it to
- /// stop earlier, you will need to wrap the input in a wrapper
- /// stream which limits reading. Or, use IMessage.WriteDelimitedTo(Stream)
- /// to write your message and MmergeDelimitedFrom(Stream) to read it.
- /// Despite usually reading the entire stream, this method never closes the stream.
- /// </summary>
- new TBuilder MergeFrom(Stream input);
-
- /// <summary>
- /// Parse <paramref name="input"/> as a message of this type and merge
- /// it with the message being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream, extensionRegistry).
- /// </summary>
- new TBuilder MergeFrom(Stream input, ExtensionRegistry extensionRegistry);
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/IBuilderLite.cs b/csharp/src/ProtocolBuffers/IBuilderLite.cs deleted file mode 100644 index 330fe495..00000000 --- a/csharp/src/ProtocolBuffers/IBuilderLite.cs +++ /dev/null @@ -1,213 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System.IO;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Non-generic interface for all members whose signatures don't require knowledge of
- /// the type being built. The generic interface extends this one. Some methods return
- /// either an IBuilder or an IMessage; in these cases the generic interface redeclares
- /// the same method with a type-specific signature. Implementations are encouraged to
- /// use explicit interface implemenation for the non-generic form. This mirrors
- /// how IEnumerable and IEnumerable<T> work.
- /// </summary>
- public partial interface IBuilderLite
- {
- /// <summary>
- /// Returns true iff all required fields in the message and all
- /// embedded messages are set.
- /// </summary>
- bool IsInitialized { get; }
-
- IBuilderLite WeakClear();
- IBuilderLite WeakMergeFrom(IMessageLite message);
- IBuilderLite WeakMergeFrom(ByteString data);
- IBuilderLite WeakMergeFrom(ByteString data, ExtensionRegistry registry);
- IBuilderLite WeakMergeFrom(ICodedInputStream input);
- IBuilderLite WeakMergeFrom(ICodedInputStream input, ExtensionRegistry registry);
- IMessageLite WeakBuild();
- IMessageLite WeakBuildPartial();
- IBuilderLite WeakClone();
- IMessageLite WeakDefaultInstanceForType { get; }
- }
-
- /// <summary>
- /// Interface implemented by Protocol Message builders.
- /// TODO(jonskeet): Consider "SetXXX" methods returning the builder, as well as the properties.
- /// </summary>
- /// <typeparam name="TMessage">Type of message</typeparam>
- /// <typeparam name="TBuilder">Type of builder</typeparam>
- public interface IBuilderLite<TMessage, TBuilder> : IBuilderLite
- where TMessage : IMessageLite<TMessage, TBuilder>
- where TBuilder : IBuilderLite<TMessage, TBuilder>
- {
- /// <summary>
- /// Resets all fields to their default values.
- /// </summary>
- TBuilder Clear();
-
- /// <summary>
- /// Merge the specified other message which may be a different implementation of
- /// the same message descriptor.
- /// </summary>
- TBuilder MergeFrom(IMessageLite other);
-
- /// <summary>
- /// Constructs the final message. Once this is called, this Builder instance
- /// is no longer valid, and calling any other method may throw a
- /// NullReferenceException. If you need to continue working with the builder
- /// after calling Build, call Clone first.
- /// </summary>
- /// <exception cref="UninitializedMessageException">the message
- /// is missing one or more required fields; use BuildPartial to bypass
- /// this check</exception>
- TMessage Build();
-
- /// <summary>
- /// Like Build(), but does not throw an exception if the message is missing
- /// required fields. Instead, a partial message is returned.
- /// </summary>
- TMessage BuildPartial();
-
- /// <summary>
- /// Clones this builder.
- /// TODO(jonskeet): Explain depth of clone.
- /// </summary>
- TBuilder Clone();
-
- /// <summary>
- /// Parses a message of this type from the input and merges it with this
- /// message, as if using MergeFrom(IMessage<T>).
- /// </summary>
- /// <remarks>
- /// Warning: This does not verify that all required fields are present
- /// in the input message. If you call Build() without setting all
- /// required fields, it will throw an UninitializedMessageException.
- /// There are a few good ways to deal with this:
- /// <list>
- /// <item>Call IsInitialized to verify to verify that all required fields are
- /// set before building.</item>
- /// <item>Parse the message separately using one of the static ParseFrom
- /// methods, then use MergeFrom(IMessage<T>) to merge it with
- /// this one. ParseFrom will throw an InvalidProtocolBufferException
- /// (an IOException) if some required fields are missing.
- /// Use BuildPartial to build, which ignores missing required fields.
- /// </list>
- /// </remarks>
- TBuilder MergeFrom(ICodedInputStream input);
-
- /// <summary>
- /// Like MergeFrom(ICodedInputStream), but also parses extensions.
- /// The extensions that you want to be able to parse must be registered
- /// in <paramref name="extensionRegistry"/>. Extensions not in the registry
- /// will be treated as unknown fields.
- /// </summary>
- TBuilder MergeFrom(ICodedInputStream input, ExtensionRegistry extensionRegistry);
-
- /// <summary>
- /// Get's the message's type's default instance.
- /// <see cref="IMessageLite{TMessage}.DefaultInstanceForType" />
- /// </summary>
- TMessage DefaultInstanceForType { get; }
-
- /// <summary>
- /// Like MergeFrom(Stream), but does not read until the end of the file.
- /// Instead, the size of the message (encoded as a varint) is read first,
- /// then the message data. Use Message.WriteDelimitedTo(Stream) to
- /// write messages in this format.
- /// </summary>
- /// <param name="input"></param>
- TBuilder MergeDelimitedFrom(Stream input);
-
- /// <summary>
- /// Like MergeDelimitedFrom(Stream) but supporting extensions.
- /// </summary>
- TBuilder MergeDelimitedFrom(Stream input, ExtensionRegistry extensionRegistry);
-
- #region Convenience methods
-
- /// <summary>
- /// Parse <paramref name="data"/> as a message of this type and merge
- /// it with the message being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream).
- /// </summary>
- TBuilder MergeFrom(ByteString data);
-
- /// <summary>
- /// Parse <paramref name="data"/> as a message of this type and merge
- /// it with the message being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream, ExtensionRegistry).
- /// </summary>
- TBuilder MergeFrom(ByteString data, ExtensionRegistry extensionRegistry);
-
- /// <summary>
- /// Parse <paramref name="data"/> as a message of this type and merge
- /// it with the message being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream).
- /// </summary>
- TBuilder MergeFrom(byte[] data);
-
- /// <summary>
- /// Parse <paramref name="data"/> as a message of this type and merge
- /// it with the message being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream, ExtensionRegistry).
- /// </summary>
- TBuilder MergeFrom(byte[] data, ExtensionRegistry extensionRegistry);
-
- /// <summary>
- /// Parse <paramref name="input"/> as a message of this type and merge
- /// it with the message being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream). Note that this method always reads
- /// the entire input (unless it throws an exception). If you want it to
- /// stop earlier, you will need to wrap the input in a wrapper
- /// stream which limits reading. Or, use IMessage.WriteDelimitedTo(Stream)
- /// to write your message and MmergeDelimitedFrom(Stream) to read it.
- /// Despite usually reading the entire stream, this method never closes the stream.
- /// </summary>
- TBuilder MergeFrom(Stream input);
-
- /// <summary>
- /// Parse <paramref name="input"/> as a message of this type and merge
- /// it with the message being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream, ExtensionRegistry).
- /// </summary>
- TBuilder MergeFrom(Stream input, ExtensionRegistry extensionRegistry);
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ICodedInputStream.cs b/csharp/src/ProtocolBuffers/ICodedInputStream.cs deleted file mode 100644 index 790274fb..00000000 --- a/csharp/src/ProtocolBuffers/ICodedInputStream.cs +++ /dev/null @@ -1,318 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using Google.ProtocolBuffers.Descriptors;
-
-//Disable warning CS3010: CLS-compliant interfaces must have only CLS-compliant members
-#pragma warning disable 3010
-
-namespace Google.ProtocolBuffers
-{
- public interface ICodedInputStream
- {
- /// <summary>
- /// Reads any message initialization data expected from the input stream
- /// </summary>
- /// <remarks>
- /// This is primarily used by text formats and unnecessary for protobuffers' own
- /// binary format. The API for MessageStart/End was added for consistent handling
- /// of output streams regardless of the actual writer implementation.
- /// </remarks>
- void ReadMessageStart();
- /// <summary>
- /// Reads any message finalization data expected from the input stream
- /// </summary>
- /// <remarks>
- /// This is primarily used by text formats and unnecessary for protobuffers' own
- /// binary format. The API for MessageStart/End was added for consistent handling
- /// of output streams regardless of the actual writer implementation.
- /// </remarks>
- void ReadMessageEnd();
- /// <summary>
- /// Attempt to read a field tag, returning false if we have reached the end
- /// of the input data.
- /// </summary>
- /// <remarks>
- /// <para>
- /// If fieldTag is non-zero and ReadTag returns true then the value in fieldName
- /// may or may not be populated. However, if fieldTag is zero and ReadTag returns
- /// true, then fieldName should be populated with a non-null field name.
- /// </para><para>
- /// In other words if ReadTag returns true then either fieldTag will be non-zero OR
- /// fieldName will be non-zero. In some cases both may be populated, however the
- /// builders will always prefer the fieldTag over fieldName.
- /// </para>
- /// </remarks>
- bool ReadTag(out uint fieldTag, out string fieldName);
-
- /// <summary>
- /// Read a double field from the stream.
- /// </summary>
- bool ReadDouble(ref double value);
-
- /// <summary>
- /// Read a float field from the stream.
- /// </summary>
- bool ReadFloat(ref float value);
-
- /// <summary>
- /// Read a uint64 field from the stream.
- /// </summary>
- bool ReadUInt64(ref ulong value);
-
- /// <summary>
- /// Read an int64 field from the stream.
- /// </summary>
- bool ReadInt64(ref long value);
-
- /// <summary>
- /// Read an int32 field from the stream.
- /// </summary>
- bool ReadInt32(ref int value);
-
- /// <summary>
- /// Read a fixed64 field from the stream.
- /// </summary>
- bool ReadFixed64(ref ulong value);
-
- /// <summary>
- /// Read a fixed32 field from the stream.
- /// </summary>
- bool ReadFixed32(ref uint value);
-
- /// <summary>
- /// Read a bool field from the stream.
- /// </summary>
- bool ReadBool(ref bool value);
-
- /// <summary>
- /// Reads a string field from the stream.
- /// </summary>
- bool ReadString(ref string value);
-
- /// <summary>
- /// Reads a group field value from the stream.
- /// </summary>
- void ReadGroup(int fieldNumber, IBuilderLite builder,
- ExtensionRegistry extensionRegistry);
-
- /// <summary>
- /// Reads a group field value from the stream and merges it into the given
- /// UnknownFieldSet.
- /// </summary>
- [Obsolete]
- void ReadUnknownGroup(int fieldNumber, IBuilderLite builder);
-
- /// <summary>
- /// Reads an embedded message field value from the stream.
- /// </summary>
- void ReadMessage(IBuilderLite builder, ExtensionRegistry extensionRegistry);
-
- /// <summary>
- /// Reads a bytes field value from the stream.
- /// </summary>
- bool ReadBytes(ref ByteString value);
-
- /// <summary>
- /// Reads a uint32 field value from the stream.
- /// </summary>
- bool ReadUInt32(ref uint value);
-
- /// <summary>
- /// Reads an enum field value from the stream. The caller is responsible
- /// for converting the numeric value to an actual enum.
- /// </summary>
- bool ReadEnum(ref IEnumLite value, out object unknown, IEnumLiteMap mapping);
-
- /// <summary>
- /// Reads an enum field value from the stream. If the enum is valid for type T,
- /// then the ref value is set and it returns true. Otherwise the unkown output
- /// value is set and this method returns false.
- /// </summary>
- bool ReadEnum<T>(ref T value, out object unknown)
- where T : struct, IComparable, IFormattable;
-
- /// <summary>
- /// Reads an sfixed32 field value from the stream.
- /// </summary>
- bool ReadSFixed32(ref int value);
-
- /// <summary>
- /// Reads an sfixed64 field value from the stream.
- /// </summary>
- bool ReadSFixed64(ref long value);
-
- /// <summary>
- /// Reads an sint32 field value from the stream.
- /// </summary>
- bool ReadSInt32(ref int value);
-
- /// <summary>
- /// Reads an sint64 field value from the stream.
- /// </summary>
- bool ReadSInt64(ref long value);
-
- /// <summary>
- /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed and the
- /// type is numeric, it will read a packed array.
- /// </summary>
- void ReadPrimitiveArray(FieldType fieldType, uint fieldTag, string fieldName, ICollection<object> list);
-
- /// <summary>
- /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed, it will
- /// read a packed array.
- /// </summary>
- void ReadEnumArray(uint fieldTag, string fieldName, ICollection<IEnumLite> list, out ICollection<object> unknown,
- IEnumLiteMap mapping);
-
- /// <summary>
- /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed, it will
- /// read a packed array.
- /// </summary>
- void ReadEnumArray<T>(uint fieldTag, string fieldName, ICollection<T> list, out ICollection<object> unknown)
- where T : struct, IComparable, IFormattable;
-
- /// <summary>
- /// Reads a set of messages using the <paramref name="messageType"/> as a template. T is not guaranteed to be
- /// the most derived type, it is only the type specifier for the collection.
- /// </summary>
- void ReadMessageArray<T>(uint fieldTag, string fieldName, ICollection<T> list, T messageType,
- ExtensionRegistry registry) where T : IMessageLite;
-
- /// <summary>
- /// Reads a set of messages using the <paramref name="messageType"/> as a template.
- /// </summary>
- void ReadGroupArray<T>(uint fieldTag, string fieldName, ICollection<T> list, T messageType,
- ExtensionRegistry registry) where T : IMessageLite;
-
- /// <summary>
- /// Reads a field of any primitive type. Enums, groups and embedded
- /// messages are not handled by this method.
- /// </summary>
- bool ReadPrimitiveField(FieldType fieldType, ref object value);
-
- /// <summary>
- /// Returns true if the stream has reached the end of the input. This is the
- /// case if either the end of the underlying input source has been reached or
- /// the stream has reached a limit created using PushLimit.
- /// </summary>
- bool IsAtEnd { get; }
-
- /// <summary>
- /// Reads and discards a single field, given its tag value.
- /// </summary>
- /// <returns>false if the tag is an end-group tag, in which case
- /// nothing is skipped. Otherwise, returns true.</returns>
- bool SkipField();
-
- /// <summary>
- /// Reads one or more repeated string field values from the stream.
- /// </summary>
- void ReadStringArray(uint fieldTag, string fieldName, ICollection<string> list);
-
- /// <summary>
- /// Reads one or more repeated ByteString field values from the stream.
- /// </summary>
- void ReadBytesArray(uint fieldTag, string fieldName, ICollection<ByteString> list);
-
- /// <summary>
- /// Reads one or more repeated boolean field values from the stream.
- /// </summary>
- void ReadBoolArray(uint fieldTag, string fieldName, ICollection<bool> list);
-
- /// <summary>
- /// Reads one or more repeated Int32 field values from the stream.
- /// </summary>
- void ReadInt32Array(uint fieldTag, string fieldName, ICollection<int> list);
-
- /// <summary>
- /// Reads one or more repeated SInt32 field values from the stream.
- /// </summary>
- void ReadSInt32Array(uint fieldTag, string fieldName, ICollection<int> list);
-
- /// <summary>
- /// Reads one or more repeated UInt32 field values from the stream.
- /// </summary>
- void ReadUInt32Array(uint fieldTag, string fieldName, ICollection<uint> list);
-
- /// <summary>
- /// Reads one or more repeated Fixed32 field values from the stream.
- /// </summary>
- void ReadFixed32Array(uint fieldTag, string fieldName, ICollection<uint> list);
-
- /// <summary>
- /// Reads one or more repeated SFixed32 field values from the stream.
- /// </summary>
- void ReadSFixed32Array(uint fieldTag, string fieldName, ICollection<int> list);
-
- /// <summary>
- /// Reads one or more repeated Int64 field values from the stream.
- /// </summary>
- void ReadInt64Array(uint fieldTag, string fieldName, ICollection<long> list);
-
- /// <summary>
- /// Reads one or more repeated SInt64 field values from the stream.
- /// </summary>
- void ReadSInt64Array(uint fieldTag, string fieldName, ICollection<long> list);
-
- /// <summary>
- /// Reads one or more repeated UInt64 field values from the stream.
- /// </summary>
- void ReadUInt64Array(uint fieldTag, string fieldName, ICollection<ulong> list);
-
- /// <summary>
- /// Reads one or more repeated Fixed64 field values from the stream.
- /// </summary>
- void ReadFixed64Array(uint fieldTag, string fieldName, ICollection<ulong> list);
-
- /// <summary>
- /// Reads one or more repeated SFixed64 field values from the stream.
- /// </summary>
- void ReadSFixed64Array(uint fieldTag, string fieldName, ICollection<long> list);
-
- /// <summary>
- /// Reads one or more repeated Double field values from the stream.
- /// </summary>
- void ReadDoubleArray(uint fieldTag, string fieldName, ICollection<double> list);
-
- /// <summary>
- /// Reads one or more repeated Float field values from the stream.
- /// </summary>
- void ReadFloatArray(uint fieldTag, string fieldName, ICollection<float> list);
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ICodedOutputStream.cs b/csharp/src/ProtocolBuffers/ICodedOutputStream.cs deleted file mode 100644 index 77de60ca..00000000 --- a/csharp/src/ProtocolBuffers/ICodedOutputStream.cs +++ /dev/null @@ -1,368 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using Google.ProtocolBuffers.Descriptors;
-
-//Disable warning CS3010: CLS-compliant interfaces must have only CLS-compliant members
-#pragma warning disable 3010
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Provides an interface that is used write a message. Most often proto buffers are written
- /// in their binary form by creating a instance via the CodedOutputStream.CreateInstance
- /// static factory.
- /// </summary>
- public interface ICodedOutputStream
- {
- /// <summary>
- /// Writes any message initialization data needed to the output stream
- /// </summary>
- /// <remarks>
- /// This is primarily used by text formats and unnecessary for protobuffers' own
- /// binary format. The API for MessageStart/End was added for consistent handling
- /// of output streams regardless of the actual writer implementation.
- /// </remarks>
- void WriteMessageStart();
- /// <summary>
- /// Writes any message finalization data needed to the output stream
- /// </summary>
- /// <remarks>
- /// This is primarily used by text formats and unnecessary for protobuffers' own
- /// binary format. The API for MessageStart/End was added for consistent handling
- /// of output streams regardless of the actual writer implementation.
- /// </remarks>
- void WriteMessageEnd();
- /// <summary>
- /// Indicates that all temporary buffers be written to the final output.
- /// </summary>
- void Flush();
- /// <summary>
- /// Writes an unknown message as a group
- /// </summary>
- [Obsolete]
- void WriteUnknownGroup(int fieldNumber, IMessageLite value);
- /// <summary>
- /// Writes an unknown field value of bytes
- /// </summary>
- void WriteUnknownBytes(int fieldNumber, ByteString value);
- /// <summary>
- /// Writes an unknown field of a primitive type
- /// </summary>
-
- void WriteUnknownField(int fieldNumber, WireFormat.WireType wireType, ulong value);
- /// <summary>
- /// Writes an extension as a message-set group
- /// </summary>
- void WriteMessageSetExtension(int fieldNumber, string fieldName, IMessageLite value);
- /// <summary>
- /// Writes an unknown extension as a message-set group
- /// </summary>
- void WriteMessageSetExtension(int fieldNumber, string fieldName, ByteString value);
-
- /// <summary>
- /// Writes a field value, including tag, to the stream.
- /// </summary>
- void WriteField(FieldType fieldType, int fieldNumber, string fieldName, object value);
-
- /// <summary>
- /// Writes a double field value, including tag, to the stream.
- /// </summary>
- void WriteDouble(int fieldNumber, string fieldName, double value);
-
- /// <summary>
- /// Writes a float field value, including tag, to the stream.
- /// </summary>
- void WriteFloat(int fieldNumber, string fieldName, float value);
-
- /// <summary>
- /// Writes a uint64 field value, including tag, to the stream.
- /// </summary>
- void WriteUInt64(int fieldNumber, string fieldName, ulong value);
-
- /// <summary>
- /// Writes an int64 field value, including tag, to the stream.
- /// </summary>
- void WriteInt64(int fieldNumber, string fieldName, long value);
-
- /// <summary>
- /// Writes an int32 field value, including tag, to the stream.
- /// </summary>
- void WriteInt32(int fieldNumber, string fieldName, int value);
-
- /// <summary>
- /// Writes a fixed64 field value, including tag, to the stream.
- /// </summary>
- void WriteFixed64(int fieldNumber, string fieldName, ulong value);
-
- /// <summary>
- /// Writes a fixed32 field value, including tag, to the stream.
- /// </summary>
- void WriteFixed32(int fieldNumber, string fieldName, uint value);
-
- /// <summary>
- /// Writes a bool field value, including tag, to the stream.
- /// </summary>
- void WriteBool(int fieldNumber, string fieldName, bool value);
-
- /// <summary>
- /// Writes a string field value, including tag, to the stream.
- /// </summary>
- void WriteString(int fieldNumber, string fieldName, string value);
-
- /// <summary>
- /// Writes a group field value, including tag, to the stream.
- /// </summary>
- void WriteGroup(int fieldNumber, string fieldName, IMessageLite value);
-
- /// <summary>
- /// Writes a message field value, including tag, to the stream.
- /// </summary>
- void WriteMessage(int fieldNumber, string fieldName, IMessageLite value);
-
- /// <summary>
- /// Writes a byte array field value, including tag, to the stream.
- /// </summary>
- void WriteBytes(int fieldNumber, string fieldName, ByteString value);
-
- /// <summary>
- /// Writes a UInt32 field value, including tag, to the stream.
- /// </summary>
- void WriteUInt32(int fieldNumber, string fieldName, uint value);
-
- /// <summary>
- /// Writes an enum field value, including tag, to the stream.
- /// </summary>
- void WriteEnum(int fieldNumber, string fieldName, int value, object rawValue);
-
- /// <summary>
- /// Writes a fixed 32-bit field value, including tag, to the stream.
- /// </summary>
- void WriteSFixed32(int fieldNumber, string fieldName, int value);
-
- /// <summary>
- /// Writes a signed fixed 64-bit field value, including tag, to the stream.
- /// </summary>
- void WriteSFixed64(int fieldNumber, string fieldName, long value);
-
- /// <summary>
- /// Writes a signed 32-bit field value, including tag, to the stream.
- /// </summary>
- void WriteSInt32(int fieldNumber, string fieldName, int value);
-
- /// <summary>
- /// Writes a signed 64-bit field value, including tag, to the stream.
- /// </summary>
- void WriteSInt64(int fieldNumber, string fieldName, long value);
-
- /// <summary>
- /// Writes a repeated field value, including tag(s), to the stream.
- /// </summary>
- void WriteArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list);
-
- /// <summary>
- /// Writes a repeated group value, including tag(s), to the stream.
- /// </summary>
- void WriteGroupArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
- where T : IMessageLite;
-
- /// <summary>
- /// Writes a repeated message value, including tag(s), to the stream.
- /// </summary>
- void WriteMessageArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
- where T : IMessageLite;
-
- /// <summary>
- /// Writes a repeated string value, including tag(s), to the stream.
- /// </summary>
- void WriteStringArray(int fieldNumber, string fieldName, IEnumerable<string> list);
-
- /// <summary>
- /// Writes a repeated ByteString value, including tag(s), to the stream.
- /// </summary>
- void WriteBytesArray(int fieldNumber, string fieldName, IEnumerable<ByteString> list);
-
- /// <summary>
- /// Writes a repeated boolean value, including tag(s), to the stream.
- /// </summary>
- void WriteBoolArray(int fieldNumber, string fieldName, IEnumerable<bool> list);
-
- /// <summary>
- /// Writes a repeated Int32 value, including tag(s), to the stream.
- /// </summary>
- void WriteInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
-
- /// <summary>
- /// Writes a repeated SInt32 value, including tag(s), to the stream.
- /// </summary>
- void WriteSInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
-
- /// <summary>
- /// Writes a repeated UInt32 value, including tag(s), to the stream.
- /// </summary>
- void WriteUInt32Array(int fieldNumber, string fieldName, IEnumerable<uint> list);
-
- /// <summary>
- /// Writes a repeated Fixed32 value, including tag(s), to the stream.
- /// </summary>
- void WriteFixed32Array(int fieldNumber, string fieldName, IEnumerable<uint> list);
-
- /// <summary>
- /// Writes a repeated SFixed32 value, including tag(s), to the stream.
- /// </summary>
- void WriteSFixed32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
-
- /// <summary>
- /// Writes a repeated Int64 value, including tag(s), to the stream.
- /// </summary>
- void WriteInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
-
- /// <summary>
- /// Writes a repeated SInt64 value, including tag(s), to the stream.
- /// </summary>
- void WriteSInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
-
- /// <summary>
- /// Writes a repeated UInt64 value, including tag(s), to the stream.
- /// </summary>
- void WriteUInt64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list);
-
- /// <summary>
- /// Writes a repeated Fixed64 value, including tag(s), to the stream.
- /// </summary>
- void WriteFixed64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list);
-
- /// <summary>
- /// Writes a repeated SFixed64 value, including tag(s), to the stream.
- /// </summary>
- void WriteSFixed64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
-
- /// <summary>
- /// Writes a repeated Double value, including tag(s), to the stream.
- /// </summary>
- void WriteDoubleArray(int fieldNumber, string fieldName, IEnumerable<double> list);
-
- /// <summary>
- /// Writes a repeated Float value, including tag(s), to the stream.
- /// </summary>
- void WriteFloatArray(int fieldNumber, string fieldName, IEnumerable<float> list);
-
- /// <summary>
- /// Writes a repeated enumeration value of type T, including tag(s), to the stream.
- /// </summary>
- void WriteEnumArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
- where T : struct, IComparable, IFormattable;
-
- /// <summary>
- /// Writes a packed repeated primitive, including tag and length, to the stream.
- /// </summary>
- void WritePackedArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list);
-
- /// <summary>
- /// Writes a packed repeated boolean, including tag and length, to the stream.
- /// </summary>
- void WritePackedBoolArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<bool> list);
-
- /// <summary>
- /// Writes a packed repeated Int32, including tag and length, to the stream.
- /// </summary>
- void WritePackedInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
-
- /// <summary>
- /// Writes a packed repeated SInt32, including tag and length, to the stream.
- /// </summary>
- void WritePackedSInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
-
- /// <summary>
- /// Writes a packed repeated UInt32, including tag and length, to the stream.
- /// </summary>
- void WritePackedUInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<uint> list);
-
- /// <summary>
- /// Writes a packed repeated Fixed32, including tag and length, to the stream.
- /// </summary>
- void WritePackedFixed32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<uint> list);
-
- /// <summary>
- /// Writes a packed repeated SFixed32, including tag and length, to the stream.
- /// </summary>
- void WritePackedSFixed32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
-
- /// <summary>
- /// Writes a packed repeated Int64, including tag and length, to the stream.
- /// </summary>
- void WritePackedInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
-
- /// <summary>
- /// Writes a packed repeated SInt64, including tag and length, to the stream.
- /// </summary>
- void WritePackedSInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
-
- /// <summary>
- /// Writes a packed repeated UInt64, including tag and length, to the stream.
- /// </summary>
- void WritePackedUInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<ulong> list);
-
- /// <summary>
- /// Writes a packed repeated Fixed64, including tag and length, to the stream.
- /// </summary>
- void WritePackedFixed64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<ulong> list);
-
- /// <summary>
- /// Writes a packed repeated SFixed64, including tag and length, to the stream.
- /// </summary>
- void WritePackedSFixed64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
-
- /// <summary>
- /// Writes a packed repeated Double, including tag and length, to the stream.
- /// </summary>
- void WritePackedDoubleArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<double> list);
-
- /// <summary>
- /// Writes a packed repeated Float, including tag and length, to the stream.
- /// </summary>
- void WritePackedFloatArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<float> list);
-
- /// <summary>
- /// Writes a packed repeated enumeration of type T, including tag and length, to the stream.
- /// </summary>
- void WritePackedEnumArray<T>(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<T> list)
- where T : struct, IComparable, IFormattable;
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs index dd309d4e..9c2a2d85 100644 --- a/csharp/src/ProtocolBuffers/IMessage.cs +++ b/csharp/src/ProtocolBuffers/IMessage.cs @@ -34,220 +34,63 @@ #endregion
-using System;
-using System.Collections.Generic;
-using System.IO;
-using Google.ProtocolBuffers.Descriptors;
+using Google.Protobuf.FieldAccess;
-namespace Google.ProtocolBuffers
+namespace Google.Protobuf
{
+
+ // TODO(jonskeet): Do we want a "weak" (non-generic) version of IReflectedMessage?
+
/// <summary>
- /// Non-generic interface used for all parts of the API which don't require
- /// any type knowledge.
+ /// Reflection support for a specific message type. message
/// </summary>
- public interface IMessage : IMessageLite
+ /// <typeparam name="T">The message type being reflected.</typeparam>
+ public interface IReflectedMessage<T> where T : IMessage<T>
{
- /// <summary>
- /// Returns the message's type's descriptor. This differs from the
- /// Descriptor property of each generated message class in that this
- /// method is an abstract method of IMessage whereas Descriptor is
- /// a static property of a specific class. They return the same thing.
- /// </summary>
- MessageDescriptor DescriptorForType { get; }
-
- /// <summary>
- /// Returns a collection of all the fields in this message which are set
- /// and their corresponding values. A singular ("required" or "optional")
- /// field is set iff HasField() returns true for that field. A "repeated"
- /// field is set iff GetRepeatedFieldSize() is greater than zero. The
- /// values are exactly what would be returned by calling
- /// GetField(FieldDescriptor) for each field. The map
- /// is guaranteed to be a sorted map, so iterating over it will return fields
- /// in order by field number.
- /// </summary>
- IDictionary<FieldDescriptor, object> AllFields { get; }
-
- bool HasOneof(OneofDescriptor oneof);
-
- FieldDescriptor OneofFieldDescriptor(OneofDescriptor oneof);
-
- /// <summary>
- /// Returns true if the given field is set. This is exactly equivalent
- /// to calling the generated "Has" property corresponding to the field.
- /// </summary>
- /// <exception cref="ArgumentException">the field is a repeated field,
- /// or it's not a field of this type</exception>
- bool HasField(FieldDescriptor field);
-
- /// <summary>
- /// Obtains the value of the given field, or the default value if
- /// it isn't set. For value type fields, the boxed value is returned.
- /// For enum fields, the EnumValueDescriptor for the enum is returned.
- /// For embedded message fields, the sub-message
- /// is returned. For repeated fields, an IList<T> is returned.
- /// </summary>
- object this[FieldDescriptor field] { get; }
-
- /// <summary>
- /// Returns the number of elements of a repeated field. This is
- /// exactly equivalent to calling the generated "Count" property
- /// corresponding to the field.
- /// </summary>
- /// <exception cref="ArgumentException">the field is not a repeated field,
- /// or it's not a field of this type</exception>
- int GetRepeatedFieldCount(FieldDescriptor field);
-
- /// <summary>
- /// Gets an element of a repeated field. For value type fields
- /// excluding enums, the boxed value is returned. For embedded
- /// message fields, the sub-message is returned. For enums, the
- /// relevant EnumValueDescriptor is returned.
- /// </summary>
- /// <exception cref="ArgumentException">the field is not a repeated field,
- /// or it's not a field of this type</exception>
- /// <exception cref="ArgumentOutOfRangeException">the index is out of
- /// range for the repeated field's value</exception>
- object this[FieldDescriptor field, int index] { get; }
-
- /// <summary>
- /// Returns the unknown fields for this message.
- /// </summary>
- UnknownFieldSet UnknownFields { get; }
-
- /// <summary>
- /// Returns true iff all required fields in the message and all embedded
- /// messages are set.
- /// </summary>
- new bool IsInitialized { get; }
-
- /// <summary>
- /// Serializes the message and writes it to the given output stream.
- /// This does not flush or close the stream.
- /// </summary>
- /// <remarks>
- /// Protocol Buffers are not self-delimiting. Therefore, if you write
- /// any more data to the stream after the message, you must somehow ensure
- /// that the parser on the receiving end does not interpret this as being
- /// part of the protocol message. One way of doing this is by writing the size
- /// of the message before the data, then making sure you limit the input to
- /// that size when receiving the data. Alternatively, use WriteDelimitedTo(Stream).
- /// </remarks>
- new void WriteTo(ICodedOutputStream output);
-
- /// <summary>
- /// Like WriteTo(Stream) but writes the size of the message as a varint before
- /// writing the data. This allows more data to be written to the stream after the
- /// message without the need to delimit the message data yourself. Use
- /// IBuilder.MergeDelimitedFrom(Stream) or the static method
- /// YourMessageType.ParseDelimitedFrom(Stream) to parse messages written by this method.
- /// </summary>
- /// <param name="output"></param>
- new void WriteDelimitedTo(Stream output);
-
- /// <summary>
- /// Returns the number of bytes required to encode this message.
- /// The result is only computed on the first call and memoized after that.
- /// </summary>
- new int SerializedSize { get; }
-
- #region Comparison and hashing
-
- /// <summary>
- /// Compares the specified object with this message for equality.
- /// Returns true iff the given object is a message of the same type
- /// (as defined by DescriptorForType) and has identical values
- /// for all its fields.
- /// </summary>
- new bool Equals(object other);
-
- /// <summary>
- /// Returns the hash code value for this message.
- /// TODO(jonskeet): Specify the hash algorithm, but better than the Java one!
- /// </summary>
- new int GetHashCode();
-
- #endregion
-
- #region Convenience methods
-
- /// <summary>
- /// Converts the message to a string in protocol buffer text format.
- /// This is just a trivial wrapper around TextFormat.PrintToString.
- /// </summary>
- new string ToString();
-
- /// <summary>
- /// Serializes the message to a ByteString. This is a trivial wrapper
- /// around WriteTo(ICodedOutputStream).
- /// </summary>
- new ByteString ToByteString();
-
- /// <summary>
- /// Serializes the message to a byte array. This is a trivial wrapper
- /// around WriteTo(ICodedOutputStream).
- /// </summary>
- new byte[] ToByteArray();
+ FieldAccessorTable<T> Fields { get; }
+ // TODO(jonskeet): Descriptor? Or a single property which has "all you need for reflection"?
+ }
+ /// <summary>
+ /// Interface for a Protocol Buffers message, supporting
+ /// basic operations required for serialization.
+ /// </summary>
+ public interface IMessage
+ {
/// <summary>
- /// Serializes the message and writes it to the given stream.
- /// This is just a wrapper around WriteTo(ICodedOutputStream). This
- /// does not flush or close the stream.
+ /// Merges the data from the specified coded input stream with the current message.
/// </summary>
- /// <param name="output"></param>
- new void WriteTo(Stream output);
-
- #endregion
+ /// <remarks>See the user guide for precise merge semantics.</remarks>
+ /// <param name="input"></param>
+ void MergeFrom(CodedInputStream input);
/// <summary>
- /// Creates a builder for the type, but in a weakly typed manner. This
- /// is typically implemented by strongly typed messages by just returning
- /// the result of CreateBuilderForType.
+ /// Writes the data to the given coded output stream.
/// </summary>
- new IBuilder WeakCreateBuilderForType();
+ /// <param name="output">Coded output stream to write the data to. Must not be null.</param>
+ void WriteTo(CodedOutputStream output);
/// <summary>
- /// Creates a builder with the same contents as this message. This
- /// is typically implemented by strongly typed messages by just returning
- /// the result of ToBuilder.
+ /// Calculates the size of this message in Protocol Buffer wire format, in bytes.
/// </summary>
- new IBuilder WeakToBuilder();
-
- new IMessage WeakDefaultInstanceForType { get; }
- }
-
- public interface IMessage<TMessage> : IMessage, IMessageLite<TMessage>
- {
- /// <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.
- /// </summary>
- new TMessage DefaultInstanceForType { get; }
+ /// <returns>The number of bytes required to write this message
+ /// to a coded output stream.</returns>
+ int CalculateSize();
}
/// <summary>
- /// Type-safe interface for all generated messages to implement.
+ /// Generic interface for a Protocol Buffers message,
+ /// where the type parameter is expected to be the same type as
+ /// the implementation class.
/// </summary>
- public interface IMessage<TMessage, TBuilder> : IMessage<TMessage>, IMessageLite<TMessage, TBuilder>
- where TMessage : IMessage<TMessage, TBuilder>
- where TBuilder : IBuilder<TMessage, TBuilder>
+ /// <typeparam name="T">The message type.</typeparam>
+ public interface IMessage<T> : IMessage where T : IMessage<T>
{
- #region Builders
-
/// <summary>
- /// Constructs a new builder for a message of the same type as this message.
+ /// Merges the given message into this one.
/// </summary>
- new TBuilder CreateBuilderForType();
-
- /// <summary>
- /// Creates a builder with the same contents as this current instance.
- /// This is typically implemented by strongly typed messages by just
- /// returning the result of ToBuilder().
- /// </summary>
- new TBuilder ToBuilder();
-
- #endregion
+ /// <remarks>See the user guide for precise merge semantics.</remarks>
+ /// <param name="message">The message to merge with this one. Must not be null.</param>
+ void MergeFrom(T message);
}
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/IMessageLite.cs b/csharp/src/ProtocolBuffers/IMessageLite.cs deleted file mode 100644 index ea5d9940..00000000 --- a/csharp/src/ProtocolBuffers/IMessageLite.cs +++ /dev/null @@ -1,188 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System.IO;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Non-generic interface used for all parts of the API which don't require
- /// any type knowledge.
- /// </summary>
- public partial interface IMessageLite
- {
- /// <summary>
- /// Returns true iff all required fields in the message and all embedded
- /// messages are set.
- /// </summary>
- bool IsInitialized { get; }
-
- /// <summary>
- /// Serializes the message and writes it to the given output stream.
- /// This does not flush or close the stream.
- /// </summary>
- /// <remarks>
- /// Protocol Buffers are not self-delimiting. Therefore, if you write
- /// any more data to the stream after the message, you must somehow ensure
- /// that the parser on the receiving end does not interpret this as being
- /// part of the protocol message. One way of doing this is by writing the size
- /// of the message before the data, then making sure you limit the input to
- /// that size when receiving the data. Alternatively, use WriteDelimitedTo(Stream).
- /// </remarks>
- void WriteTo(ICodedOutputStream output);
-
- /// <summary>
- /// Like WriteTo(Stream) but writes the size of the message as a varint before
- /// writing the data. This allows more data to be written to the stream after the
- /// message without the need to delimit the message data yourself. Use
- /// IBuilder.MergeDelimitedFrom(Stream) or the static method
- /// YourMessageType.ParseDelimitedFrom(Stream) to parse messages written by this method.
- /// </summary>
- /// <param name="output"></param>
- void WriteDelimitedTo(Stream output);
-
- /// <summary>
- /// Returns the number of bytes required to encode this message.
- /// The result is only computed on the first call and memoized after that.
- /// </summary>
- int SerializedSize { get; }
-
- #region Comparison and hashing
-
- /// <summary>
- /// Compares the specified object with this message for equality.
- /// Returns true iff the given object is a message of the same type
- /// (as defined by DescriptorForType) and has identical values
- /// for all its fields.
- /// </summary>
- bool Equals(object other);
-
- /// <summary>
- /// Returns the hash code value for this message.
- /// TODO(jonskeet): Specify the hash algorithm, but better than the Java one!
- /// </summary>
- int GetHashCode();
-
- #endregion
-
- #region Convenience methods
-
- /// <summary>
- /// Converts the message to a string in protocol buffer text format.
- /// This is just a trivial wrapper around TextFormat.PrintToString.
- /// </summary>
- string ToString();
-
- /// <summary>
- /// Converts the message to a string.
- /// </summary>
- void PrintTo(TextWriter writer);
-
- /// <summary>
- /// Serializes the message to a ByteString. This is a trivial wrapper
- /// around WriteTo(ICodedOutputStream).
- /// </summary>
- ByteString ToByteString();
-
- /// <summary>
- /// Serializes the message to a byte array. This is a trivial wrapper
- /// around WriteTo(ICodedOutputStream).
- /// </summary>
- byte[] ToByteArray();
-
- /// <summary>
- /// Serializes the message and writes it to the given stream.
- /// This is just a wrapper around WriteTo(ICodedOutputStream). This
- /// does not flush or close the stream.
- /// </summary>
- /// <param name="output"></param>
- void WriteTo(Stream output);
-
- #endregion
-
- /// <summary>
- /// Creates a builder for the type, but in a weakly typed manner. This
- /// is typically implemented by strongly typed messages by just returning
- /// the result of CreateBuilderForType.
- /// </summary>
- IBuilderLite WeakCreateBuilderForType();
-
- /// <summary>
- /// Creates a builder with the same contents as this message. This
- /// is typically implemented by strongly typed messages by just returning
- /// the result of ToBuilder.
- /// </summary>
- IBuilderLite WeakToBuilder();
-
- IMessageLite WeakDefaultInstanceForType { get; }
- }
-
- public interface IMessageLite<TMessage> : IMessageLite
- {
- /// <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.
- /// </summary>
- TMessage DefaultInstanceForType { get; }
- }
-
- /// <summary>
- /// Type-safe interface for all generated messages to implement.
- /// </summary>
- public interface IMessageLite<TMessage, TBuilder> : IMessageLite<TMessage>
- where TMessage : IMessageLite<TMessage, TBuilder>
- where TBuilder : IBuilderLite<TMessage, TBuilder>
- {
- #region Builders
-
- /// <summary>
- /// Constructs a new builder for a message of the same type as this message.
- /// </summary>
- TBuilder CreateBuilderForType();
-
- /// <summary>
- /// Creates a builder with the same contents as this current instance.
- /// This is typically implemented by strongly typed messages by just
- /// returning the result of ToBuilder().
- /// </summary>
- TBuilder ToBuilder();
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs b/csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs index 67d7b374..97e80cac 100644 --- a/csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs +++ b/csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs @@ -36,7 +36,7 @@ using System.IO;
-namespace Google.ProtocolBuffers
+namespace Google.Protobuf
{
/// <summary>
/// Thrown when a protocol message being parsed is invalid in some way,
diff --git a/csharp/src/ProtocolBuffers/LimitedInputStream.cs b/csharp/src/ProtocolBuffers/LimitedInputStream.cs new file mode 100644 index 00000000..cfbf47de --- /dev/null +++ b/csharp/src/ProtocolBuffers/LimitedInputStream.cs @@ -0,0 +1,78 @@ +using System; +using System.IO; + +namespace Google.Protobuf +{ + /// <summary> + /// Stream implementation which proxies another stream, only allowing a certain amount + /// of data to be read. Note that this is only used to read delimited streams, so it + /// doesn't attempt to implement everything. + /// </summary> + internal sealed class LimitedInputStream : Stream + { + private readonly Stream proxied; + private int bytesLeft; + + internal LimitedInputStream(Stream proxied, int size) + { + this.proxied = proxied; + bytesLeft = size; + } + + public override bool CanRead + { + get { return true; } + } + + public override bool CanSeek + { + get { return false; } + } + + public override bool CanWrite + { + get { return false; } + } + + public override void Flush() + { + } + + public override long Length + { + get { throw new NotSupportedException(); } + } + + public override long Position + { + get { throw new NotSupportedException(); } + set { throw new NotSupportedException(); } + } + + public override int Read(byte[] buffer, int offset, int count) + { + if (bytesLeft > 0) + { + int bytesRead = proxied.Read(buffer, offset, Math.Min(bytesLeft, count)); + bytesLeft -= bytesRead; + return bytesRead; + } + return 0; + } + + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotSupportedException(); + } + + public override void SetLength(long value) + { + throw new NotSupportedException(); + } + + public override void Write(byte[] buffer, int offset, int count) + { + throw new NotSupportedException(); + } + } +} diff --git a/csharp/src/ProtocolBuffers/MessageExtensions.cs b/csharp/src/ProtocolBuffers/MessageExtensions.cs new file mode 100644 index 00000000..57cecfd4 --- /dev/null +++ b/csharp/src/ProtocolBuffers/MessageExtensions.cs @@ -0,0 +1,81 @@ +using System.IO; + +namespace Google.Protobuf +{ + /// <summary> + /// Extension methods on <see cref="IMessage"/> and <see cref="IMessage{T}"/>. + /// </summary> + public static class MessageExtensions + { + public static void MergeFrom(this IMessage message, byte[] data) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(data, "data"); + CodedInputStream input = CodedInputStream.CreateInstance(data); + message.MergeFrom(input); + input.CheckLastTagWas(0); + } + + public static void MergeFrom(this IMessage message, ByteString data) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(data, "data"); + CodedInputStream input = data.CreateCodedInput(); + message.MergeFrom(input); + input.CheckLastTagWas(0); + } + + public static void MergeFrom(this IMessage message, Stream input) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(input, "input"); + CodedInputStream codedInput = CodedInputStream.CreateInstance(input); + message.MergeFrom(codedInput); + codedInput.CheckLastTagWas(0); + } + + public static void MergeDelimitedFrom(this IMessage message, Stream input) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(input, "input"); + int size = (int)CodedInputStream.ReadRawVarint32(input); + Stream limitedStream = new LimitedInputStream(input, size); + message.MergeFrom(limitedStream); + } + + public static byte[] ToByteArray(this IMessage message) + { + ThrowHelper.ThrowIfNull(message, "message"); + byte[] result = new byte[message.CalculateSize()]; + CodedOutputStream output = CodedOutputStream.CreateInstance(result); + message.WriteTo(output); + output.CheckNoSpaceLeft(); + return result; + } + + public static void WriteTo(this IMessage message, Stream output) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(output, "output"); + CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output); + message.WriteTo(codedOutput); + codedOutput.Flush(); + } + + public static void WriteDelimitedTo(this IMessage message, Stream output) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(output, "output"); + CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output); + codedOutput.WriteRawVarint32((uint)message.CalculateSize()); + message.WriteTo(codedOutput); + codedOutput.Flush(); + } + + public static ByteString ToByteString(this IMessage message) + { + ThrowHelper.ThrowIfNull(message, "message"); + return ByteString.AttachBytes(message.ToByteArray()); + } + } +} diff --git a/csharp/src/ProtocolBuffers/MessageParser.cs b/csharp/src/ProtocolBuffers/MessageParser.cs new file mode 100644 index 00000000..18cda2dc --- /dev/null +++ b/csharp/src/ProtocolBuffers/MessageParser.cs @@ -0,0 +1,90 @@ +using System; +using System.IO; + +namespace Google.Protobuf +{ + /// <summary> + /// A parser for a specific message type. + /// </summary> + /// <remarks> + /// <p> + /// This delegates most behavior to the + /// <see cref="IMessage.MergeFrom"/> implementation within the original type, but + /// provides convenient overloads to parse from a variety of sources. + /// </p> + /// <p> + /// Most applications will never need to create their own instances of this type; + /// instead, use the static <c>Parser</c> property of a generated message type to obtain a + /// parser for that type. + /// </p> + /// </remarks> + /// <typeparam name="T">The type of message to be parsed.</typeparam> + public sealed class MessageParser<T> where T : IMessage<T> + { + private readonly Func<T> factory; + + /// <summary> + /// Creates a new parser. + /// </summary> + /// <remarks> + /// The factory method is effectively an optimization over using a generic constraint + /// to require a parameterless constructor: delegates are significantly faster to execute. + /// </remarks> + /// <param name="factory">Function to invoke when a new, empty message is required.</param> + public MessageParser(Func<T> factory) + { + this.factory = factory; + } + + /// <summary> + /// Creates a template instance ready for population. + /// </summary> + /// <returns>An empty message.</returns> + internal T CreateTemplate() + { + return factory(); + } + + /// <summary> + /// Parses a message from a byte array. + /// </summary> + /// <param name="data">The byte array containing the message. Must not be null.</param> + /// <returns>The newly parsed message.</returns> + public T ParseFrom(byte[] data) + { + ThrowHelper.ThrowIfNull(data, "data"); + T message = factory(); + message.MergeFrom(data); + return message; + } + + public T ParseFrom(ByteString data) + { + ThrowHelper.ThrowIfNull(data, "data"); + T message = factory(); + message.MergeFrom(data); + return message; + } + + public T ParseFrom(Stream input) + { + T message = factory(); + message.MergeFrom(input); + return message; + } + + public T ParseDelimitedFrom(Stream input) + { + T message = factory(); + message.MergeDelimitedFrom(input); + return message; + } + + public T ParseFrom(CodedInputStream input) + { + T message = factory(); + message.MergeFrom(input); + return message; + } + } +} diff --git a/csharp/src/ProtocolBuffers/MessageStreamIterator.cs b/csharp/src/ProtocolBuffers/MessageStreamIterator.cs deleted file mode 100644 index 32d697ca..00000000 --- a/csharp/src/ProtocolBuffers/MessageStreamIterator.cs +++ /dev/null @@ -1,170 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Iterates over data created using a <see cref="MessageStreamWriter{T}" />.
- /// Unlike MessageStreamWriter, this class is not usually constructed directly with
- /// a stream; instead it is provided with a way of opening a stream when iteration
- /// is started. The stream is closed when the iteration is completed or the enumerator
- /// is disposed. (This occurs naturally when using <c>foreach</c>.)
- /// </summary>
- public class MessageStreamIterator<TMessage> : IEnumerable<TMessage>
- where TMessage : IMessage<TMessage>
- {
- private readonly StreamProvider streamProvider;
- private readonly ExtensionRegistry extensionRegistry;
- private readonly int sizeLimit;
-
- /// <summary>
- /// The default instance of TMessage type used to construct builders while reading
- /// </summary>
- private static readonly TMessage defaultMessageInstance = CreateDefaultInstance();
- /// <summary>
- /// Any exception (within reason) thrown in type ctor is caught and rethrown in the constructor.
- /// This makes life a lot simpler for the caller.
- /// </summary>
- private static Exception typeInitializationException;
-
-
- /// <summary>
- /// Vastly simplified the reflection to simply obtain the default instance and use it to construct
- /// the weak builder while simply casting the result. Ideally this class should have required a
- /// TBuilder type argument with a new() constraint to construct the initial instance thereby the
- /// reflection could be eliminated.
- /// </summary>
- private static TMessage CreateDefaultInstance()
- {
- try
- {
- return (TMessage)typeof(TMessage)
- .GetProperty("DefaultInstance", typeof(TMessage), new Type[0])
- .GetValue(null, null);
- }
- catch (Exception e)
- {
- typeInitializationException = e;
- return default(TMessage);
- }
- }
-
- private static readonly uint ExpectedTag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
-
- private MessageStreamIterator(StreamProvider streamProvider, ExtensionRegistry extensionRegistry, int sizeLimit)
- {
- if (ReferenceEquals(defaultMessageInstance, null))
- {
- throw new System.Reflection.TargetInvocationException(typeInitializationException);
- }
- this.streamProvider = streamProvider;
- this.extensionRegistry = extensionRegistry;
- this.sizeLimit = sizeLimit;
- }
-
- private MessageStreamIterator(StreamProvider streamProvider, ExtensionRegistry extensionRegistry)
- : this(streamProvider, extensionRegistry, CodedInputStream.DefaultSizeLimit)
- {
- }
-
- /// <summary>
- /// Creates a new instance which uses the same stream provider as this one,
- /// but the specified extension registry.
- /// </summary>
- public MessageStreamIterator<TMessage> WithExtensionRegistry(ExtensionRegistry newRegistry)
- {
- return new MessageStreamIterator<TMessage>(streamProvider, newRegistry, sizeLimit);
- }
-
- /// <summary>
- /// Creates a new instance which uses the same stream provider and extension registry as this one,
- /// but with the specified size limit. Note that this must be big enough for the largest message
- /// and the tag and size preceding it.
- /// </summary>
- public MessageStreamIterator<TMessage> WithSizeLimit(int newSizeLimit)
- {
- return new MessageStreamIterator<TMessage>(streamProvider, extensionRegistry, newSizeLimit);
- }
-
-#if CLIENTPROFILE
- public static MessageStreamIterator<TMessage> FromFile(string file)
- {
- return new MessageStreamIterator<TMessage>(() => File.OpenRead(file), ExtensionRegistry.Empty);
- }
-#endif
-
- public static MessageStreamIterator<TMessage> FromStreamProvider(StreamProvider streamProvider)
- {
- return new MessageStreamIterator<TMessage>(streamProvider, ExtensionRegistry.Empty);
- }
-
- public IEnumerator<TMessage> GetEnumerator()
- {
- using (Stream stream = streamProvider())
- {
- CodedInputStream input = CodedInputStream.CreateInstance(stream);
- input.SetSizeLimit(sizeLimit);
- uint tag;
- string name;
- while (input.ReadTag(out tag, out name))
- {
- if ((tag == 0 && name == "item") || (tag == ExpectedTag))
- {
- IBuilder builder = defaultMessageInstance.WeakCreateBuilderForType();
- input.ReadMessage(builder, extensionRegistry);
- yield return (TMessage)builder.WeakBuild();
- }
- else
- {
- throw InvalidProtocolBufferException.InvalidMessageStreamTag();
- }
-
- input.ResetSizeCounter();
- }
- }
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/MessageStreamWriter.cs b/csharp/src/ProtocolBuffers/MessageStreamWriter.cs deleted file mode 100644 index 3430e13c..00000000 --- a/csharp/src/ProtocolBuffers/MessageStreamWriter.cs +++ /dev/null @@ -1,70 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System.IO;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Writes multiple messages to the same stream. Each message is written
- /// as if it were an element of a repeated field 1 in a larger protocol buffer.
- /// This class takes no ownership of the stream it is given; it never closes the
- /// stream.
- /// </summary>
- public sealed class MessageStreamWriter<T> where T : IMessage<T>
- {
- private readonly CodedOutputStream codedOutput;
-
- /// <summary>
- /// Creates an instance which writes to the given stream.
- /// </summary>
- /// <param name="output">Stream to write messages to.</param>
- public MessageStreamWriter(Stream output)
- {
- codedOutput = CodedOutputStream.CreateInstance(output);
- }
-
- public void Write(T message)
- {
- codedOutput.WriteMessage(1, "item", message);
- }
-
- public void Flush()
- {
- codedOutput.Flush();
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/MessageUtil.cs b/csharp/src/ProtocolBuffers/MessageUtil.cs deleted file mode 100644 index d120d209..00000000 --- a/csharp/src/ProtocolBuffers/MessageUtil.cs +++ /dev/null @@ -1,109 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Reflection;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Utilities for arbitrary messages of an unknown type. This class does not use
- /// generics precisely because it is designed for dynamically discovered types.
- /// </summary>
- public static class MessageUtil
- {
- /// <summary>
- /// Returns the default message for the given type. If an exception is thrown
- /// (directly from this code), the message will be suitable to be displayed to a user.
- /// </summary>
- /// <param name="type"></param>
- /// <exception cref="ArgumentNullException">The type parameter is null.</exception>
- /// <exception cref="ArgumentException">The type doesn't implement IMessage, or doesn't
- /// have a static DefaultMessage property of the same type, or is generic or abstract.</exception>
- /// <returns></returns>
- public static IMessage GetDefaultMessage(Type type)
- {
- if (type == null)
- {
- throw new ArgumentNullException("type", "No type specified.");
- }
- if (type.IsAbstract || type.IsGenericTypeDefinition)
- {
- throw new ArgumentException("Unable to get a default message for an abstract or generic type (" +
- type.FullName + ")");
- }
- if (!typeof(IMessage).IsAssignableFrom(type))
- {
- throw new ArgumentException("Unable to get a default message for non-message type (" + type.FullName +
- ")");
- }
- PropertyInfo property = type.GetProperty("DefaultInstance",
- BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
- if (property == null)
- {
- throw new ArgumentException(type.FullName + " doesn't have a static DefaultInstance property");
- }
- if (property.PropertyType != type)
- {
- throw new ArgumentException(type.FullName + ".DefaultInstance property is of the wrong type");
- }
- return (IMessage) property.GetValue(null, null);
- }
-
- /// <summary>
- /// Returns the default message for the type with the given name. This is just
- /// a convenience wrapper around calling Type.GetType and then GetDefaultMessage.
- /// If an exception is thrown, the message will be suitable to be displayed to a user.
- /// </summary>
- /// <param name="typeName"></param>
- /// <exception cref="ArgumentNullException">The typeName parameter is null.</exception>
- /// <exception cref="ArgumentException">The type doesn't implement IMessage, or doesn't
- /// have a static DefaultMessage property of the same type, or can't be found.</exception>
- public static IMessage GetDefaultMessage(string typeName)
- {
- if (typeName == null)
- {
- throw new ArgumentNullException("typeName", "No type name specified.");
- }
- Type type = Type.GetType(typeName);
- if (type == null)
- {
- throw new ArgumentException("Unable to load type " + typeName);
- }
- return GetDefaultMessage(type);
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/NameHelpers.cs b/csharp/src/ProtocolBuffers/NameHelpers.cs deleted file mode 100644 index 80a1f9aa..00000000 --- a/csharp/src/ProtocolBuffers/NameHelpers.cs +++ /dev/null @@ -1,140 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Text.RegularExpressions;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Helpers for converting names to pascal case etc.
- /// </summary>
- public class NameHelpers
- {
- /// <summary>
- /// All characters that are not alpha-numeric
- /// </summary>
- private static readonly Regex NonAlphaNumericCharacters = new Regex(@"[^a-zA-Z0-9]+");
-
- /// <summary>
- /// Matches lower-case character that follow either an underscore, or a number
- /// </summary>
- private static readonly Regex UnderscoreOrNumberWithLowerCase = new Regex(@"[0-9_][a-z]");
-
- /// <summary>
- /// Removes non alpha numeric characters while capitalizing letters that follow
- /// a number or underscore. The first letter is always upper case.
- /// </summary>
- public static string UnderscoresToPascalCase(string input)
- {
- string name = UnderscoresToUpperCase(input);
-
- // Pascal case always begins with upper-case letter
- if (Char.IsLower(name[0]))
- {
- char[] chars = name.ToCharArray();
- chars[0] = char.ToUpper(chars[0]);
- return new string(chars);
- }
- return name;
- }
-
- /// <summary>
- /// Removes non alpha numeric characters while capitalizing letters that follow
- /// a number or underscore. The first letter is always lower case.
- /// </summary>
- public static string UnderscoresToCamelCase(string input)
- {
- string name = UnderscoresToUpperCase(input);
-
- // Camel case always begins with lower-case letter
- if (Char.IsUpper(name[0]))
- {
- char[] chars = name.ToCharArray();
- chars[0] = char.ToLower(chars[0]);
- return new string(chars);
- }
- return name;
- }
-
- /// <summary>
- /// Capitalizes any characters following an '_' or a number '0' - '9' and removes
- /// all non alpha-numeric characters. If the resulting string begins with a number
- /// an '_' will be prefixed.
- /// </summary>
- private static string UnderscoresToUpperCase(string input)
- {
- string name = UnderscoreOrNumberWithLowerCase.Replace(input, x => x.Value.ToUpper());
- name = NonAlphaNumericCharacters.Replace(name, String.Empty);
-
- if (name.Length == 0)
- {
- throw new ArgumentException(String.Format("The field name '{0}' is invalid.", input));
- }
-
- // Fields can not start with a number
- if (Char.IsNumber(name[0]))
- {
- name = '_' + name;
- }
-
- return name;
- }
-
- internal static string StripProto(string text)
- {
- if (!StripSuffix(ref text, ".protodevel"))
- {
- StripSuffix(ref text, ".proto");
- }
- return text;
- }
-
- /// <summary>
- /// Attempts to strip a suffix from a string, returning whether
- /// or not the suffix was actually present.
- /// </summary>
- public static bool StripSuffix(ref string text, string suffix)
- {
- if (text.EndsWith(suffix))
- {
- text = text.Substring(0, text.Length - suffix.Length);
- return true;
- }
- return false;
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index 7dc8f665..33a32ff2 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -8,8 +8,8 @@ <ProjectGuid>{6908BDCE-D925-43F3-94AC-A531E6DF2591}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Google.ProtocolBuffers</RootNamespace>
- <AssemblyName>Google.ProtocolBuffers</AssemblyName>
+ <RootNamespace>Google.Protobuf</RootNamespace>
+ <AssemblyName>Google.Protobuf</AssemblyName>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile92</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
@@ -25,7 +25,7 @@ <Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<IntermediateOutputPath>obj\Debug\</IntermediateOutputPath>
- <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
+ <DocumentationFile>bin\Debug\Google.Protobuf.xml</DocumentationFile>
<NoWarn>1591, 1570, 1571, 1572, 1573, 1574</NoWarn>
<DefineConstants>DEBUG;TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate)</DefineConstants>
<ErrorReport>prompt</ErrorReport>
@@ -52,22 +52,17 @@ <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <Compile Include="AbstractBuilder.cs" />
- <Compile Include="AbstractBuilderLite.cs" />
- <Compile Include="AbstractMessage.cs" />
- <Compile Include="AbstractMessageLite.cs" />
<Compile Include="ByteArray.cs" />
<Compile Include="ByteString.cs" />
<Compile Include="Collections\Enumerables.cs" />
- <Compile Include="Collections\IPopsicleList.cs" />
- <Compile Include="Collections\PopsicleList.cs" />
<Compile Include="CodedOutputStream.ComputeSize.cs" />
- <Compile Include="Delegates.cs" />
<Compile Include="CodedInputStream.cs" />
<Compile Include="CodedOutputStream.cs" />
<Compile Include="Collections\Dictionaries.cs" />
<Compile Include="Collections\Lists.cs" />
<Compile Include="Collections\ReadOnlyDictionary.cs" />
+ <Compile Include="Collections\RepeatedField.cs" />
+ <Compile Include="Collections\RepeatedFieldExtensions.cs" />
<Compile Include="DescriptorProtos\DescriptorProtoFile.cs" />
<Compile Include="DescriptorProtos\IDescriptorProto.cs" />
<Compile Include="DescriptorProtos\PartialClasses.cs" />
@@ -89,55 +84,22 @@ <Compile Include="Descriptors\MethodDescriptor.cs" />
<Compile Include="Descriptors\PackageDescriptor.cs" />
<Compile Include="Descriptors\ServiceDescriptor.cs" />
- <Compile Include="DynamicMessage.cs" />
- <Compile Include="EnumLite.cs" />
- <Compile Include="ExtendableBuilder.cs" />
- <Compile Include="ExtendableBuilderLite.cs" />
- <Compile Include="ExtendableMessage.cs" />
- <Compile Include="ExtendableMessageLite.cs" />
- <Compile Include="ExtensionInfo.cs" />
- <Compile Include="ExtensionRegistry.cs" />
- <Compile Include="ExtensionRegistryLite.cs" />
+ <Compile Include="FrameworkPortability.cs" />
+ <Compile Include="MessageExtensions.cs" />
+ <Compile Include="FieldAccess\FieldAccessorBase.cs" />
<Compile Include="FieldAccess\ReflectionUtil.cs" />
- <Compile Include="FieldAccess\SingleEnumAccessor.cs" />
- <Compile Include="FieldAccess\SingleMessageAccessor.cs" />
- <Compile Include="FieldAccess\SinglePrimitiveAccessor.cs" />
- <Compile Include="FieldAccess\RepeatedPrimitiveAccessor.cs" />
- <Compile Include="FieldAccess\RepeatedEnumAccessor.cs" />
+ <Compile Include="FieldAccess\RepeatedFieldAccessor.cs" />
+ <Compile Include="FieldAccess\SingleFieldAccessor.cs" />
<Compile Include="FieldAccess\IFieldAccessor.cs" />
<Compile Include="FieldAccess\FieldAccessorTable.cs" />
- <Compile Include="FieldAccess\RepeatedMessageAccessor.cs" />
<Compile Include="FieldAccess\OneofAccessor.cs" />
- <Compile Include="FieldSet.cs" />
- <Compile Include="FrameworkPortability.cs" />
- <Compile Include="GeneratedBuilder.cs" />
- <Compile Include="GeneratedBuilderLite.cs" />
- <Compile Include="GeneratedExtensionLite.cs" />
- <Compile Include="GeneratedMessageLite.cs" />
- <Compile Include="GeneratedRepeatExtension.cs" />
- <Compile Include="GeneratedSingleExtension.cs" />
- <Compile Include="GeneratedMessage.cs" />
- <Compile Include="IBuilder.cs" />
- <Compile Include="GeneratedExtensionBase.cs" />
- <Compile Include="IBuilderLite.cs" />
- <Compile Include="ICodedInputStream.cs" />
- <Compile Include="ICodedOutputStream.cs" />
<Compile Include="IMessage.cs" />
- <Compile Include="IMessageLite.cs" />
<Compile Include="InvalidProtocolBufferException.cs" />
- <Compile Include="MessageStreamIterator.cs" />
- <Compile Include="MessageStreamWriter.cs" />
- <Compile Include="MessageUtil.cs" />
- <Compile Include="NameHelpers.cs" />
+ <Compile Include="LimitedInputStream.cs" />
+ <Compile Include="MessageParser.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="SortedList.cs" />
- <Compile Include="TextFormat.cs" />
<Compile Include="TextGenerator.cs" />
- <Compile Include="TextTokenizer.cs" />
<Compile Include="ThrowHelper.cs" />
- <Compile Include="UninitializedMessageException.cs" />
- <Compile Include="UnknownField.cs" />
- <Compile Include="UnknownFieldSet.cs" />
<Compile Include="WireFormat.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
@@ -148,4 +110,4 @@ <Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffersLite.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.csproj deleted file mode 100644 index d0912a6b..00000000 --- a/csharp/src/ProtocolBuffers/ProtocolBuffersLite.csproj +++ /dev/null @@ -1,99 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{6969BDCE-D925-43F3-94AC-A531E6DF2591}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Google.ProtocolBuffers</RootNamespace>
- <AssemblyName>Google.ProtocolBuffersLite</AssemblyName>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <TargetFrameworkProfile>Profile92</TargetFrameworkProfile>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <SignAssembly>true</SignAssembly>
- <AssemblyOriginatorKeyFile>..\..\keys\Google.ProtocolBuffers.snk</AssemblyOriginatorKeyFile>
- <OldToolsVersion>3.5</OldToolsVersion>
- <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug</OutputPath>
- <IntermediateOutputPath>obj\Debug\</IntermediateOutputPath>
- <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
- <NoWarn>1591, 1570, 1571, 1572, 1573, 1574</NoWarn>
- <DefineConstants>DEBUG;TRACE;LITE;$(EnvironmentFlavor);$(EnvironmentTemplate)</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <NoStdLib>true</NoStdLib>
- <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release</OutputPath>
- <IntermediateOutputPath>obj\Release\</IntermediateOutputPath>
- <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
- <NoWarn>1591, 1570, 1571, 1572, 1573, 1574</NoWarn>
- <DefineConstants>TRACE;LITE;$(EnvironmentFlavor);$(EnvironmentTemplate)</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <NoStdLib>true</NoStdLib>
- <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="mscorlib" />
- <Reference Include="System" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="AbstractBuilderLite.cs" />
- <Compile Include="AbstractMessageLite.cs" />
- <Compile Include="ByteArray.cs" />
- <Compile Include="CodedOutputStream.ComputeSize.cs" />
- <Compile Include="Collections\Dictionaries.cs" />
- <Compile Include="Collections\Enumerables.cs" />
- <Compile Include="Collections\IPopsicleList.cs" />
- <Compile Include="Collections\Lists.cs" />
- <Compile Include="Collections\PopsicleList.cs" />
- <Compile Include="Collections\ReadOnlyDictionary.cs" />
- <Compile Include="Descriptors\FieldMappingAttribute.cs" />
- <Compile Include="Descriptors\FieldType.cs" />
- <Compile Include="Descriptors\MappedType.cs" />
- <Compile Include="EnumLite.cs" />
- <Compile Include="ExtendableBuilderLite.cs" />
- <Compile Include="ExtendableMessageLite.cs" />
- <Compile Include="FieldSet.cs" />
- <Compile Include="FrameworkPortability.cs" />
- <Compile Include="GeneratedBuilderLite.cs" />
- <Compile Include="GeneratedExtensionLite.cs" />
- <Compile Include="GeneratedMessageLite.cs" />
- <Compile Include="ICodedInputStream.cs" />
- <Compile Include="ICodedOutputStream.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="ByteString.cs" />
- <Compile Include="CodedInputStream.cs" />
- <Compile Include="CodedOutputStream.cs" />
- <Compile Include="ExtensionRegistryLite.cs" />
- <Compile Include="IBuilderLite.cs" />
- <Compile Include="IMessageLite.cs" />
- <Compile Include="InvalidProtocolBufferException.cs" />
- <Compile Include="SortedList.cs" />
- <Compile Include="ThrowHelper.cs" />
- <Compile Include="UninitializedMessageException.cs" />
- <Compile Include="WireFormat.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/SortedList.cs b/csharp/src/ProtocolBuffers/SortedList.cs deleted file mode 100644 index 2dd7da92..00000000 --- a/csharp/src/ProtocolBuffers/SortedList.cs +++ /dev/null @@ -1,167 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-#if NOSORTEDLIST
-using System.Collections;
-using System.Collections.Generic;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Dictionary implementation which always yields keys in sorted order.
- /// This is not particularly efficient: it wraps a normal dictionary
- /// for most operations, but sorts by key when either iterating or
- /// fetching the Keys/Values properties.
- /// </summary>
- internal sealed class SortedList<TKey, TValue> : IDictionary<TKey, TValue>
- {
- private readonly IDictionary<TKey, TValue> wrapped = new Dictionary<TKey, TValue>();
-
- public SortedList()
- {
- }
-
- public SortedList(IDictionary<TKey, TValue> dictionary)
- {
- foreach (KeyValuePair<TKey, TValue> entry in dictionary)
- {
- Add(entry.Key, entry.Value);
- }
- }
-
- public void Add(TKey key, TValue value)
- {
- wrapped.Add(key, value);
- }
-
- public bool ContainsKey(TKey key)
- {
- return wrapped.ContainsKey(key);
- }
-
- public ICollection<TKey> Keys
- {
- get
- {
- List<TKey> keys = new List<TKey>(wrapped.Count);
- foreach (var pair in this)
- {
- keys.Add(pair.Key);
- }
- return keys;
- }
- }
-
- public bool Remove(TKey key)
- {
- return wrapped.Remove(key);
- }
-
- public bool TryGetValue(TKey key, out TValue value)
- {
- return wrapped.TryGetValue(key, out value);
- }
-
- public ICollection<TValue> Values
- {
- get
- {
- List<TValue> values = new List<TValue>(wrapped.Count);
- foreach (var pair in this)
- {
- values.Add(pair.Value);
- }
- return values;
- }
- }
-
- public TValue this[TKey key]
- {
- get { return wrapped[key]; }
- set { wrapped[key] = value; }
- }
-
- public void Add(KeyValuePair<TKey, TValue> item)
- {
- wrapped.Add(item);
- }
-
- public void Clear()
- {
- wrapped.Clear();
- }
-
- public bool Contains(KeyValuePair<TKey, TValue> item)
- {
- return wrapped.Contains(item);
- }
-
- public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
- {
- wrapped.CopyTo(array, arrayIndex);
- }
-
- public int Count
- {
- get { return wrapped.Count; }
- }
-
- public bool IsReadOnly
- {
- get { return wrapped.IsReadOnly; }
- }
-
- public bool Remove(KeyValuePair<TKey, TValue> item)
- {
- return wrapped.Remove(item);
- }
-
- public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
- {
- IComparer<TKey> comparer = Comparer<TKey>.Default;
- var list = new List<KeyValuePair<TKey, TValue>>(wrapped);
- list.Sort((x, y) => comparer.Compare(x.Key, y.Key));
- return list.GetEnumerator();
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
-}
-
-#endif
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/TextFormat.cs b/csharp/src/ProtocolBuffers/TextFormat.cs deleted file mode 100644 index 6a9180f3..00000000 --- a/csharp/src/ProtocolBuffers/TextFormat.cs +++ /dev/null @@ -1,893 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Text;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Provides ASCII text formatting support for messages.
- /// TODO(jonskeet): Support for alternative line endings.
- /// (Easy to print, via TextGenerator. Not sure about parsing.)
- /// </summary>
- public static class TextFormat
- {
- /// <summary>
- /// Outputs a textual representation of the Protocol Message supplied into
- /// the parameter output.
- /// </summary>
- public static void Print(IMessage message, TextWriter output)
- {
- TextGenerator generator = new TextGenerator(output, "\n");
- Print(message, generator);
- }
-
- /// <summary>
- /// Outputs a textual representation of the Protocol Message builder supplied into
- /// the parameter output.
- /// </summary>
- public static void Print(IBuilder builder, TextWriter output)
- {
- TextGenerator generator = new TextGenerator(output, "\n");
- Print(builder, generator);
- }
-
- /// <summary>
- /// Outputs a textual representation of <paramref name="fields" /> to <paramref name="output"/>.
- /// </summary>
- public static void Print(UnknownFieldSet fields, TextWriter output)
- {
- TextGenerator generator = new TextGenerator(output, "\n");
- PrintUnknownFields(fields, generator);
- }
-
- public static string PrintToString(IMessage message)
- {
- StringWriter text = new StringWriter();
- Print(message, text);
- return text.ToString();
- }
-
- public static string PrintToString(IBuilder builder)
- {
- StringWriter text = new StringWriter();
- Print(builder, text);
- return text.ToString();
- }
-
- public static string PrintToString(UnknownFieldSet fields)
- {
- StringWriter text = new StringWriter();
- Print(fields, text);
- return text.ToString();
- }
-
- private static void Print(IMessage message, TextGenerator generator)
- {
- foreach (KeyValuePair<FieldDescriptor, object> entry in message.AllFields)
- {
- PrintField(entry.Key, entry.Value, generator);
- }
- PrintUnknownFields(message.UnknownFields, generator);
- }
-
- private static void Print(IBuilder message, TextGenerator generator)
- {
- foreach (KeyValuePair<FieldDescriptor, object> entry in message.AllFields)
- {
- PrintField(entry.Key, entry.Value, generator);
- }
- PrintUnknownFields(message.UnknownFields, generator);
- }
-
- internal static void PrintField(FieldDescriptor field, object value, TextGenerator generator)
- {
- if (field.IsRepeated)
- {
- // Repeated field. Print each element.
- foreach (object element in (IEnumerable) value)
- {
- PrintSingleField(field, element, generator);
- }
- }
- else
- {
- PrintSingleField(field, value, generator);
- }
- }
-
- private static void PrintSingleField(FieldDescriptor field, Object value, TextGenerator generator)
- {
- if (field.IsExtension)
- {
- generator.Print("[");
- // We special-case MessageSet elements for compatibility with proto1.
- if (field.ContainingType.Options.MessageSetWireFormat
- && field.FieldType == FieldType.Message
- && field.IsOptional
- // object equality (TODO(jonskeet): Work out what this comment means!)
- && field.ExtensionScope == field.MessageType)
- {
- generator.Print(field.MessageType.FullName);
- }
- else
- {
- generator.Print(field.FullName);
- }
- generator.Print("]");
- }
- else
- {
- if (field.FieldType == FieldType.Group)
- {
- // Groups must be serialized with their original capitalization.
- generator.Print(field.MessageType.Name);
- }
- else
- {
- generator.Print(field.Name);
- }
- }
-
- if (field.MappedType == MappedType.Message)
- {
- generator.Print(" {\n");
- generator.Indent();
- }
- else
- {
- generator.Print(": ");
- }
-
- PrintFieldValue(field, value, generator);
-
- if (field.MappedType == MappedType.Message)
- {
- generator.Outdent();
- generator.Print("}");
- }
- generator.Print("\n");
- }
-
- private static void PrintFieldValue(FieldDescriptor field, object value, TextGenerator generator)
- {
- switch (field.FieldType)
- {
- // The Float and Double types must specify the "r" format to preserve their precision, otherwise,
- // the double to/from string will trim the precision to 6 places. As with other numeric formats
- // below, always use the invariant culture so it's predictable.
- case FieldType.Float:
- generator.Print(((float)value).ToString("r", FrameworkPortability.InvariantCulture));
- break;
- case FieldType.Double:
- generator.Print(((double)value).ToString("r", FrameworkPortability.InvariantCulture));
- break;
-
- case FieldType.Int32:
- case FieldType.Int64:
- case FieldType.SInt32:
- case FieldType.SInt64:
- case FieldType.SFixed32:
- case FieldType.SFixed64:
- case FieldType.UInt32:
- case FieldType.UInt64:
- case FieldType.Fixed32:
- case FieldType.Fixed64:
- // The simple Object.ToString converts using the current culture.
- // We want to always use the invariant culture so it's predictable.
- generator.Print(((IConvertible)value).ToString(FrameworkPortability.InvariantCulture));
- break;
- case FieldType.Bool:
- // Explicitly use the Java true/false
- generator.Print((bool) value ? "true" : "false");
- break;
-
- case FieldType.String:
- generator.Print("\"");
- generator.Print(EscapeText((string) value));
- generator.Print("\"");
- break;
-
- case FieldType.Bytes:
- {
- generator.Print("\"");
- generator.Print(EscapeBytes((ByteString) value));
- generator.Print("\"");
- break;
- }
-
- case FieldType.Enum:
- {
- if (value is IEnumLite && !(value is EnumValueDescriptor))
- {
- throw new NotSupportedException("Lite enumerations are not supported.");
- }
- generator.Print(((EnumValueDescriptor) value).Name);
- break;
- }
-
- case FieldType.Message:
- case FieldType.Group:
- if (value is IMessageLite && !(value is IMessage))
- {
- throw new NotSupportedException("Lite messages are not supported.");
- }
- Print((IMessage) value, generator);
- break;
- }
- }
-
- private static void PrintUnknownFields(UnknownFieldSet unknownFields, TextGenerator generator)
- {
- foreach (KeyValuePair<int, UnknownField> entry in unknownFields.FieldDictionary)
- {
- String prefix = entry.Key.ToString() + ": ";
- UnknownField field = entry.Value;
-
- foreach (ulong value in field.VarintList)
- {
- generator.Print(prefix);
- generator.Print(value.ToString());
- generator.Print("\n");
- }
- foreach (uint value in field.Fixed32List)
- {
- generator.Print(prefix);
- generator.Print(string.Format("0x{0:x8}", value));
- generator.Print("\n");
- }
- foreach (ulong value in field.Fixed64List)
- {
- generator.Print(prefix);
- generator.Print(string.Format("0x{0:x16}", value));
- generator.Print("\n");
- }
- foreach (ByteString value in field.LengthDelimitedList)
- {
- generator.Print(entry.Key.ToString());
- generator.Print(": \"");
- generator.Print(EscapeBytes(value));
- generator.Print("\"\n");
- }
- foreach (UnknownFieldSet value in field.GroupList)
- {
- generator.Print(entry.Key.ToString());
- generator.Print(" {\n");
- generator.Indent();
- PrintUnknownFields(value, generator);
- generator.Outdent();
- generator.Print("}\n");
- }
- }
- }
-
- public static ulong ParseUInt64(string text)
- {
- return (ulong) ParseInteger(text, false, true);
- }
-
- public static long ParseInt64(string text)
- {
- return ParseInteger(text, true, true);
- }
-
- public static uint ParseUInt32(string text)
- {
- return (uint) ParseInteger(text, false, false);
- }
-
- public static int ParseInt32(string text)
- {
- return (int) ParseInteger(text, true, false);
- }
-
- public static float ParseFloat(string text)
- {
- switch (text)
- {
- case "-inf":
- case "-infinity":
- case "-inff":
- case "-infinityf":
- return float.NegativeInfinity;
- case "inf":
- case "infinity":
- case "inff":
- case "infinityf":
- return float.PositiveInfinity;
- case "nan":
- case "nanf":
- return float.NaN;
- default:
- return float.Parse(text, FrameworkPortability.InvariantCulture);
- }
- }
-
- public static double ParseDouble(string text)
- {
- switch (text)
- {
- case "-inf":
- case "-infinity":
- return double.NegativeInfinity;
- case "inf":
- case "infinity":
- return double.PositiveInfinity;
- case "nan":
- return double.NaN;
- default:
- return double.Parse(text, FrameworkPortability.InvariantCulture);
- }
- }
-
- /// <summary>
- /// Parses an integer in hex (leading 0x), decimal (no prefix) or octal (leading 0).
- /// Only a negative sign is permitted, and it must come before the radix indicator.
- /// </summary>
- private static long ParseInteger(string text, bool isSigned, bool isLong)
- {
- string original = text;
- bool negative = false;
- if (text.StartsWith("-"))
- {
- if (!isSigned)
- {
- throw new FormatException("Number must be positive: " + original);
- }
- negative = true;
- text = text.Substring(1);
- }
-
- int radix = 10;
- if (text.StartsWith("0x"))
- {
- radix = 16;
- text = text.Substring(2);
- }
- else if (text.StartsWith("0"))
- {
- radix = 8;
- }
-
- ulong result;
- try
- {
- // Workaround for https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=278448
- // We should be able to use Convert.ToUInt64 for all cases.
- result = radix == 10 ? ulong.Parse(text) : Convert.ToUInt64(text, radix);
- }
- catch (OverflowException)
- {
- // Convert OverflowException to FormatException so there's a single exception type this method can throw.
- string numberDescription = string.Format("{0}-bit {1}signed integer", isLong ? 64 : 32,
- isSigned ? "" : "un");
- throw new FormatException("Number out of range for " + numberDescription + ": " + original);
- }
-
- if (negative)
- {
- ulong max = isLong ? 0x8000000000000000UL : 0x80000000L;
- if (result > max)
- {
- string numberDescription = string.Format("{0}-bit signed integer", isLong ? 64 : 32);
- throw new FormatException("Number out of range for " + numberDescription + ": " + original);
- }
- return -((long) result);
- }
- else
- {
- ulong max = isSigned
- ? (isLong ? (ulong) long.MaxValue : int.MaxValue)
- : (isLong ? ulong.MaxValue : uint.MaxValue);
- if (result > max)
- {
- string numberDescription = string.Format("{0}-bit {1}signed integer", isLong ? 64 : 32,
- isSigned ? "" : "un");
- throw new FormatException("Number out of range for " + numberDescription + ": " + original);
- }
- return (long) result;
- }
- }
-
- /// <summary>
- /// Tests a character to see if it's an octal digit.
- /// </summary>
- private static bool IsOctal(char c)
- {
- return '0' <= c && c <= '7';
- }
-
- /// <summary>
- /// Tests a character to see if it's a hex digit.
- /// </summary>
- private static bool IsHex(char c)
- {
- return ('0' <= c && c <= '9') ||
- ('a' <= c && c <= 'f') ||
- ('A' <= c && c <= 'F');
- }
-
- /// <summary>
- /// Interprets a character as a digit (in any base up to 36) and returns the
- /// numeric value.
- /// </summary>
- private static int ParseDigit(char c)
- {
- if ('0' <= c && c <= '9')
- {
- return c - '0';
- }
- else if ('a' <= c && c <= 'z')
- {
- return c - 'a' + 10;
- }
- else
- {
- return c - 'A' + 10;
- }
- }
-
- /// <summary>
- /// Unescapes a text string as escaped using <see cref="EscapeText(string)" />.
- /// Two-digit hex escapes (starting with "\x" are also recognised.
- /// </summary>
- public static string UnescapeText(string input)
- {
- return UnescapeBytes(input).ToStringUtf8();
- }
-
- /// <summary>
- /// Like <see cref="EscapeBytes" /> but escapes a text string.
- /// The string is first encoded as UTF-8, then each byte escaped individually.
- /// The returned value is guaranteed to be entirely ASCII.
- /// </summary>
- public static string EscapeText(string input)
- {
- return EscapeBytes(ByteString.CopyFromUtf8(input));
- }
-
- /// <summary>
- /// Escapes bytes in the format used in protocol buffer text format, which
- /// is the same as the format used for C string literals. All bytes
- /// that are not printable 7-bit ASCII characters are escaped, as well as
- /// backslash, single-quote, and double-quote characters. Characters for
- /// which no defined short-hand escape sequence is defined will be escaped
- /// using 3-digit octal sequences.
- /// The returned value is guaranteed to be entirely ASCII.
- /// </summary>
- public static String EscapeBytes(ByteString input)
- {
- StringBuilder builder = new StringBuilder(input.Length);
- foreach (byte b in input)
- {
- switch (b)
- {
- // C# does not use \a or \v
- case 0x07:
- builder.Append("\\a");
- break;
- case (byte) '\b':
- builder.Append("\\b");
- break;
- case (byte) '\f':
- builder.Append("\\f");
- break;
- case (byte) '\n':
- builder.Append("\\n");
- break;
- case (byte) '\r':
- builder.Append("\\r");
- break;
- case (byte) '\t':
- builder.Append("\\t");
- break;
- case 0x0b:
- builder.Append("\\v");
- break;
- case (byte) '\\':
- builder.Append("\\\\");
- break;
- case (byte) '\'':
- builder.Append("\\\'");
- break;
- case (byte) '"':
- builder.Append("\\\"");
- break;
- default:
- if (b >= 0x20 && b < 128)
- {
- builder.Append((char) b);
- }
- else
- {
- builder.Append('\\');
- builder.Append((char) ('0' + ((b >> 6) & 3)));
- builder.Append((char) ('0' + ((b >> 3) & 7)));
- builder.Append((char) ('0' + (b & 7)));
- }
- break;
- }
- }
- return builder.ToString();
- }
-
- /// <summary>
- /// Performs string unescaping from C style (octal, hex, form feeds, tab etc) into a byte string.
- /// </summary>
- public static ByteString UnescapeBytes(string input)
- {
- byte[] result = new byte[input.Length];
- int pos = 0;
- for (int i = 0; i < input.Length; i++)
- {
- char c = input[i];
- if (c > 127 || c < 32)
- {
- throw new FormatException("Escaped string must only contain ASCII");
- }
- if (c != '\\')
- {
- result[pos++] = (byte) c;
- continue;
- }
- if (i + 1 >= input.Length)
- {
- throw new FormatException("Invalid escape sequence: '\\' at end of string.");
- }
-
- i++;
- c = input[i];
- if (c >= '0' && c <= '7')
- {
- // Octal escape.
- int code = ParseDigit(c);
- if (i + 1 < input.Length && IsOctal(input[i + 1]))
- {
- i++;
- code = code*8 + ParseDigit(input[i]);
- }
- if (i + 1 < input.Length && IsOctal(input[i + 1]))
- {
- i++;
- code = code*8 + ParseDigit(input[i]);
- }
- result[pos++] = (byte) code;
- }
- else
- {
- switch (c)
- {
- case 'a':
- result[pos++] = 0x07;
- break;
- case 'b':
- result[pos++] = (byte) '\b';
- break;
- case 'f':
- result[pos++] = (byte) '\f';
- break;
- case 'n':
- result[pos++] = (byte) '\n';
- break;
- case 'r':
- result[pos++] = (byte) '\r';
- break;
- case 't':
- result[pos++] = (byte) '\t';
- break;
- case 'v':
- result[pos++] = 0x0b;
- break;
- case '\\':
- result[pos++] = (byte) '\\';
- break;
- case '\'':
- result[pos++] = (byte) '\'';
- break;
- case '"':
- result[pos++] = (byte) '\"';
- break;
-
- case 'x':
- // hex escape
- int code;
- if (i + 1 < input.Length && IsHex(input[i + 1]))
- {
- i++;
- code = ParseDigit(input[i]);
- }
- else
- {
- throw new FormatException("Invalid escape sequence: '\\x' with no digits");
- }
- if (i + 1 < input.Length && IsHex(input[i + 1]))
- {
- ++i;
- code = code*16 + ParseDigit(input[i]);
- }
- result[pos++] = (byte) code;
- break;
-
- default:
- throw new FormatException("Invalid escape sequence: '\\" + c + "'");
- }
- }
- }
-
- return ByteString.CopyFrom(result, 0, pos);
- }
-
- public static void Merge(string text, IBuilder builder)
- {
- Merge(text, ExtensionRegistry.Empty, builder);
- }
-
- public static void Merge(TextReader reader, IBuilder builder)
- {
- Merge(reader, ExtensionRegistry.Empty, builder);
- }
-
- public static void Merge(TextReader reader, ExtensionRegistry registry, IBuilder builder)
- {
- Merge(reader.ReadToEnd(), registry, builder);
- }
-
- public static void Merge(string text, ExtensionRegistry registry, IBuilder builder)
- {
- TextTokenizer tokenizer = new TextTokenizer(text);
-
- while (!tokenizer.AtEnd)
- {
- MergeField(tokenizer, registry, builder);
- }
- }
-
- /// <summary>
- /// Parses a single field from the specified tokenizer and merges it into
- /// the builder.
- /// </summary>
- private static void MergeField(TextTokenizer tokenizer, ExtensionRegistry extensionRegistry,
- IBuilder builder)
- {
- FieldDescriptor field;
- MessageDescriptor type = builder.DescriptorForType;
- ExtensionInfo extension = null;
-
- if (tokenizer.TryConsume("["))
- {
- // An extension.
- StringBuilder name = new StringBuilder(tokenizer.ConsumeIdentifier());
- while (tokenizer.TryConsume("."))
- {
- name.Append(".");
- name.Append(tokenizer.ConsumeIdentifier());
- }
-
- extension = extensionRegistry.FindByName(type, name.ToString());
-
- if (extension == null)
- {
- throw tokenizer.CreateFormatExceptionPreviousToken("Extension \"" + name +
- "\" not found in the ExtensionRegistry.");
- }
- else if (extension.Descriptor.ContainingType != type)
- {
- throw tokenizer.CreateFormatExceptionPreviousToken("Extension \"" + name +
- "\" does not extend message type \"" +
- type.FullName + "\".");
- }
-
- tokenizer.Consume("]");
-
- field = extension.Descriptor;
- }
- else
- {
- String name = tokenizer.ConsumeIdentifier();
- field = type.FindDescriptor<FieldDescriptor>(name);
-
- // Group names are expected to be capitalized as they appear in the
- // .proto file, which actually matches their type names, not their field
- // names.
- if (field == null)
- {
- // Explicitly specify the invariant culture so that this code does not break when
- // executing in Turkey.
- String lowerName = name.ToLowerInvariant();
- field = type.FindDescriptor<FieldDescriptor>(lowerName);
- // If the case-insensitive match worked but the field is NOT a group,
- // TODO(jonskeet): What? Java comment ends here!
- if (field != null && field.FieldType != FieldType.Group)
- {
- field = null;
- }
- }
- // Again, special-case group names as described above.
- if (field != null && field.FieldType == FieldType.Group && field.MessageType.Name != name)
- {
- field = null;
- }
-
- if (field == null)
- {
- throw tokenizer.CreateFormatExceptionPreviousToken(
- "Message type \"" + type.FullName + "\" has no field named \"" + name + "\".");
- }
- }
-
- object value = null;
-
- if (field.MappedType == MappedType.Message)
- {
- tokenizer.TryConsume(":"); // optional
-
- String endToken;
- if (tokenizer.TryConsume("<"))
- {
- endToken = ">";
- }
- else
- {
- tokenizer.Consume("{");
- endToken = "}";
- }
-
- IBuilder subBuilder;
- if (extension == null)
- {
- subBuilder = builder.CreateBuilderForField(field);
- }
- else
- {
- subBuilder = extension.DefaultInstance.WeakCreateBuilderForType() as IBuilder;
- if (subBuilder == null)
- {
- throw new NotSupportedException("Lite messages are not supported.");
- }
- }
-
- while (!tokenizer.TryConsume(endToken))
- {
- if (tokenizer.AtEnd)
- {
- throw tokenizer.CreateFormatException("Expected \"" + endToken + "\".");
- }
- MergeField(tokenizer, extensionRegistry, subBuilder);
- }
-
- value = subBuilder.WeakBuild();
- }
- else
- {
- tokenizer.Consume(":");
-
- switch (field.FieldType)
- {
- case FieldType.Int32:
- case FieldType.SInt32:
- case FieldType.SFixed32:
- value = tokenizer.ConsumeInt32();
- break;
-
- case FieldType.Int64:
- case FieldType.SInt64:
- case FieldType.SFixed64:
- value = tokenizer.ConsumeInt64();
- break;
-
- case FieldType.UInt32:
- case FieldType.Fixed32:
- value = tokenizer.ConsumeUInt32();
- break;
-
- case FieldType.UInt64:
- case FieldType.Fixed64:
- value = tokenizer.ConsumeUInt64();
- break;
-
- case FieldType.Float:
- value = tokenizer.ConsumeFloat();
- break;
-
- case FieldType.Double:
- value = tokenizer.ConsumeDouble();
- break;
-
- case FieldType.Bool:
- value = tokenizer.ConsumeBoolean();
- break;
-
- case FieldType.String:
- value = tokenizer.ConsumeString();
- break;
-
- case FieldType.Bytes:
- value = tokenizer.ConsumeByteString();
- break;
-
- case FieldType.Enum:
- {
- EnumDescriptor enumType = field.EnumType;
-
- if (tokenizer.LookingAtInteger())
- {
- int number = tokenizer.ConsumeInt32();
- value = enumType.FindValueByNumber(number);
- if (value == null)
- {
- throw tokenizer.CreateFormatExceptionPreviousToken(
- "Enum type \"" + enumType.FullName +
- "\" has no value with number " + number + ".");
- }
- }
- else
- {
- String id = tokenizer.ConsumeIdentifier();
- value = enumType.FindValueByName(id);
- if (value == null)
- {
- throw tokenizer.CreateFormatExceptionPreviousToken(
- "Enum type \"" + enumType.FullName +
- "\" has no value named \"" + id + "\".");
- }
- }
-
- break;
- }
-
- case FieldType.Message:
- case FieldType.Group:
- throw new InvalidOperationException("Can't get here.");
- }
- }
-
- if (field.IsRepeated)
- {
- builder.WeakAddRepeatedField(field, value);
- }
- else
- {
- builder.SetField(field, value);
- }
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/TextGenerator.cs b/csharp/src/ProtocolBuffers/TextGenerator.cs index 30cbf0fd..80910ba1 100644 --- a/csharp/src/ProtocolBuffers/TextGenerator.cs +++ b/csharp/src/ProtocolBuffers/TextGenerator.cs @@ -38,7 +38,7 @@ using System; using System.IO;
using System.Text;
-namespace Google.ProtocolBuffers
+namespace Google.Protobuf
{
/// <summary>
/// Helper class to control indentation. Used for TextFormat and by ProtoGen.
diff --git a/csharp/src/ProtocolBuffers/TextTokenizer.cs b/csharp/src/ProtocolBuffers/TextTokenizer.cs deleted file mode 100644 index 5bb27fd0..00000000 --- a/csharp/src/ProtocolBuffers/TextTokenizer.cs +++ /dev/null @@ -1,501 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Globalization;
-using System.Text.RegularExpressions;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Represents a stream of tokens parsed from a string.
- /// </summary>
- internal sealed class TextTokenizer
- {
- private readonly string text;
- private string currentToken;
-
- /// <summary>
- /// The character index within the text to perform the next regex match at.
- /// </summary>
- private int matchPos = 0;
-
- /// <summary>
- /// The character index within the text at which the current token begins.
- /// </summary>
- private int pos = 0;
-
- /// <summary>
- /// The line number of the current token.
- /// </summary>
- private int line = 0;
-
- /// <summary>
- /// The column number of the current token.
- /// </summary>
- private int column = 0;
-
- /// <summary>
- /// The line number of the previous token.
- /// </summary>
- private int previousLine = 0;
-
- /// <summary>
- /// The column number of the previous token.
- /// </summary>
- private int previousColumn = 0;
-
- // Note: atomic groups used to mimic possessive quantifiers in Java in both of these regexes
- internal static readonly Regex WhitespaceAndCommentPattern = new Regex("\\G(?>(\\s|(#.*$))+)",
- FrameworkPortability.
- CompiledRegexWhereAvailable |
- RegexOptions.Multiline);
-
- private static readonly Regex TokenPattern = new Regex(
- "\\G[a-zA-Z_](?>[0-9a-zA-Z_+-]*)|" + // an identifier
- "\\G[0-9+-](?>[0-9a-zA-Z_.+-]*)|" + // a number
- "\\G\"(?>([^\"\\\n\\\\]|\\\\.)*)(\"|\\\\?$)|" + // a double-quoted string
- "\\G\'(?>([^\"\\\n\\\\]|\\\\.)*)(\'|\\\\?$)", // a single-quoted string
- FrameworkPortability.CompiledRegexWhereAvailable | RegexOptions.Multiline);
-
- private static readonly Regex DoubleInfinity = new Regex("^-?inf(inity)?$",
- FrameworkPortability.CompiledRegexWhereAvailable |
- RegexOptions.IgnoreCase);
-
- private static readonly Regex FloatInfinity = new Regex("^-?inf(inity)?f?$",
- FrameworkPortability.CompiledRegexWhereAvailable |
- RegexOptions.IgnoreCase);
-
- private static readonly Regex FloatNan = new Regex("^nanf?$",
- FrameworkPortability.CompiledRegexWhereAvailable |
- RegexOptions.IgnoreCase);
-
- /** Construct a tokenizer that parses tokens from the given text. */
-
- public TextTokenizer(string text)
- {
- this.text = text;
- SkipWhitespace();
- NextToken();
- }
-
- /// <summary>
- /// Are we at the end of the input?
- /// </summary>
- public bool AtEnd
- {
- get { return currentToken.Length == 0; }
- }
-
- /// <summary>
- /// Advances to the next token.
- /// </summary>
- public void NextToken()
- {
- previousLine = line;
- previousColumn = column;
-
- // Advance the line counter to the current position.
- while (pos < matchPos)
- {
- if (text[pos] == '\n')
- {
- ++line;
- column = 0;
- }
- else
- {
- ++column;
- }
- ++pos;
- }
-
- // Match the next token.
- if (matchPos == text.Length)
- {
- // EOF
- currentToken = "";
- }
- else
- {
- Match match = TokenPattern.Match(text, matchPos);
- if (match.Success)
- {
- currentToken = match.Value;
- matchPos += match.Length;
- }
- else
- {
- // Take one character.
- currentToken = text[matchPos].ToString();
- matchPos++;
- }
-
- SkipWhitespace();
- }
- }
-
- /// <summary>
- /// Skip over any whitespace so that matchPos starts at the next token.
- /// </summary>
- private void SkipWhitespace()
- {
- Match match = WhitespaceAndCommentPattern.Match(text, matchPos);
- if (match.Success)
- {
- matchPos += match.Length;
- }
- }
-
- /// <summary>
- /// If the next token exactly matches the given token, consume it and return
- /// true. Otherwise, return false without doing anything.
- /// </summary>
- public bool TryConsume(string token)
- {
- if (currentToken == token)
- {
- NextToken();
- return true;
- }
- return false;
- }
-
- /*
- * If the next token exactly matches {@code token}, consume it. Otherwise,
- * throw a {@link ParseException}.
- */
-
- /// <summary>
- /// If the next token exactly matches the specified one, consume it.
- /// Otherwise, throw a FormatException.
- /// </summary>
- /// <param name="token"></param>
- public void Consume(string token)
- {
- if (!TryConsume(token))
- {
- throw CreateFormatException("Expected \"" + token + "\".");
- }
- }
-
- /// <summary>
- /// Returns true if the next token is an integer, but does not consume it.
- /// </summary>
- public bool LookingAtInteger()
- {
- if (currentToken.Length == 0)
- {
- return false;
- }
-
- char c = currentToken[0];
- return ('0' <= c && c <= '9') || c == '-' || c == '+';
- }
-
- /// <summary>
- /// If the next token is an identifier, consume it and return its value.
- /// Otherwise, throw a FormatException.
- /// </summary>
- public string ConsumeIdentifier()
- {
- foreach (char c in currentToken)
- {
- if (('a' <= c && c <= 'z') ||
- ('A' <= c && c <= 'Z') ||
- ('0' <= c && c <= '9') ||
- (c == '_') || (c == '.'))
- {
- // OK
- }
- else
- {
- throw CreateFormatException("Expected identifier.");
- }
- }
-
- string result = currentToken;
- NextToken();
- return result;
- }
-
- /// <summary>
- /// If the next token is a 32-bit signed integer, consume it and return its
- /// value. Otherwise, throw a FormatException.
- /// </summary>
- public int ConsumeInt32()
- {
- try
- {
- int result = TextFormat.ParseInt32(currentToken);
- NextToken();
- return result;
- }
- catch (FormatException e)
- {
- throw CreateIntegerParseException(e);
- }
- }
-
- /// <summary>
- /// If the next token is a 32-bit unsigned integer, consume it and return its
- /// value. Otherwise, throw a FormatException.
- /// </summary>
- public uint ConsumeUInt32()
- {
- try
- {
- uint result = TextFormat.ParseUInt32(currentToken);
- NextToken();
- return result;
- }
- catch (FormatException e)
- {
- throw CreateIntegerParseException(e);
- }
- }
-
- /// <summary>
- /// If the next token is a 64-bit signed integer, consume it and return its
- /// value. Otherwise, throw a FormatException.
- /// </summary>
- public long ConsumeInt64()
- {
- try
- {
- long result = TextFormat.ParseInt64(currentToken);
- NextToken();
- return result;
- }
- catch (FormatException e)
- {
- throw CreateIntegerParseException(e);
- }
- }
-
- /// <summary>
- /// If the next token is a 64-bit unsigned integer, consume it and return its
- /// value. Otherwise, throw a FormatException.
- /// </summary>
- public ulong ConsumeUInt64()
- {
- try
- {
- ulong result = TextFormat.ParseUInt64(currentToken);
- NextToken();
- return result;
- }
- catch (FormatException e)
- {
- throw CreateIntegerParseException(e);
- }
- }
-
- /// <summary>
- /// If the next token is a double, consume it and return its value.
- /// Otherwise, throw a FormatException.
- /// </summary>
- public double ConsumeDouble()
- {
- // We need to parse infinity and nan separately because
- // double.Parse() does not accept "inf", "infinity", or "nan".
- if (DoubleInfinity.IsMatch(currentToken))
- {
- bool negative = currentToken.StartsWith("-");
- NextToken();
- return negative ? double.NegativeInfinity : double.PositiveInfinity;
- }
- if (currentToken.Equals("nan", StringComparison.OrdinalIgnoreCase))
- {
- NextToken();
- return Double.NaN;
- }
-
- try
- {
- double result = double.Parse(currentToken, FrameworkPortability.InvariantCulture);
- NextToken();
- return result;
- }
- catch (FormatException e)
- {
- throw CreateFloatParseException(e);
- }
- catch (OverflowException e)
- {
- throw CreateFloatParseException(e);
- }
- }
-
- /// <summary>
- /// If the next token is a float, consume it and return its value.
- /// Otherwise, throw a FormatException.
- /// </summary>
- public float ConsumeFloat()
- {
- // We need to parse infinity and nan separately because
- // Float.parseFloat() does not accept "inf", "infinity", or "nan".
- if (FloatInfinity.IsMatch(currentToken))
- {
- bool negative = currentToken.StartsWith("-");
- NextToken();
- return negative ? float.NegativeInfinity : float.PositiveInfinity;
- }
- if (FloatNan.IsMatch(currentToken))
- {
- NextToken();
- return float.NaN;
- }
-
- if (currentToken.EndsWith("f"))
- {
- currentToken = currentToken.TrimEnd('f');
- }
-
- try
- {
- float result = float.Parse(currentToken, FrameworkPortability.InvariantCulture);
- NextToken();
- return result;
- }
- catch (FormatException e)
- {
- throw CreateFloatParseException(e);
- }
- catch (OverflowException e)
- {
- throw CreateFloatParseException(e);
- }
- }
-
- /// <summary>
- /// If the next token is a Boolean, consume it and return its value.
- /// Otherwise, throw a FormatException.
- /// </summary>
- public bool ConsumeBoolean()
- {
- if (currentToken == "true")
- {
- NextToken();
- return true;
- }
- if (currentToken == "false")
- {
- NextToken();
- return false;
- }
- throw CreateFormatException("Expected \"true\" or \"false\".");
- }
-
- /// <summary>
- /// If the next token is a string, consume it and return its (unescaped) value.
- /// Otherwise, throw a FormatException.
- /// </summary>
- public string ConsumeString()
- {
- return ConsumeByteString().ToStringUtf8();
- }
-
- /// <summary>
- /// If the next token is a string, consume it, unescape it as a
- /// ByteString and return it. Otherwise, throw a FormatException.
- /// </summary>
- public ByteString ConsumeByteString()
- {
- char quote = currentToken.Length > 0 ? currentToken[0] : '\0';
- if (quote != '\"' && quote != '\'')
- {
- throw CreateFormatException("Expected string.");
- }
-
- if (currentToken.Length < 2 ||
- currentToken[currentToken.Length - 1] != quote)
- {
- throw CreateFormatException("String missing ending quote.");
- }
-
- try
- {
- string escaped = currentToken.Substring(1, currentToken.Length - 2);
- ByteString result = TextFormat.UnescapeBytes(escaped);
- NextToken();
- return result;
- }
- catch (FormatException e)
- {
- throw CreateFormatException(e.Message);
- }
- }
-
- /// <summary>
- /// Returns a format exception with the current line and column numbers
- /// in the description, suitable for throwing.
- /// </summary>
- public FormatException CreateFormatException(string description)
- {
- // Note: People generally prefer one-based line and column numbers.
- return new FormatException((line + 1) + ":" + (column + 1) + ": " + description);
- }
-
- /// <summary>
- /// Returns a format exception with the line and column numbers of the
- /// previous token in the description, suitable for throwing.
- /// </summary>
- public FormatException CreateFormatExceptionPreviousToken(string description)
- {
- // Note: People generally prefer one-based line and column numbers.
- return new FormatException((previousLine + 1) + ":" + (previousColumn + 1) + ": " + description);
- }
-
- /// <summary>
- /// Constructs an appropriate FormatException for the given existing exception
- /// when trying to parse an integer.
- /// </summary>
- private FormatException CreateIntegerParseException(FormatException e)
- {
- return CreateFormatException("Couldn't parse integer: " + e.Message);
- }
-
- /// <summary>
- /// Constructs an appropriate FormatException for the given existing exception
- /// when trying to parse a float or double.
- /// </summary>
- private FormatException CreateFloatParseException(Exception e)
- {
- return CreateFormatException("Couldn't parse number: " + e.Message);
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ThrowHelper.cs b/csharp/src/ProtocolBuffers/ThrowHelper.cs index 69e5f569..c12a48a3 100644 --- a/csharp/src/ProtocolBuffers/ThrowHelper.cs +++ b/csharp/src/ProtocolBuffers/ThrowHelper.cs @@ -37,17 +37,17 @@ using System;
using System.Collections.Generic;
-namespace Google.ProtocolBuffers
+namespace Google.Protobuf
{
/// <summary>
/// Helper methods for throwing exceptions
/// </summary>
- public static class ThrowHelper
+ internal static class ThrowHelper
{
/// <summary>
/// Throws an ArgumentNullException if the given value is null.
/// </summary>
- public static void ThrowIfNull(object value, string name)
+ internal static void ThrowIfNull(object value, string name)
{
if (value == null)
{
@@ -58,7 +58,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Throws an ArgumentNullException if the given value is null.
/// </summary>
- public static void ThrowIfNull(object value)
+ internal static void ThrowIfNull(object value)
{
if (value == null)
{
@@ -69,7 +69,7 @@ namespace Google.ProtocolBuffers /// <summary>
/// Throws an ArgumentNullException if the given value or any element within it is null.
/// </summary>
- public static void ThrowIfAnyNull<T>(IEnumerable<T> sequence)
+ internal static void ThrowIfAnyNull<T>(IEnumerable<T> sequence)
{
foreach (T t in sequence)
{
@@ -79,14 +79,5 @@ namespace Google.ProtocolBuffers }
}
}
-
- public static Exception CreateMissingMethod(Type type, string methodName)
- {
-#if CLIENTPROFILE
- return new System.MissingMethodException(type.FullName, methodName);
-#else
- return new System.ArgumentException(String.Format("The method '{0}' was not found on type {1}.", methodName, type));
-#endif
- }
}
}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/UninitializedMessageException.cs b/csharp/src/ProtocolBuffers/UninitializedMessageException.cs deleted file mode 100644 index 9e4f856e..00000000 --- a/csharp/src/ProtocolBuffers/UninitializedMessageException.cs +++ /dev/null @@ -1,208 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-#if !LITE
-using Google.ProtocolBuffers.Collections;
-using Google.ProtocolBuffers.Descriptors;
-
-#endif
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// TODO(jonskeet): Write summary text.
- /// </summary>
- public sealed class UninitializedMessageException : Exception
- {
- private readonly IList<string> missingFields;
-
- private UninitializedMessageException(IList<string> missingFields)
- : base(BuildDescription(missingFields))
- {
- this.missingFields = new List<string>(missingFields);
- }
-
- /// <summary>
- /// Returns a read-only list of human-readable names of
- /// required fields missing from this message. Each name
- /// is a full path to a field, e.g. "foo.bar[5].baz"
- /// </summary>
- public IList<string> MissingFields
- {
- get { return missingFields; }
- }
-
- /// <summary>
- /// Converts this exception into an InvalidProtocolBufferException.
- /// When a parsed message is missing required fields, this should be thrown
- /// instead of UninitializedMessageException.
- /// </summary>
- public InvalidProtocolBufferException AsInvalidProtocolBufferException()
- {
- return new InvalidProtocolBufferException(Message);
- }
-
- /// <summary>
- /// Constructs the description string for a given list of missing fields.
- /// </summary>
- private static string BuildDescription(IEnumerable<string> missingFields)
- {
- StringBuilder description = new StringBuilder("Message missing required fields: ");
- bool first = true;
- foreach (string field in missingFields)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- description.Append(", ");
- }
- description.Append(field);
- }
- return description.ToString();
- }
-
- /// <summary>
- /// For Lite exceptions that do not known how to enumerate missing fields
- /// </summary>
- public UninitializedMessageException(IMessageLite message)
- : base(String.Format("Message {0} is missing required fields", message.GetType()))
- {
- missingFields = new List<string>();
- }
-
-#if !LITE
- public UninitializedMessageException(IMessage message)
- : this(FindMissingFields(message))
- {
- }
-
- /// <summary>
- /// Returns a list of the full "paths" of missing required
- /// fields in the specified message.
- /// </summary>
- private static IList<String> FindMissingFields(IMessage message)
- {
- List<String> results = new List<String>();
- FindMissingFields(message, "", results);
- return results;
- }
-
- /// <summary>
- /// Recursive helper implementing FindMissingFields.
- /// </summary>
- private static void FindMissingFields(IMessage message, String prefix, List<String> results)
- {
- foreach (FieldDescriptor field in message.DescriptorForType.Fields)
- {
- if (field.IsRequired && !message.HasField(field))
- {
- results.Add(prefix + field.Name);
- }
- }
-
- foreach (KeyValuePair<FieldDescriptor, object> entry in message.AllFields)
- {
- FieldDescriptor field = entry.Key;
- object value = entry.Value;
-
- if (field.MappedType == MappedType.Message)
- {
- if (field.IsRepeated)
- {
- int i = 0;
- foreach (object element in (IEnumerable) value)
- {
- if (element is IMessage)
- {
- FindMissingFields((IMessage) element, SubMessagePrefix(prefix, field, i++), results);
- }
- else
- {
- results.Add(prefix + field.Name);
- }
- }
- }
- else
- {
- if (message.HasField(field))
- {
- if (value is IMessage)
- {
- FindMissingFields((IMessage) value, SubMessagePrefix(prefix, field, -1), results);
- }
- else
- {
- results.Add(prefix + field.Name);
- }
- }
- }
- }
- }
- }
-
- private static String SubMessagePrefix(String prefix, FieldDescriptor field, int index)
- {
- StringBuilder result = new StringBuilder(prefix);
- if (field.IsExtension)
- {
- result.Append('(')
- .Append(field.FullName)
- .Append(')');
- }
- else
- {
- result.Append(field.Name);
- }
- if (index != -1)
- {
- result.Append('[')
- .Append(index)
- .Append(']');
- }
- result.Append('.');
- return result.ToString();
- }
-#endif
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/UnknownField.cs b/csharp/src/ProtocolBuffers/UnknownField.cs deleted file mode 100644 index 7650b9df..00000000 --- a/csharp/src/ProtocolBuffers/UnknownField.cs +++ /dev/null @@ -1,415 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using Google.ProtocolBuffers.Collections;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Represents a single field in an UnknownFieldSet.
- ///
- /// An UnknownField consists of five lists of values. The lists correspond
- /// to the five "wire types" used in the protocol buffer binary format.
- /// The wire type of each field can be determined from the encoded form alone,
- /// without knowing the field's declared type. So, we are able to parse
- /// unknown values at least this far and separate them. Normally, only one
- /// of the five lists will contain any values, since it is impossible to
- /// define a valid message type that declares two different types for the
- /// same field number. However, the code is designed to allow for the case
- /// where the same unknown field number is encountered using multiple different
- /// wire types.
- ///
- /// UnknownField is an immutable class. To construct one, you must use an
- /// UnknownField.Builder.
- /// </summary>
- public sealed class UnknownField
- {
- public const string UnknownFieldName = "unknown_field";
- private static readonly UnknownField defaultInstance = CreateBuilder().Build();
- private readonly ReadOnlyCollection<ulong> varintList;
- private readonly ReadOnlyCollection<uint> fixed32List;
- private readonly ReadOnlyCollection<ulong> fixed64List;
- private readonly ReadOnlyCollection<ByteString> lengthDelimitedList;
- private readonly ReadOnlyCollection<UnknownFieldSet> groupList;
-
- private UnknownField(ReadOnlyCollection<ulong> varintList,
- ReadOnlyCollection<uint> fixed32List,
- ReadOnlyCollection<ulong> fixed64List,
- ReadOnlyCollection<ByteString> lengthDelimitedList,
- ReadOnlyCollection<UnknownFieldSet> groupList)
- {
- this.varintList = varintList;
- this.fixed32List = fixed32List;
- this.fixed64List = fixed64List;
- this.lengthDelimitedList = lengthDelimitedList;
- this.groupList = groupList;
- }
-
- public static UnknownField DefaultInstance
- {
- get { return defaultInstance; }
- }
-
- /// <summary>
- /// The list of varint values for this field.
- /// </summary>
- public IList<ulong> VarintList
- {
- get { return varintList; }
- }
-
- /// <summary>
- /// The list of fixed32 values for this field.
- /// </summary>
- public IList<uint> Fixed32List
- {
- get { return fixed32List; }
- }
-
- /// <summary>
- /// The list of fixed64 values for this field.
- /// </summary>
- public IList<ulong> Fixed64List
- {
- get { return fixed64List; }
- }
-
- /// <summary>
- /// The list of length-delimited values for this field.
- /// </summary>
- public IList<ByteString> LengthDelimitedList
- {
- get { return lengthDelimitedList; }
- }
-
- /// <summary>
- /// The list of embedded group values for this field. These
- /// are represented using UnknownFieldSets rather than Messages
- /// since the group's type is presumably unknown.
- /// </summary>
- public IList<UnknownFieldSet> GroupList
- {
- get { return groupList; }
- }
-
- public override bool Equals(object other)
- {
- if (ReferenceEquals(this, other))
- {
- return true;
- }
- UnknownField otherField = other as UnknownField;
- return otherField != null
- && Lists.Equals(varintList, otherField.varintList)
- && Lists.Equals(fixed32List, otherField.fixed32List)
- && Lists.Equals(fixed64List, otherField.fixed64List)
- && Lists.Equals(lengthDelimitedList, otherField.lengthDelimitedList)
- && Lists.Equals(groupList, otherField.groupList);
- }
-
- public override int GetHashCode()
- {
- int hash = 43;
- hash = hash*47 + Lists.GetHashCode(varintList);
- hash = hash*47 + Lists.GetHashCode(fixed32List);
- hash = hash*47 + Lists.GetHashCode(fixed64List);
- hash = hash*47 + Lists.GetHashCode(lengthDelimitedList);
- hash = hash*47 + Lists.GetHashCode(groupList);
- return hash;
- }
-
- /// <summary>
- /// Constructs a new Builder.
- /// </summary>
- public static Builder CreateBuilder()
- {
- return new Builder();
- }
-
- /// <summary>
- /// Constructs a new Builder and initializes it to a copy of <paramref name="copyFrom"/>.
- /// </summary>
- public static Builder CreateBuilder(UnknownField copyFrom)
- {
- return new Builder().MergeFrom(copyFrom);
- }
-
- /// <summary>
- /// Serializes the field, including the field number, and writes it to
- /// <paramref name="output"/>.
- /// </summary>
- public void WriteTo(int fieldNumber, ICodedOutputStream output)
- {
- foreach (ulong value in varintList)
- {
- output.WriteUnknownField(fieldNumber, WireFormat.WireType.Varint, value);
- }
- foreach (uint value in fixed32List)
- {
- output.WriteUnknownField(fieldNumber, WireFormat.WireType.Fixed32, value);
- }
- foreach (ulong value in fixed64List)
- {
- output.WriteUnknownField(fieldNumber, WireFormat.WireType.Fixed64, value);
- }
- foreach (ByteString value in lengthDelimitedList)
- {
- output.WriteUnknownBytes(fieldNumber, value);
- }
- foreach (UnknownFieldSet value in groupList)
- {
-#pragma warning disable 0612
- output.WriteUnknownGroup(fieldNumber, value);
-#pragma warning restore 0612
- }
- }
-
- /// <summary>
- /// Computes the number of bytes required to encode this field, including field
- /// number.
- /// </summary>
- public int GetSerializedSize(int fieldNumber)
- {
- int result = 0;
- foreach (ulong value in varintList)
- {
- result += CodedOutputStream.ComputeUInt64Size(fieldNumber, value);
- }
- foreach (uint value in fixed32List)
- {
- result += CodedOutputStream.ComputeFixed32Size(fieldNumber, value);
- }
- foreach (ulong value in fixed64List)
- {
- result += CodedOutputStream.ComputeFixed64Size(fieldNumber, value);
- }
- foreach (ByteString value in lengthDelimitedList)
- {
- result += CodedOutputStream.ComputeBytesSize(fieldNumber, value);
- }
- foreach (UnknownFieldSet value in groupList)
- {
-#pragma warning disable 0612
- result += CodedOutputStream.ComputeUnknownGroupSize(fieldNumber, value);
-#pragma warning restore 0612
- }
- return result;
- }
-
- /// <summary>
- /// Serializes the length-delimited values of the field, including field
- /// number, and writes them to <paramref name="output"/> using the MessageSet wire format.
- /// </summary>
- /// <param name="fieldNumber"></param>
- /// <param name="output"></param>
- public void WriteAsMessageSetExtensionTo(int fieldNumber, ICodedOutputStream output)
- {
- foreach (ByteString value in lengthDelimitedList)
- {
- output.WriteMessageSetExtension(fieldNumber, UnknownFieldName, value);
- }
- }
-
- /// <summary>
- /// Get the number of bytes required to encode this field, incuding field number,
- /// using the MessageSet wire format.
- /// </summary>
- public int GetSerializedSizeAsMessageSetExtension(int fieldNumber)
- {
- int result = 0;
- foreach (ByteString value in lengthDelimitedList)
- {
- result += CodedOutputStream.ComputeRawMessageSetExtensionSize(fieldNumber, value);
- }
- return result;
- }
-
- /// <summary>
- /// Used to build instances of UnknownField.
- /// </summary>
- public sealed class Builder
- {
- private List<ulong> varintList;
- private List<uint> fixed32List;
- private List<ulong> fixed64List;
- private List<ByteString> lengthDelimitedList;
- private List<UnknownFieldSet> groupList;
-
- /// <summary>
- /// Builds the field. After building, the builder is reset to an empty
- /// state. (This is actually easier than making it unusable.)
- /// </summary>
- public UnknownField Build()
- {
- return new UnknownField(MakeReadOnly(ref varintList),
- MakeReadOnly(ref fixed32List),
- MakeReadOnly(ref fixed64List),
- MakeReadOnly(ref lengthDelimitedList),
- MakeReadOnly(ref groupList));
- }
-
- /// <summary>
- /// Merge the values in <paramref name="other" /> into this field. For each list
- /// of values, <paramref name="other"/>'s values are append to the ones in this
- /// field.
- /// </summary>
- public Builder MergeFrom(UnknownField other)
- {
- varintList = AddAll(varintList, other.VarintList);
- fixed32List = AddAll(fixed32List, other.Fixed32List);
- fixed64List = AddAll(fixed64List, other.Fixed64List);
- lengthDelimitedList = AddAll(lengthDelimitedList, other.LengthDelimitedList);
- groupList = AddAll(groupList, other.GroupList);
- return this;
- }
-
- /// <summary>
- /// Returns a new list containing all of the given specified values from
- /// both the <paramref name="current"/> and <paramref name="extras"/> lists.
- /// If <paramref name="current" /> is null and <paramref name="extras"/> is empty,
- /// null is returned. Otherwise, either a new list is created (if <paramref name="current" />
- /// is null) or the elements of <paramref name="extras"/> are added to <paramref name="current" />.
- /// </summary>
- private static List<T> AddAll<T>(List<T> current, IList<T> extras)
- {
- if (extras.Count == 0)
- {
- return current;
- }
- if (current == null)
- {
- current = new List<T>(extras);
- }
- else
- {
- current.AddRange(extras);
- }
- return current;
- }
-
- /// <summary>
- /// Clears the contents of this builder.
- /// </summary>
- public Builder Clear()
- {
- varintList = null;
- fixed32List = null;
- fixed64List = null;
- lengthDelimitedList = null;
- groupList = null;
- return this;
- }
-
- /// <summary>
- /// Adds a varint value.
- /// </summary>
- public Builder AddVarint(ulong value)
- {
- varintList = Add(varintList, value);
- return this;
- }
-
- /// <summary>
- /// Adds a fixed32 value.
- /// </summary>
- public Builder AddFixed32(uint value)
- {
- fixed32List = Add(fixed32List, value);
- return this;
- }
-
- /// <summary>
- /// Adds a fixed64 value.
- /// </summary>
- public Builder AddFixed64(ulong value)
- {
- fixed64List = Add(fixed64List, value);
- return this;
- }
-
- /// <summary>
- /// Adds a length-delimited value.
- /// </summary>
- public Builder AddLengthDelimited(ByteString value)
- {
- lengthDelimitedList = Add(lengthDelimitedList, value);
- return this;
- }
-
- /// <summary>
- /// Adds an embedded group.
- /// </summary>
- /// <param name="value"></param>
- /// <returns></returns>
- public Builder AddGroup(UnknownFieldSet value)
- {
- groupList = Add(groupList, value);
- return this;
- }
-
- /// <summary>
- /// Adds <paramref name="value"/> to the <paramref name="list"/>, creating
- /// a new list if <paramref name="list"/> is null. The list is returned - either
- /// the original reference or the new list.
- /// </summary>
- private static List<T> Add<T>(List<T> list, T value)
- {
- if (list == null)
- {
- list = new List<T>();
- }
- list.Add(value);
- return list;
- }
-
- /// <summary>
- /// Returns a read-only version of the given IList, and clears
- /// the field used for <paramref name="list"/>. If the value
- /// is null, an empty list is produced using Lists.Empty.
- /// </summary>
- /// <returns></returns>
- private static ReadOnlyCollection<T> MakeReadOnly<T>(ref List<T> list)
- {
- ReadOnlyCollection<T> ret = list == null ? Lists<T>.Empty : new ReadOnlyCollection<T>(list);
- list = null;
- return ret;
- }
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/UnknownFieldSet.cs b/csharp/src/ProtocolBuffers/UnknownFieldSet.cs deleted file mode 100644 index d5d0675d..00000000 --- a/csharp/src/ProtocolBuffers/UnknownFieldSet.cs +++ /dev/null @@ -1,1061 +0,0 @@ -#region Copyright notice and license
-
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// http://github.com/jskeet/dotnet-protobufs/
-// Original C++/Java/Python code:
-// http://code.google.com/p/protobuf/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using Google.ProtocolBuffers.Collections;
-using Google.ProtocolBuffers.Descriptors;
-
-namespace Google.ProtocolBuffers
-{
- /// <summary>
- /// Used to keep track of fields which were seen when parsing a protocol message
- /// but whose field numbers or types are unrecognized. This most frequently
- /// occurs when new fields are added to a message type and then messages containing
- /// those fields are read by old software that was built before the new types were
- /// added.
- ///
- /// Every message contains an UnknownFieldSet.
- ///
- /// Most users will never need to use this class directly.
- /// </summary>
- public sealed partial class UnknownFieldSet : IMessageLite
- {
- private static readonly UnknownFieldSet defaultInstance =
- new UnknownFieldSet(new Dictionary<int, UnknownField>());
-
- private readonly IDictionary<int, UnknownField> fields;
-
- private UnknownFieldSet(IDictionary<int, UnknownField> fields)
- {
- this.fields = fields;
- }
-
- /// <summary>
- /// Creates a new unknown field set builder.
- /// </summary>
- public static Builder CreateBuilder()
- {
- return new Builder();
- }
-
- /// <summary>
- /// Creates a new unknown field set builder
- /// and initialize it from <paramref name="original"/>.
- /// </summary>
- public static Builder CreateBuilder(UnknownFieldSet original)
- {
- return new Builder().MergeFrom(original);
- }
-
- public static UnknownFieldSet DefaultInstance
- {
- get { return defaultInstance; }
- }
-
- /// <summary>
- /// Returns a read-only view of the mapping from field numbers to values.
- /// </summary>
- public IDictionary<int, UnknownField> FieldDictionary
- {
- get { return Dictionaries.AsReadOnly(fields); }
- }
-
- /// <summary>
- /// Checks whether or not the given field number is present in the set.
- /// </summary>
- public bool HasField(int field)
- {
- return fields.ContainsKey(field);
- }
-
- /// <summary>
- /// Fetches a field by number, returning an empty field if not present.
- /// Never returns null.
- /// </summary>
- public UnknownField this[int number]
- {
- get
- {
- UnknownField ret;
- if (!fields.TryGetValue(number, out ret))
- {
- ret = UnknownField.DefaultInstance;
- }
- return ret;
- }
- }
-
- /// <summary>
- /// Serializes the set and writes it to <paramref name="output"/>.
- /// </summary>
- public void WriteTo(ICodedOutputStream output)
- {
- // Avoid creating enumerator for the most common code path.
- if (fields.Count > 0)
- {
- foreach (KeyValuePair<int, UnknownField> entry in fields)
- {
- entry.Value.WriteTo(entry.Key, output);
- }
- }
- }
-
- /// <summary>
- /// Gets the number of bytes required to encode this set.
- /// </summary>
- public int SerializedSize
- {
- get
- {
- // Avoid creating enumerator for the most common code path.
- if (fields.Count == 0)
- {
- return 0;
- }
-
- int result = 0;
- foreach (KeyValuePair<int, UnknownField> entry in fields)
- {
- result += entry.Value.GetSerializedSize(entry.Key);
- }
- return result;
- }
- }
-
- /// <summary>
- /// Converts the set to a string in protocol buffer text format. This
- /// is just a trivial wrapper around TextFormat.PrintToString.
- /// </summary>
- public override String ToString()
- {
- return TextFormat.PrintToString(this);
- }
-
- /// <summary>
- /// Converts the set to a string in protocol buffer text format. This
- /// is just a trivial wrapper around TextFormat.PrintToString.
- /// </summary>
- public void PrintTo(TextWriter writer)
- {
- TextFormat.Print(this, writer);
- }
-
- /// <summary>
- /// Serializes the message to a ByteString and returns it. This is
- /// just a trivial wrapper around WriteTo(ICodedOutputStream).
- /// </summary>
- /// <returns></returns>
- public ByteString ToByteString()
- {
- ByteString.CodedBuilder codedBuilder = new ByteString.CodedBuilder(SerializedSize);
- WriteTo(codedBuilder.CodedOutput);
- return codedBuilder.Build();
- }
-
- /// <summary>
- /// Serializes the message to a byte array and returns it. This is
- /// just a trivial wrapper around WriteTo(ICodedOutputStream).
- /// </summary>
- /// <returns></returns>
- public byte[] ToByteArray()
- {
- byte[] data = new byte[SerializedSize];
- CodedOutputStream output = CodedOutputStream.CreateInstance(data);
- WriteTo(output);
- output.CheckNoSpaceLeft();
- return data;
- }
-
- /// <summary>
- /// Serializes the message and writes it to <paramref name="output"/>. This is
- /// just a trivial wrapper around WriteTo(ICodedOutputStream).
- /// </summary>
- /// <param name="output"></param>
- public void WriteTo(Stream output)
- {
- CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output);
- WriteTo(codedOutput);
- codedOutput.Flush();
- }
-
- /// <summary>
- /// Serializes the set and writes it to <paramref name="output"/> using
- /// the MessageSet wire format.
- /// </summary>
- public void WriteAsMessageSetTo(ICodedOutputStream output)
- {
- // Avoid creating enumerator for the most common code path.
- if (fields.Count > 0)
- {
- foreach (KeyValuePair<int, UnknownField> entry in fields)
- {
- entry.Value.WriteAsMessageSetExtensionTo(entry.Key, output);
- }
- }
- }
-
- /// <summary>
- /// Gets the number of bytes required to encode this set using the MessageSet
- /// wire format.
- /// </summary>
- public int SerializedSizeAsMessageSet
- {
- get
- {
- // Avoid creating enumerator for the most common code path.
- if (fields.Count == 0)
- {
- return 0;
- }
-
- int result = 0;
- foreach (KeyValuePair<int, UnknownField> entry in fields)
- {
- result += entry.Value.GetSerializedSizeAsMessageSetExtension(entry.Key);
- }
- return result;
- }
- }
-
- public override bool Equals(object other)
- {
- if (ReferenceEquals(this, other))
- {
- return true;
- }
- UnknownFieldSet otherSet = other as UnknownFieldSet;
- return otherSet != null && Dictionaries.Equals(fields, otherSet.fields);
- }
-
- public override int GetHashCode()
- {
- return Dictionaries.GetHashCode(fields);
- }
-
- /// <summary>
- /// Parses an UnknownFieldSet from the given input.
- /// </summary>
- public static UnknownFieldSet ParseFrom(ICodedInputStream input)
- {
- return CreateBuilder().MergeFrom(input).Build();
- }
-
- /// <summary>
- /// Parses an UnknownFieldSet from the given data.
- /// </summary>
- public static UnknownFieldSet ParseFrom(ByteString data)
- {
- return CreateBuilder().MergeFrom(data).Build();
- }
-
- /// <summary>
- /// Parses an UnknownFieldSet from the given data.
- /// </summary>
- public static UnknownFieldSet ParseFrom(byte[] data)
- {
- return CreateBuilder().MergeFrom(data).Build();
- }
-
- /// <summary>
- /// Parses an UnknownFieldSet from the given input.
- /// </summary>
- public static UnknownFieldSet ParseFrom(Stream input)
- {
- return CreateBuilder().MergeFrom(input).Build();
- }
-
- #region IMessageLite Members
-
- public bool IsInitialized
- {
- get { return fields != null; }
- }
-
- public void WriteDelimitedTo(Stream output)
- {
- CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output);
- codedOutput.WriteRawVarint32((uint) SerializedSize);
- WriteTo(codedOutput);
- codedOutput.Flush();
- }
-
- public IBuilderLite WeakCreateBuilderForType()
- {
- return new Builder();
- }
-
- public IBuilderLite WeakToBuilder()
- {
- return new Builder(fields);
- }
-
- public IMessageLite WeakDefaultInstanceForType
- {
- get { return defaultInstance; }
- }
-
- #endregion
-
- /// <summary>
- /// Builder for UnknownFieldSets.
- /// </summary>
- public sealed partial class Builder : IBuilderLite
- {
- /// <summary>
- /// Mapping from number to field. Note that by using a SortedList we ensure
- /// that the fields will be serialized in ascending order.
- /// </summary>
- private IDictionary<int, UnknownField> fields;
-
- // Optimization: We keep around a builder for the last field that was
- // modified so that we can efficiently add to it multiple times in a
- // row (important when parsing an unknown repeated field).
- private int lastFieldNumber;
- private UnknownField.Builder lastField;
-
- internal Builder()
- {
- fields = new SortedDictionary<int, UnknownField>();
- }
-
- internal Builder(IDictionary<int, UnknownField> dictionary)
- {
- fields = new SortedDictionary<int, UnknownField>(dictionary);
- }
-
- /// <summary>
- /// Returns a field builder for the specified field number, including any values
- /// which already exist.
- /// </summary>
- private UnknownField.Builder GetFieldBuilder(int number)
- {
- if (lastField != null)
- {
- if (number == lastFieldNumber)
- {
- return lastField;
- }
- // Note: AddField() will reset lastField and lastFieldNumber.
- AddField(lastFieldNumber, lastField.Build());
- }
- if (number == 0)
- {
- return null;
- }
-
- lastField = UnknownField.CreateBuilder();
- UnknownField existing;
- if (fields.TryGetValue(number, out existing))
- {
- lastField.MergeFrom(existing);
- }
- lastFieldNumber = number;
- return lastField;
- }
-
- /// <summary>
- /// Build the UnknownFieldSet and return it. Once this method has been called,
- /// this instance will no longer be usable. Calling any method after this
- /// will throw a NullReferenceException.
- /// </summary>
- public UnknownFieldSet Build()
- {
- GetFieldBuilder(0); // Force lastField to be built.
- UnknownFieldSet result = fields.Count == 0 ? DefaultInstance : new UnknownFieldSet(fields);
- fields = null;
- return result;
- }
-
- /// <summary>
- /// Adds a field to the set. If a field with the same number already exists, it
- /// is replaced.
- /// </summary>
- public Builder AddField(int number, UnknownField field)
- {
- if (number == 0)
- {
- throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number.");
- }
- if (lastField != null && lastFieldNumber == number)
- {
- // Discard this.
- lastField = null;
- lastFieldNumber = 0;
- }
- fields[number] = field;
- return this;
- }
-
- /// <summary>
- /// Resets the builder to an empty set.
- /// </summary>
- public Builder Clear()
- {
- fields.Clear();
- lastFieldNumber = 0;
- lastField = null;
- return this;
- }
-
- /// <summary>
- /// Parse an entire message from <paramref name="input"/> and merge
- /// its fields into this set.
- /// </summary>
- public Builder MergeFrom(ICodedInputStream input)
- {
- uint tag;
- string name;
- while (input.ReadTag(out tag, out name))
- {
- if (tag == 0)
- {
- if (input.SkipField())
- {
- continue; //can't merge unknown without field tag
- }
- break;
- }
-
- if (!MergeFieldFrom(tag, input))
- {
- break;
- }
- }
- return this;
- }
-
- /// <summary>
- /// Parse a single field from <paramref name="input"/> and merge it
- /// into this set.
- /// </summary>
- /// <param name="tag">The field's tag number, which was already parsed.</param>
- /// <param name="input">The coded input stream containing the field</param>
- /// <returns>false if the tag is an "end group" tag, true otherwise</returns>
- public bool MergeFieldFrom(uint tag, ICodedInputStream input)
- {
- if (tag == 0)
- {
- input.SkipField();
- return true;
- }
-
- int number = WireFormat.GetTagFieldNumber(tag);
- switch (WireFormat.GetTagWireType(tag))
- {
- case WireFormat.WireType.Varint:
- {
- ulong uint64 = 0;
- if (input.ReadUInt64(ref uint64))
- {
- GetFieldBuilder(number).AddVarint(uint64);
- }
- return true;
- }
- case WireFormat.WireType.Fixed32:
- {
- uint uint32 = 0;
- if (input.ReadFixed32(ref uint32))
- {
- GetFieldBuilder(number).AddFixed32(uint32);
- }
- return true;
- }
- case WireFormat.WireType.Fixed64:
- {
- ulong uint64 = 0;
- if (input.ReadFixed64(ref uint64))
- {
- GetFieldBuilder(number).AddFixed64(uint64);
- }
- return true;
- }
- case WireFormat.WireType.LengthDelimited:
- {
- ByteString bytes = null;
- if (input.ReadBytes(ref bytes))
- {
- GetFieldBuilder(number).AddLengthDelimited(bytes);
- }
- return true;
- }
- case WireFormat.WireType.StartGroup:
- {
- Builder subBuilder = CreateBuilder();
-#pragma warning disable 0612
- input.ReadUnknownGroup(number, subBuilder);
-#pragma warning restore 0612
- GetFieldBuilder(number).AddGroup(subBuilder.Build());
- return true;
- }
- case WireFormat.WireType.EndGroup:
- return false;
- default:
- throw InvalidProtocolBufferException.InvalidWireType();
- }
- }
-
- /// <summary>
- /// Parses <paramref name="input"/> as an UnknownFieldSet and merge it
- /// with the set being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream).
- /// </summary>
- public Builder MergeFrom(Stream input)
- {
- CodedInputStream codedInput = CodedInputStream.CreateInstance(input);
- MergeFrom(codedInput);
- codedInput.CheckLastTagWas(0);
- return this;
- }
-
- /// <summary>
- /// Parses <paramref name="data"/> as an UnknownFieldSet and merge it
- /// with the set being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream).
- /// </summary>
- public Builder MergeFrom(ByteString data)
- {
- CodedInputStream input = data.CreateCodedInput();
- MergeFrom(input);
- input.CheckLastTagWas(0);
- return this;
- }
-
- /// <summary>
- /// Parses <paramref name="data"/> as an UnknownFieldSet and merge it
- /// with the set being built. This is just a small wrapper around
- /// MergeFrom(ICodedInputStream).
- /// </summary>
- public Builder MergeFrom(byte[] data)
- {
- CodedInputStream input = CodedInputStream.CreateInstance(data);
- MergeFrom(input);
- input.CheckLastTagWas(0);
- return this;
- }
-
- /// <summary>
- /// Convenience method for merging a new field containing a single varint
- /// value. This is used in particular when an unknown enum value is
- /// encountered.
- /// </summary>
- public Builder MergeVarintField(int number, ulong value)
- {
- if (number == 0)
- {
- throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number.");
- }
- GetFieldBuilder(number).AddVarint(value);
- return this;
- }
-
- /// <summary>
- /// Merges the fields from <paramref name="other"/> into this set.
- /// If a field number exists in both sets, the values in <paramref name="other"/>
- /// will be appended to the values in this set.
- /// </summary>
- public Builder MergeFrom(UnknownFieldSet other)
- {
- if (other != DefaultInstance)
- {
- foreach (KeyValuePair<int, UnknownField> entry in other.fields)
- {
- MergeField(entry.Key, entry.Value);
- }
- }
- return this;
- }
-
- /// <summary>
- /// Checks if the given field number is present in the set.
- /// </summary>
- public bool HasField(int number)
- {
- if (number == 0)
- {
- throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number.");
- }
- return number == lastFieldNumber || fields.ContainsKey(number);
- }
-
- /// <summary>
- /// Adds a field to the unknown field set. If a field with the same
- /// number already exists, the two are merged.
- /// </summary>
- public Builder MergeField(int number, UnknownField field)
- {
- if (number == 0)
- {
- throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number.");
- }
- if (HasField(number))
- {
- GetFieldBuilder(number).MergeFrom(field);
- }
- else
- {
- // Optimization: We could call getFieldBuilder(number).mergeFrom(field)
- // in this case, but that would create a copy of the Field object.
- // We'd rather reuse the one passed to us, so call AddField() instead.
- AddField(number, field);
- }
- return this;
- }
-
- internal void MergeFrom(ICodedInputStream input, ExtensionRegistry extensionRegistry, IBuilder builder)
- {
- uint tag;
- string name;
- while (input.ReadTag(out tag, out name))
- {
- if (tag == 0 && name != null)
- {
- FieldDescriptor fieldByName = builder.DescriptorForType.FindFieldByName(name);
- if (fieldByName != null)
- {
- tag = WireFormat.MakeTag(fieldByName);
- }
- else
- {
- ExtensionInfo extension = extensionRegistry.FindByName(builder.DescriptorForType, name);
- if (extension != null)
- {
- tag = WireFormat.MakeTag(extension.Descriptor);
- }
- }
- }
- if (tag == 0)
- {
- if (input.SkipField())
- {
- continue; //can't merge unknown without field tag
- }
- break;
- }
-
- if (!MergeFieldFrom(input, extensionRegistry, builder, tag, name))
- {
- // end group tag
- break;
- }
- }
- }
-
- /// <summary>
- /// Like <see cref="MergeFrom(ICodedInputStream, ExtensionRegistry, IBuilder)" />
- /// but parses a single field.
- /// </summary>
- /// <param name="input">The input to read the field from</param>
- /// <param name="extensionRegistry">Registry to use when an extension field is encountered</param>
- /// <param name="builder">Builder to merge field into, if it's a known field</param>
- /// <param name="tag">The tag, which should already have been read from the input</param>
- /// <returns>true unless the tag is an end-group tag</returns>
- internal bool MergeFieldFrom(ICodedInputStream input,
- ExtensionRegistry extensionRegistry, IBuilder builder, uint tag,
- string fieldName)
- {
- if (tag == 0 && fieldName != null)
- {
- FieldDescriptor fieldByName = builder.DescriptorForType.FindFieldByName(fieldName);
- if (fieldByName != null)
- {
- tag = WireFormat.MakeTag(fieldByName);
- }
- else
- {
- ExtensionInfo extension = extensionRegistry.FindByName(builder.DescriptorForType, fieldName);
- if (extension != null)
- {
- tag = WireFormat.MakeTag(extension.Descriptor);
- }
- }
- }
-
- MessageDescriptor type = builder.DescriptorForType;
- if (type.Options.MessageSetWireFormat && tag == WireFormat.MessageSetTag.ItemStart)
- {
- MergeMessageSetExtensionFromCodedStream(input, extensionRegistry, builder);
- return true;
- }
-
- WireFormat.WireType wireType = WireFormat.GetTagWireType(tag);
- int fieldNumber = WireFormat.GetTagFieldNumber(tag);
-
- FieldDescriptor field;
- IMessageLite defaultFieldInstance = null;
-
- if (type.IsExtensionNumber(fieldNumber))
- {
- ExtensionInfo extension = extensionRegistry[type, fieldNumber];
- if (extension == null)
- {
- field = null;
- }
- else
- {
- field = extension.Descriptor;
- defaultFieldInstance = extension.DefaultInstance;
- }
- }
- else
- {
- field = type.FindFieldByNumber(fieldNumber);
- }
-
- // Unknown field or wrong wire type. Skip.
- if (field == null)
- {
- return MergeFieldFrom(tag, input);
- }
- if (wireType != WireFormat.GetWireType(field))
- {
- WireFormat.WireType expectedType = WireFormat.GetWireType(field.FieldType);
- if (wireType == expectedType)
- {
- //Allowed as of 2.3, this is unpacked data for a packed array
- }
- else if (field.IsRepeated && wireType == WireFormat.WireType.LengthDelimited &&
- (expectedType == WireFormat.WireType.Varint || expectedType == WireFormat.WireType.Fixed32 ||
- expectedType == WireFormat.WireType.Fixed64))
- {
- //Allowed as of 2.3, this is packed data for an unpacked array
- }
- else
- {
- return MergeFieldFrom(tag, input);
- }
- }
-
- switch (field.FieldType)
- {
- case FieldType.Group:
- case FieldType.Message:
- {
- IBuilderLite subBuilder = (defaultFieldInstance != null)
- ? defaultFieldInstance.WeakCreateBuilderForType()
- : builder.CreateBuilderForField(field);
- if (!field.IsRepeated)
- {
- subBuilder.WeakMergeFrom((IMessageLite) builder[field]);
- if (field.FieldType == FieldType.Group)
- {
- input.ReadGroup(field.FieldNumber, subBuilder, extensionRegistry);
- }
- else
- {
- input.ReadMessage(subBuilder, extensionRegistry);
- }
- builder[field] = subBuilder.WeakBuild();
- }
- else
- {
- List<IMessageLite> list = new List<IMessageLite>();
- if (field.FieldType == FieldType.Group)
- {
- input.ReadGroupArray(tag, fieldName, list, subBuilder.WeakDefaultInstanceForType,
- extensionRegistry);
- }
- else
- {
- input.ReadMessageArray(tag, fieldName, list, subBuilder.WeakDefaultInstanceForType,
- extensionRegistry);
- }
-
- foreach (IMessageLite m in list)
- {
- builder.WeakAddRepeatedField(field, m);
- }
- return true;
- }
- break;
- }
- case FieldType.Enum:
- {
- if (!field.IsRepeated)
- {
- object unknown;
- IEnumLite value = null;
- if (input.ReadEnum(ref value, out unknown, field.EnumType))
- {
- builder[field] = value;
- }
- else if (unknown is int)
- {
- MergeVarintField(fieldNumber, (ulong) (int) unknown);
- }
- }
- else
- {
- ICollection<object> unknown;
- List<IEnumLite> list = new List<IEnumLite>();
- input.ReadEnumArray(tag, fieldName, list, out unknown, field.EnumType);
-
- foreach (IEnumLite en in list)
- {
- builder.WeakAddRepeatedField(field, en);
- }
-
- if (unknown != null)
- {
- foreach (object oval in unknown)
- {
- if (oval is int)
- {
- MergeVarintField(fieldNumber, (ulong) (int) oval);
- }
- }
- }
- }
- break;
- }
- default:
- {
- if (!field.IsRepeated)
- {
- object value = null;
- if (input.ReadPrimitiveField(field.FieldType, ref value))
- {
- builder[field] = value;
- }
- }
- else
- {
- List<object> list = new List<object>();
- input.ReadPrimitiveArray(field.FieldType, tag, fieldName, list);
- foreach (object oval in list)
- {
- builder.WeakAddRepeatedField(field, oval);
- }
- }
- break;
- }
- }
- return true;
- }
-
- /// <summary>
- /// Called by MergeFieldFrom to parse a MessageSet extension.
- /// </summary>
- private void MergeMessageSetExtensionFromCodedStream(ICodedInputStream input,
- ExtensionRegistry extensionRegistry, IBuilder builder)
- {
- MessageDescriptor type = builder.DescriptorForType;
-
- // The wire format for MessageSet is:
- // message MessageSet {
- // repeated group Item = 1 {
- // required int32 typeId = 2;
- // required bytes message = 3;
- // }
- // }
- // "typeId" is the extension's field number. The extension can only be
- // a message type, where "message" contains the encoded bytes of that
- // message.
- //
- // In practice, we will probably never see a MessageSet item in which
- // the message appears before the type ID, or where either field does not
- // appear exactly once. However, in theory such cases are valid, so we
- // should be prepared to accept them.
-
- int typeId = 0;
- ByteString rawBytes = null; // If we encounter "message" before "typeId"
- IBuilderLite subBuilder = null;
- FieldDescriptor field = null;
-
- uint lastTag = WireFormat.MessageSetTag.ItemStart;
- uint tag;
- string name;
- while (input.ReadTag(out tag, out name))
- {
- if (tag == 0 && name != null)
- {
- if (name == "type_id")
- {
- tag = WireFormat.MessageSetTag.TypeID;
- }
- else if (name == "message")
- {
- tag = WireFormat.MessageSetTag.Message;
- }
- }
- if (tag == 0)
- {
- if (input.SkipField())
- {
- continue; //can't merge unknown without field tag
- }
- break;
- }
-
- lastTag = tag;
- if (tag == WireFormat.MessageSetTag.TypeID)
- {
- typeId = 0;
- // Zero is not a valid type ID.
- if (input.ReadInt32(ref typeId) && typeId != 0)
- {
- ExtensionInfo extension = extensionRegistry[type, typeId];
- if (extension != null)
- {
- field = extension.Descriptor;
- subBuilder = extension.DefaultInstance.WeakCreateBuilderForType();
- IMessageLite originalMessage = (IMessageLite) builder[field];
- if (originalMessage != null)
- {
- subBuilder.WeakMergeFrom(originalMessage);
- }
- if (rawBytes != null)
- {
- // We already encountered the message. Parse it now.
- // TODO(jonskeet): Check this is okay. It's subtly different from the Java, as it doesn't create an input stream from rawBytes.
- // In fact, why don't we just call MergeFrom(rawBytes)? And what about the extension registry?
- subBuilder.WeakMergeFrom(rawBytes.CreateCodedInput());
- rawBytes = null;
- }
- }
- else
- {
- // Unknown extension number. If we already saw data, put it
- // in rawBytes.
- if (rawBytes != null)
- {
- MergeField(typeId, UnknownField.CreateBuilder().AddLengthDelimited(rawBytes).Build());
- rawBytes = null;
- }
- }
- }
- }
- else if (tag == WireFormat.MessageSetTag.Message)
- {
- if (subBuilder != null)
- {
- // We already know the type, so we can parse directly from the input
- // with no copying. Hooray!
- input.ReadMessage(subBuilder, extensionRegistry);
- }
- else if (input.ReadBytes(ref rawBytes))
- {
- if (typeId != 0)
- {
- // We don't know how to parse this. Ignore it.
- MergeField(typeId,
- UnknownField.CreateBuilder().AddLengthDelimited(rawBytes).Build());
- }
- }
- }
- else
- {
- // Unknown tag. Skip it.
- if (!input.SkipField())
- {
- break; // end of group
- }
- }
- }
-
- if (lastTag != WireFormat.MessageSetTag.ItemEnd)
- {
- throw InvalidProtocolBufferException.InvalidEndTag();
- }
-
- if (subBuilder != null)
- {
- builder[field] = subBuilder.WeakBuild();
- }
- }
-
- #region IBuilderLite Members
-
- bool IBuilderLite.IsInitialized
- {
- get { return fields != null; }
- }
-
- IBuilderLite IBuilderLite.WeakClear()
- {
- return Clear();
- }
-
- IBuilderLite IBuilderLite.WeakMergeFrom(IMessageLite message)
- {
- return MergeFrom((UnknownFieldSet) message);
- }
-
- IBuilderLite IBuilderLite.WeakMergeFrom(ByteString data)
- {
- return MergeFrom(data);
- }
-
- IBuilderLite IBuilderLite.WeakMergeFrom(ByteString data, ExtensionRegistry registry)
- {
- return MergeFrom(data);
- }
-
- IBuilderLite IBuilderLite.WeakMergeFrom(ICodedInputStream input)
- {
- return MergeFrom(input);
- }
-
- IBuilderLite IBuilderLite.WeakMergeFrom(ICodedInputStream input, ExtensionRegistry registry)
- {
- return MergeFrom(input);
- }
-
- IMessageLite IBuilderLite.WeakBuild()
- {
- return Build();
- }
-
- IMessageLite IBuilderLite.WeakBuildPartial()
- {
- return Build();
- }
-
- IBuilderLite IBuilderLite.WeakClone()
- {
- return Build().WeakToBuilder();
- }
-
- IMessageLite IBuilderLite.WeakDefaultInstanceForType
- {
- get { return DefaultInstance; }
- }
-
- #endregion
- }
- }
-}
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/WireFormat.cs b/csharp/src/ProtocolBuffers/WireFormat.cs index b9daa328..87f7c358 100644 --- a/csharp/src/ProtocolBuffers/WireFormat.cs +++ b/csharp/src/ProtocolBuffers/WireFormat.cs @@ -35,9 +35,9 @@ #endregion
using System;
-using Google.ProtocolBuffers.Descriptors;
+using Google.Protobuf.Descriptors;
-namespace Google.ProtocolBuffers
+namespace Google.Protobuf
{
/// <summary>
/// This class is used internally by the Protocol Buffer Library and generated
|