aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtocolBuffers
diff options
context:
space:
mode:
authorJon Skeet <skeet@pobox.com>2015-06-12 09:53:12 +0100
committerJon Skeet <skeet@pobox.com>2015-06-12 09:53:12 +0100
commit96ddf01aed1a49d73a7fda50e28c431ffc977e5a (patch)
tree4f603245ff514486481f126ca8d81deeff572534 /csharp/src/ProtocolBuffers
parent39aaf21d5194fdc07c296847def8e7795279e041 (diff)
downloadprotobuf-96ddf01aed1a49d73a7fda50e28c431ffc977e5a.tar.gz
protobuf-96ddf01aed1a49d73a7fda50e28c431ffc977e5a.tar.bz2
protobuf-96ddf01aed1a49d73a7fda50e28c431ffc977e5a.zip
Coded*Stream streamlining.
Remove ICodedInputStream and ICodedOutputStream, and rewrite CodedInputStream and CodedOutputStream to be specific to the binary format. If we want to support text-based formats, that can be a whole different serialization mechanism.
Diffstat (limited to 'csharp/src/ProtocolBuffers')
-rw-r--r--csharp/src/ProtocolBuffers/CodedInputStream.cs427
-rw-r--r--csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs132
-rw-r--r--csharp/src/ProtocolBuffers/CodedOutputStream.cs249
-rw-r--r--csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs719
-rw-r--r--csharp/src/ProtocolBuffers/Extensions.cs2
-rw-r--r--csharp/src/ProtocolBuffers/ICodedInputStream.cs293
-rw-r--r--csharp/src/ProtocolBuffers/ICodedOutputStream.cs347
-rw-r--r--csharp/src/ProtocolBuffers/IMessage.cs4
-rw-r--r--csharp/src/ProtocolBuffers/MessageParser.cs2
-rw-r--r--csharp/src/ProtocolBuffers/ProtocolBuffers.csproj2
10 files changed, 423 insertions, 1754 deletions
diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs
index d5cab6fd..cb47f1c2 100644
--- a/csharp/src/ProtocolBuffers/CodedInputStream.cs
+++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs
@@ -58,7 +58,7 @@ namespace Google.Protobuf
/// 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 +173,6 @@ namespace Google.Protobuf
}
}
-
- void ICodedInputStream.ReadMessageStart() { }
- void ICodedInputStream.ReadMessageEnd() { }
-
#region Validation
/// <summary>
@@ -201,17 +197,16 @@ namespace Google.Protobuf
/// <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 +217,9 @@ namespace Google.Protobuf
/// 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 +248,21 @@ namespace Google.Protobuf
/// <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 FrameworkPortability.Int64ToDouble((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,76 +271,68 @@ namespace Google.Protobuf
{
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)
{
@@ -356,12 +340,10 @@ namespace Google.Protobuf
// just copy directly from it.
String result = Encoding.UTF8.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;
+ return Encoding.UTF8.GetString(ReadRawBytes(size), 0, size);
}
/// <summary>
@@ -400,7 +382,7 @@ namespace Google.Protobuf
/// <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)
@@ -409,24 +391,21 @@ namespace Google.Protobuf
// 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)
+ public uint ReadUInt32()
{
- value = ReadRawVarint32();
- return true;
+ return ReadRawVarint32();
}
/// <summary>
@@ -434,47 +413,42 @@ namespace Google.Protobuf
/// 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(ref int value)
+ public int ReadEnum()
{
// Currently just a pass-through, but it's nice to separate it logically from WriteInt32.
- value = (int) ReadRawVarint32();
- return true;
+ 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)
@@ -502,9 +476,8 @@ namespace Google.Protobuf
/// </summary>
private bool ContinueArray(uint currentTag)
{
- string ignore;
uint next;
- if (PeekNextTag(out next, out ignore))
+ if (PeekNextTag(out next))
{
if (next == currentTag)
{
@@ -530,9 +503,8 @@ namespace Google.Protobuf
return true;
}
- string ignore;
uint next;
- if (PeekNextTag(out next, out ignore))
+ if (PeekNextTag(out next))
{
if (next == currentTag)
{
@@ -543,259 +515,194 @@ namespace Google.Protobuf
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)
+ public void ReadStringArray(uint fieldTag, ICollection<string> list)
{
- string tmp = null;
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(uint fieldTag, ICollection<ByteString> list)
{
- ByteString tmp = null;
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(uint fieldTag, ICollection<bool> list)
{
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(uint fieldTag, ICollection<int> list)
{
- // TODO(jonskeet): Work out how this works for non-packed values. (It doesn't look like it does...)
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(uint fieldTag, ICollection<int> list)
{
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(uint fieldTag, ICollection<uint> list)
{
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(uint fieldTag, ICollection<uint> list)
{
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(uint fieldTag, ICollection<int> list)
{
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(uint fieldTag, ICollection<long> list)
{
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(uint fieldTag, ICollection<long> list)
{
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(uint fieldTag, ICollection<ulong> list)
{
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(uint fieldTag, ICollection<ulong> list)
{
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(uint fieldTag, ICollection<long> list)
{
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(uint fieldTag, ICollection<double> list)
{
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(uint fieldTag, ICollection<float> list)
{
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<T>(uint fieldTag, string fieldName, ICollection<T> list)
+ public void ReadEnumArray<T>(uint fieldTag, ICollection<T> list)
where T : struct, IComparable, IFormattable
{
- int value = 0;
WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag);
// 2.3 allows packed form even if the field is not declared packed.
@@ -805,9 +712,8 @@ namespace Google.Protobuf
int limit = PushLimit(length);
while (!ReachedLimit)
{
- ReadEnum(ref value);
// TODO(jonskeet): Avoid this horrible boxing!
- list.Add((T)(object)value);
+ list.Add((T)(object) ReadEnum());
}
PopLimit(limit);
}
@@ -815,14 +721,12 @@ namespace Google.Protobuf
{
do
{
- ReadEnum(ref value);
- // TODO(jonskeet): Avoid this horrible boxing!
- list.Add((T)(object) value);
+ list.Add((T)(object) ReadEnum());
} while (ContinueArray(fieldTag));
}
}
- public void ReadMessageArray<T>(uint fieldTag, string fieldName, ICollection<T> list, MessageParser<T> messageParser)
+ public void ReadMessageArray<T>(uint fieldTag, ICollection<T> list, MessageParser<T> messageParser)
where T : IMessage<T>
{
do
@@ -833,7 +737,7 @@ namespace Google.Protobuf
} while (ContinueArray(fieldTag));
}
- public void ReadGroupArray<T>(uint fieldTag, string fieldName, ICollection<T> list, MessageParser<T> messageParser)
+ public void ReadGroupArray<T>(uint fieldTag, ICollection<T> list, MessageParser<T> messageParser)
where T : IMessage<T>
{
do
@@ -843,178 +747,6 @@ namespace Google.Protobuf
list.Add(message);
} 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
@@ -1622,8 +1354,7 @@ namespace Google.Protobuf
public void SkipMessage()
{
uint tag;
- string name;
- while (ReadTag(out tag, out name))
+ while (ReadTag(out tag))
{
if (!SkipField())
{
diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
index 96be9db5..b7629d7c 100644
--- a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
+++ b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
@@ -413,41 +413,12 @@ namespace Google.Protobuf
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, IMessage 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>
public static int ComputeRawVarint32Size(uint value)
{
+ // TODO(jonskeet): Look at optimizing this to just hard-coded comparisons.
if ((value & (0xffffffff << 7)) == 0)
{
return 1;
@@ -472,6 +443,7 @@ namespace Google.Protobuf
/// </summary>
public static int ComputeRawVarint64Size(ulong value)
{
+ // TODO(jonskeet): Look at optimizing this to just hard-coded comparisons.
if ((value & (0xffffffffffffffffL << 7)) == 0)
{
return 1;
@@ -512,106 +484,6 @@ namespace Google.Protobuf
}
/// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// field of arbitrary type, including the tag, to the stream.
- /// </summary>
- // TODO(jonskeet): Why do we need this?
- 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, (IMessage) value);
- case FieldType.Message:
- return ComputeMessageSize(fieldNumber, (IMessage) 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:
- return ComputeEnumSize(fieldNumber, (int) value);
- 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>
- // TODO(jonskeet): Why do we need this?
- 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((IMessage) value);
- case FieldType.Message:
- return ComputeMessageSizeNoTag((IMessage) 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:
- return ComputeEnumSizeNoTag((int) value);
- 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 e3f0c700..132f8067 100644
--- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs
+++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs
@@ -57,7 +57,7 @@ namespace Google.Protobuf
/// 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
{
private static readonly Encoding UTF8 = Encoding.UTF8;
@@ -143,76 +143,11 @@ namespace Google.Protobuf
}
}
- void ICodedOutputStream.WriteMessageStart() { }
- void ICodedOutputStream.WriteMessageEnd() { Flush(); }
-
#region Writing of tags and fields
-
- // TODO(jonskeet): Do we need this?
- 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, (IMessage) value);
- break;
- case FieldType.Group:
- WriteGroup(fieldNumber, fieldName, (IMessage) value);
- break;
- case FieldType.Bytes:
- WriteBytes(fieldNumber, fieldName, (ByteString) value);
- break;
- case FieldType.Bool:
- WriteBool(fieldNumber, fieldName, (bool) value);
- break;
- case FieldType.Enum:
- throw new NotImplementedException();
- 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)
+ public void WriteDouble(int fieldNumber, double value)
{
WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
WriteDoubleNoTag(value);
@@ -221,7 +156,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a float field value, including tag, to the stream.
/// </summary>
- public void WriteFloat(int fieldNumber, string fieldName, float value)
+ public void WriteFloat(int fieldNumber, float value)
{
WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
WriteFloatNoTag(value);
@@ -230,7 +165,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a uint64 field value, including tag, to the stream.
/// </summary>
- public void WriteUInt64(int fieldNumber, string fieldName, ulong value)
+ public void WriteUInt64(int fieldNumber, ulong value)
{
WriteTag(fieldNumber, WireFormat.WireType.Varint);
WriteRawVarint64(value);
@@ -239,7 +174,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes an int64 field value, including tag, to the stream.
/// </summary>
- public void WriteInt64(int fieldNumber, string fieldName, long value)
+ public void WriteInt64(int fieldNumber, long value)
{
WriteTag(fieldNumber, WireFormat.WireType.Varint);
WriteRawVarint64((ulong) value);
@@ -248,7 +183,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes an int32 field value, including tag, to the stream.
/// </summary>
- public void WriteInt32(int fieldNumber, string fieldName, int value)
+ public void WriteInt32(int fieldNumber, int value)
{
WriteTag(fieldNumber, WireFormat.WireType.Varint);
if (value >= 0)
@@ -265,7 +200,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a fixed64 field value, including tag, to the stream.
/// </summary>
- public void WriteFixed64(int fieldNumber, string fieldName, ulong value)
+ public void WriteFixed64(int fieldNumber, ulong value)
{
WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
WriteRawLittleEndian64(value);
@@ -274,7 +209,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a fixed32 field value, including tag, to the stream.
/// </summary>
- public void WriteFixed32(int fieldNumber, string fieldName, uint value)
+ public void WriteFixed32(int fieldNumber, uint value)
{
WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
WriteRawLittleEndian32(value);
@@ -283,7 +218,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a bool field value, including tag, to the stream.
/// </summary>
- public void WriteBool(int fieldNumber, string fieldName, bool value)
+ public void WriteBool(int fieldNumber, bool value)
{
WriteTag(fieldNumber, WireFormat.WireType.Varint);
WriteRawByte(value ? (byte) 1 : (byte) 0);
@@ -292,7 +227,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a string field value, including tag, to the stream.
/// </summary>
- public void WriteString(int fieldNumber, string fieldName, string value)
+ public void WriteString(int fieldNumber, string value)
{
WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
// Optimise the case where we have enough space to write
@@ -324,80 +259,63 @@ namespace Google.Protobuf
/// <summary>
/// Writes a group field value, including tag, to the stream.
/// </summary>
- public void WriteGroup(int fieldNumber, string fieldName, IMessage value)
+ public void WriteGroup(int fieldNumber, IMessage value)
{
WriteTag(fieldNumber, WireFormat.WireType.StartGroup);
value.WriteTo(this);
WriteTag(fieldNumber, WireFormat.WireType.EndGroup);
}
- public void WriteMessage(int fieldNumber, string fieldName, IMessage value)
+ public void WriteMessage(int fieldNumber, IMessage value)
{
WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
WriteRawVarint32((uint) value.CalculateSize());
value.WriteTo(this);
}
- public void WriteBytes(int fieldNumber, string fieldName, ByteString value)
+ public void WriteBytes(int fieldNumber, ByteString value)
{
WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
WriteRawVarint32((uint) value.Length);
value.WriteRawBytesTo(this);
}
- public void WriteUInt32(int fieldNumber, string fieldName, uint value)
+ public void WriteUInt32(int fieldNumber, uint value)
{
WriteTag(fieldNumber, WireFormat.WireType.Varint);
WriteRawVarint32(value);
}
- public void WriteEnum(int fieldNumber, string fieldName, int value)
+ public void WriteEnum(int fieldNumber, int value)
{
// Currently just a pass-through, but it's nice to separate it logically from WriteInt32.
WriteTag(fieldNumber, WireFormat.WireType.Varint);
WriteInt32NoTag(value);
}
- public void WriteSFixed32(int fieldNumber, string fieldName, int value)
+ public void WriteSFixed32(int fieldNumber, int value)
{
WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
WriteRawLittleEndian32((uint) value);
}
- public void WriteSFixed64(int fieldNumber, string fieldName, long value)
+ public void WriteSFixed64(int fieldNumber, long value)
{
WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
WriteRawLittleEndian64((ulong) value);
}
- public void WriteSInt32(int fieldNumber, string fieldName, int value)
+ public void WriteSInt32(int fieldNumber, int value)
{
WriteTag(fieldNumber, WireFormat.WireType.Varint);
WriteRawVarint32(EncodeZigZag32(value));
}
- public void WriteSInt64(int fieldNumber, string fieldName, long value)
+ public void WriteSInt64(int fieldNumber, long value)
{
WriteTag(fieldNumber, WireFormat.WireType.Varint);
WriteRawVarint64(EncodeZigZag64(value));
}
-
- public void WriteMessageSetExtension(int fieldNumber, string fieldName, IMessage 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
@@ -625,155 +543,145 @@ namespace Google.Protobuf
#endregion
#region Write array members
-
- // TODO(jonskeet): Remove?
- public void WriteArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list)
- {
- foreach (object element in list)
- {
- WriteField(fieldType, fieldNumber, fieldName, element);
- }
- }
-
- public void WriteGroupArray<T>(int fieldNumber, string fieldName, RepeatedField<T> list)
+ public void WriteGroupArray<T>(int fieldNumber, RepeatedField<T> list)
where T : IMessage
{
foreach (IMessage value in list)
{
- WriteGroup(fieldNumber, fieldName, value);
+ WriteGroup(fieldNumber, value);
}
}
- public void WriteMessageArray<T>(int fieldNumber, string fieldName, RepeatedField<T> list)
+ public void WriteMessageArray<T>(int fieldNumber, RepeatedField<T> list)
where T : IMessage
{
foreach (IMessage value in list)
{
- WriteMessage(fieldNumber, fieldName, value);
+ WriteMessage(fieldNumber, value);
}
}
- public void WriteStringArray(int fieldNumber, string fieldName, RepeatedField<string> list)
+ public void WriteStringArray(int fieldNumber, RepeatedField<string> list)
{
foreach (var value in list)
{
- WriteString(fieldNumber, fieldName, value);
+ WriteString(fieldNumber, value);
}
}
- public void WriteBytesArray(int fieldNumber, string fieldName, RepeatedField<ByteString> list)
+ public void WriteBytesArray(int fieldNumber, RepeatedField<ByteString> list)
{
foreach (var value in list)
{
- WriteBytes(fieldNumber, fieldName, value);
+ WriteBytes(fieldNumber, value);
}
}
- public void WriteBoolArray(int fieldNumber, string fieldName, RepeatedField<bool> list)
+ public void WriteBoolArray(int fieldNumber, RepeatedField<bool> list)
{
foreach (var value in list)
{
- WriteBool(fieldNumber, fieldName, value);
+ WriteBool(fieldNumber, value);
}
}
- public void WriteInt32Array(int fieldNumber, string fieldName, RepeatedField<int> list)
+ public void WriteInt32Array(int fieldNumber, RepeatedField<int> list)
{
foreach (var value in list)
{
- WriteInt32(fieldNumber, fieldName, value);
+ WriteInt32(fieldNumber, value);
}
}
- public void WriteSInt32Array(int fieldNumber, string fieldName, RepeatedField<int> list)
+ public void WriteSInt32Array(int fieldNumber, RepeatedField<int> list)
{
foreach (var value in list)
{
- WriteSInt32(fieldNumber, fieldName, value);
+ WriteSInt32(fieldNumber, value);
}
}
- public void WriteUInt32Array(int fieldNumber, string fieldName, RepeatedField<uint> list)
+ public void WriteUInt32Array(int fieldNumber, RepeatedField<uint> list)
{
foreach (var value in list)
{
- WriteUInt32(fieldNumber, fieldName, value);
+ WriteUInt32(fieldNumber, value);
}
}
- public void WriteFixed32Array(int fieldNumber, string fieldName, RepeatedField<uint> list)
+ public void WriteFixed32Array(int fieldNumber, RepeatedField<uint> list)
{
foreach (var value in list)
{
- WriteFixed32(fieldNumber, fieldName, value);
+ WriteFixed32(fieldNumber, value);
}
}
- public void WriteSFixed32Array(int fieldNumber, string fieldName, RepeatedField<int> list)
+ public void WriteSFixed32Array(int fieldNumber, RepeatedField<int> list)
{
foreach (var value in list)
{
- WriteSFixed32(fieldNumber, fieldName, value);
+ WriteSFixed32(fieldNumber, value);
}
}
- public void WriteInt64Array(int fieldNumber, string fieldName, RepeatedField<long> list)
+ public void WriteInt64Array(int fieldNumber, RepeatedField<long> list)
{
foreach (var value in list)
{
- WriteInt64(fieldNumber, fieldName, value);
+ WriteInt64(fieldNumber, value);
}
}
- public void WriteSInt64Array(int fieldNumber, string fieldName, RepeatedField<long> list)
+ public void WriteSInt64Array(int fieldNumber, RepeatedField<long> list)
{
foreach (var value in list)
{
- WriteSInt64(fieldNumber, fieldName, value);
+ WriteSInt64(fieldNumber, value);
}
}
- public void WriteUInt64Array(int fieldNumber, string fieldName, RepeatedField<ulong> list)
+ public void WriteUInt64Array(int fieldNumber, RepeatedField<ulong> list)
{
foreach (var value in list)
{
- WriteUInt64(fieldNumber, fieldName, value);
+ WriteUInt64(fieldNumber, value);
}
}
- public void WriteFixed64Array(int fieldNumber, string fieldName, RepeatedField<ulong> list)
+ public void WriteFixed64Array(int fieldNumber, RepeatedField<ulong> list)
{
foreach (var value in list)
{
- WriteFixed64(fieldNumber, fieldName, value);
+ WriteFixed64(fieldNumber, value);
}
}
- public void WriteSFixed64Array(int fieldNumber, string fieldName, RepeatedField<long> list)
+ public void WriteSFixed64Array(int fieldNumber, RepeatedField<long> list)
{
foreach (var value in list)
{
- WriteSFixed64(fieldNumber, fieldName, value);
+ WriteSFixed64(fieldNumber, value);
}
}
- public void WriteDoubleArray(int fieldNumber, string fieldName, RepeatedField<double> list)
+ public void WriteDoubleArray(int fieldNumber, RepeatedField<double> list)
{
foreach (var value in list)
{
- WriteDouble(fieldNumber, fieldName, value);
+ WriteDouble(fieldNumber, value);
}
}
- public void WriteFloatArray(int fieldNumber, string fieldName, RepeatedField<float> list)
+ public void WriteFloatArray(int fieldNumber, RepeatedField<float> list)
{
foreach (var value in list)
{
- WriteFloat(fieldNumber, fieldName, value);
+ WriteFloat(fieldNumber, value);
}
}
- public void WriteEnumArray<T>(int fieldNumber, string fieldName, RepeatedField<T> list)
+ public void WriteEnumArray<T>(int fieldNumber, RepeatedField<T> list)
where T : struct, IComparable, IFormattable
{
if (list.Count == 0)
@@ -783,34 +691,15 @@ namespace Google.Protobuf
// TODO(jonskeet): Avoid the Cast call here. Work out a better mass "T to int" conversion.
foreach (int value in list.Cast<int>())
{
- WriteEnum(fieldNumber, fieldName, value);
+ WriteEnum(fieldNumber, value);
}
}
#endregion
#region Write packed array members
-
- // TODO(jonskeet): Remove?
- public void WritePackedArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list)
- {
- int calculatedSize = 0;
- foreach (object element in list)
- {
- calculatedSize += ComputeFieldSizeNoTag(fieldType, element);
- }
-
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) calculatedSize);
-
- foreach (object element in list)
- {
- WriteFieldNoTag(fieldType, element);
- }
- }
-
// TODO(jonskeet): A lot of these are really inefficient, due to method group conversions. Fix!
- public void WritePackedBoolArray(int fieldNumber, string fieldName, RepeatedField<bool> list)
+ public void WritePackedBoolArray(int fieldNumber, RepeatedField<bool> list)
{
if (list.Count == 0)
{
@@ -825,7 +714,7 @@ namespace Google.Protobuf
}
}
- public void WritePackedInt32Array(int fieldNumber, string fieldName, RepeatedField<int> list)
+ public void WritePackedInt32Array(int fieldNumber, RepeatedField<int> list)
{
if (list.Count == 0)
{
@@ -840,7 +729,7 @@ namespace Google.Protobuf
}
}
- public void WritePackedSInt32Array(int fieldNumber, string fieldName, RepeatedField<int> list)
+ public void WritePackedSInt32Array(int fieldNumber, RepeatedField<int> list)
{
if (list.Count == 0)
{
@@ -855,7 +744,7 @@ namespace Google.Protobuf
}
}
- public void WritePackedUInt32Array(int fieldNumber, string fieldName, RepeatedField<uint> list)
+ public void WritePackedUInt32Array(int fieldNumber, RepeatedField<uint> list)
{
if (list.Count == 0)
{
@@ -870,7 +759,7 @@ namespace Google.Protobuf
}
}
- public void WritePackedFixed32Array(int fieldNumber, string fieldName, RepeatedField<uint> list)
+ public void WritePackedFixed32Array(int fieldNumber, RepeatedField<uint> list)
{
if (list.Count == 0)
{
@@ -885,7 +774,7 @@ namespace Google.Protobuf
}
}
- public void WritePackedSFixed32Array(int fieldNumber, string fieldName, RepeatedField<int> list)
+ public void WritePackedSFixed32Array(int fieldNumber, RepeatedField<int> list)
{
if (list.Count == 0)
{
@@ -900,7 +789,7 @@ namespace Google.Protobuf
}
}
- public void WritePackedInt64Array(int fieldNumber, string fieldName, RepeatedField<long> list)
+ public void WritePackedInt64Array(int fieldNumber, RepeatedField<long> list)
{
if (list.Count == 0)
{
@@ -915,7 +804,7 @@ namespace Google.Protobuf
}
}
- public void WritePackedSInt64Array(int fieldNumber, string fieldName, RepeatedField<long> list)
+ public void WritePackedSInt64Array(int fieldNumber, RepeatedField<long> list)
{
if (list.Count == 0)
{
@@ -930,7 +819,7 @@ namespace Google.Protobuf
}
}
- public void WritePackedUInt64Array(int fieldNumber, string fieldName, RepeatedField<ulong> list)
+ public void WritePackedUInt64Array(int fieldNumber, RepeatedField<ulong> list)
{
if (list.Count == 0)
{
@@ -945,7 +834,7 @@ namespace Google.Protobuf
}
}
- public void WritePackedFixed64Array(int fieldNumber, string fieldName, RepeatedField<ulong> list)
+ public void WritePackedFixed64Array(int fieldNumber, RepeatedField<ulong> list)
{
if (list.Count == 0)
{
@@ -960,7 +849,7 @@ namespace Google.Protobuf
}
}
- public void WritePackedSFixed64Array(int fieldNumber, string fieldName, RepeatedField<long> list)
+ public void WritePackedSFixed64Array(int fieldNumber, RepeatedField<long> list)
{
if (list.Count == 0)
{
@@ -975,7 +864,7 @@ namespace Google.Protobuf
}
}
- public void WritePackedDoubleArray(int fieldNumber, string fieldName, RepeatedField<double> list)
+ public void WritePackedDoubleArray(int fieldNumber, RepeatedField<double> list)
{
if (list.Count == 0)
{
@@ -990,7 +879,7 @@ namespace Google.Protobuf
}
}
- public void WritePackedFloatArray(int fieldNumber, string fieldName, RepeatedField<float> list)
+ public void WritePackedFloatArray(int fieldNumber, RepeatedField<float> list)
{
if (list.Count == 0)
{
@@ -1005,7 +894,7 @@ namespace Google.Protobuf
}
}
- public void WritePackedEnumArray<T>(int fieldNumber, string fieldName, RepeatedField<T> list)
+ public void WritePackedEnumArray<T>(int fieldNumber, RepeatedField<T> list)
where T : struct, IComparable, IFormattable
{
if (list.Count == 0)
diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
index eb96dfcf..f4af4e2c 100644
--- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
+++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
@@ -323,9 +323,8 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
- output.WriteMessageArray(1, fieldNames[0], file_);
+ public void WriteTo(pb::CodedOutputStream output) {
+ output.WriteMessageArray(1, file_);
}
public int CalculateSize() {
@@ -342,16 +341,9 @@ namespace Google.Protobuf.DescriptorProtos {
file_.Add(other.file_);
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -361,7 +353,7 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 10: {
- input.ReadMessageArray(tag, fieldName, file_, global::Google.Protobuf.DescriptorProtos.FileDescriptorProto.Parser);
+ input.ReadMessageArray(tag, file_, global::Google.Protobuf.DescriptorProtos.FileDescriptorProto.Parser);
break;
}
}
@@ -510,29 +502,28 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Name != "") {
- output.WriteString(1, fieldNames[4], Name);
+ output.WriteString(1, Name);
}
if (Package != "") {
- output.WriteString(2, fieldNames[6], Package);
+ output.WriteString(2, Package);
}
- output.WriteStringArray(3, fieldNames[0], dependency_);
- output.WriteMessageArray(4, fieldNames[3], messageType_);
- output.WriteMessageArray(5, fieldNames[1], enumType_);
- output.WriteMessageArray(6, fieldNames[8], service_);
- output.WriteMessageArray(7, fieldNames[2], extension_);
+ output.WriteStringArray(3, dependency_);
+ output.WriteMessageArray(4, messageType_);
+ output.WriteMessageArray(5, enumType_);
+ output.WriteMessageArray(6, service_);
+ output.WriteMessageArray(7, extension_);
if (options_ != null) {
- output.WriteMessage(8, fieldNames[5], Options);
+ output.WriteMessage(8, Options);
}
if (sourceCodeInfo_ != null) {
- output.WriteMessage(9, fieldNames[9], SourceCodeInfo);
+ output.WriteMessage(9, SourceCodeInfo);
}
- output.WriteInt32Array(10, fieldNames[7], publicDependency_);
- output.WriteInt32Array(11, fieldNames[11], weakDependency_);
+ output.WriteInt32Array(10, publicDependency_);
+ output.WriteInt32Array(11, weakDependency_);
if (Syntax != "") {
- output.WriteString(12, fieldNames[10], Syntax);
+ output.WriteString(12, Syntax);
}
}
@@ -625,16 +616,9 @@ namespace Google.Protobuf.DescriptorProtos {
}
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -644,31 +628,31 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 10: {
- input.ReadString(ref name_);
+ name_ = input.ReadString();
break;
}
case 18: {
- input.ReadString(ref package_);
+ package_ = input.ReadString();
break;
}
case 26: {
- input.ReadStringArray(tag, fieldName, dependency_);
+ input.ReadStringArray(tag, dependency_);
break;
}
case 34: {
- input.ReadMessageArray(tag, fieldName, messageType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser);
+ input.ReadMessageArray(tag, messageType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser);
break;
}
case 42: {
- input.ReadMessageArray(tag, fieldName, enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser);
+ input.ReadMessageArray(tag, enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser);
break;
}
case 50: {
- input.ReadMessageArray(tag, fieldName, service_, global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto.Parser);
+ input.ReadMessageArray(tag, service_, global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto.Parser);
break;
}
case 58: {
- input.ReadMessageArray(tag, fieldName, extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser);
+ input.ReadMessageArray(tag, extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser);
break;
}
case 66: {
@@ -687,16 +671,16 @@ namespace Google.Protobuf.DescriptorProtos {
}
case 82:
case 80: {
- input.ReadInt32Array(tag, fieldName, publicDependency_);
+ input.ReadInt32Array(tag, publicDependency_);
break;
}
case 90:
case 88: {
- input.ReadInt32Array(tag, fieldName, weakDependency_);
+ input.ReadInt32Array(tag, weakDependency_);
break;
}
case 98: {
- input.ReadString(ref syntax_);
+ syntax_ = input.ReadString();
break;
}
}
@@ -825,22 +809,21 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Name != "") {
- output.WriteString(1, fieldNames[4], Name);
+ output.WriteString(1, Name);
}
- output.WriteMessageArray(2, fieldNames[3], field_);
- output.WriteMessageArray(3, fieldNames[5], nestedType_);
- output.WriteMessageArray(4, fieldNames[0], enumType_);
- output.WriteMessageArray(5, fieldNames[2], extensionRange_);
- output.WriteMessageArray(6, fieldNames[1], extension_);
+ output.WriteMessageArray(2, field_);
+ output.WriteMessageArray(3, nestedType_);
+ output.WriteMessageArray(4, enumType_);
+ output.WriteMessageArray(5, extensionRange_);
+ output.WriteMessageArray(6, extension_);
if (options_ != null) {
- output.WriteMessage(7, fieldNames[7], Options);
+ output.WriteMessage(7, Options);
}
- output.WriteMessageArray(8, fieldNames[6], oneofDecl_);
- output.WriteMessageArray(9, fieldNames[9], reservedRange_);
- output.WriteStringArray(10, fieldNames[8], reservedName_);
+ output.WriteMessageArray(8, oneofDecl_);
+ output.WriteMessageArray(9, reservedRange_);
+ output.WriteStringArray(10, reservedName_);
}
public int CalculateSize() {
@@ -905,16 +888,9 @@ namespace Google.Protobuf.DescriptorProtos {
reservedName_.Add(other.reservedName_);
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -924,27 +900,27 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 10: {
- input.ReadString(ref name_);
+ name_ = input.ReadString();
break;
}
case 18: {
- input.ReadMessageArray(tag, fieldName, field_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser);
+ input.ReadMessageArray(tag, field_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser);
break;
}
case 26: {
- input.ReadMessageArray(tag, fieldName, nestedType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser);
+ input.ReadMessageArray(tag, nestedType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser);
break;
}
case 34: {
- input.ReadMessageArray(tag, fieldName, enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser);
+ input.ReadMessageArray(tag, enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser);
break;
}
case 42: {
- input.ReadMessageArray(tag, fieldName, extensionRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Parser);
+ input.ReadMessageArray(tag, extensionRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Parser);
break;
}
case 50: {
- input.ReadMessageArray(tag, fieldName, extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser);
+ input.ReadMessageArray(tag, extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser);
break;
}
case 58: {
@@ -955,15 +931,15 @@ namespace Google.Protobuf.DescriptorProtos {
break;
}
case 66: {
- input.ReadMessageArray(tag, fieldName, oneofDecl_, global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto.Parser);
+ input.ReadMessageArray(tag, oneofDecl_, global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto.Parser);
break;
}
case 74: {
- input.ReadMessageArray(tag, fieldName, reservedRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange.Parser);
+ input.ReadMessageArray(tag, reservedRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange.Parser);
break;
}
case 82: {
- input.ReadStringArray(tag, fieldName, reservedName_);
+ input.ReadStringArray(tag, reservedName_);
break;
}
}
@@ -1031,13 +1007,12 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Start != 0) {
- output.WriteInt32(1, fieldNames[1], Start);
+ output.WriteInt32(1, Start);
}
if (End != 0) {
- output.WriteInt32(2, fieldNames[0], End);
+ output.WriteInt32(2, End);
}
}
@@ -1063,16 +1038,9 @@ namespace Google.Protobuf.DescriptorProtos {
}
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -1082,11 +1050,11 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 8: {
- input.ReadInt32(ref start_);
+ start_ = input.ReadInt32();
break;
}
case 16: {
- input.ReadInt32(ref end_);
+ end_ = input.ReadInt32();
break;
}
}
@@ -1153,13 +1121,12 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Start != 0) {
- output.WriteInt32(1, fieldNames[1], Start);
+ output.WriteInt32(1, Start);
}
if (End != 0) {
- output.WriteInt32(2, fieldNames[0], End);
+ output.WriteInt32(2, End);
}
}
@@ -1185,16 +1152,9 @@ namespace Google.Protobuf.DescriptorProtos {
}
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -1204,11 +1164,11 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 8: {
- input.ReadInt32(ref start_);
+ start_ = input.ReadInt32();
break;
}
case 16: {
- input.ReadInt32(ref end_);
+ end_ = input.ReadInt32();
break;
}
}
@@ -1348,34 +1308,33 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Name != "") {
- output.WriteString(1, fieldNames[3], Name);
+ output.WriteString(1, Name);
}
if (Extendee != "") {
- output.WriteString(2, fieldNames[1], Extendee);
+ output.WriteString(2, Extendee);
}
if (Number != 0) {
- output.WriteInt32(3, fieldNames[4], Number);
+ output.WriteInt32(3, Number);
}
if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) {
- output.WriteEnum(4, fieldNames[2], (int) Label);
+ output.WriteEnum(4, (int) Label);
}
if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) {
- output.WriteEnum(5, fieldNames[7], (int) Type);
+ output.WriteEnum(5, (int) Type);
}
if (TypeName != "") {
- output.WriteString(6, fieldNames[8], TypeName);
+ output.WriteString(6, TypeName);
}
if (DefaultValue != "") {
- output.WriteString(7, fieldNames[0], DefaultValue);
+ output.WriteString(7, DefaultValue);
}
if (options_ != null) {
- output.WriteMessage(8, fieldNames[6], Options);
+ output.WriteMessage(8, Options);
}
if (OneofIndex != 0) {
- output.WriteInt32(9, fieldNames[5], OneofIndex);
+ output.WriteInt32(9, OneofIndex);
}
}
@@ -1446,16 +1405,9 @@ namespace Google.Protobuf.DescriptorProtos {
}
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -1465,33 +1417,31 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 10: {
- input.ReadString(ref name_);
+ name_ = input.ReadString();
break;
}
case 18: {
- input.ReadString(ref extendee_);
+ extendee_ = input.ReadString();
break;
}
case 24: {
- input.ReadInt32(ref number_);
+ number_ = input.ReadInt32();
break;
}
case 32: {
- int tmp = 0;
- input.ReadEnum(ref tmp);
- label_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label) tmp;break;
+ label_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label) input.ReadEnum();
+ break;
}
case 40: {
- int tmp = 0;
- input.ReadEnum(ref tmp);
- type_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type) tmp;break;
+ type_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type) input.ReadEnum();
+ break;
}
case 50: {
- input.ReadString(ref typeName_);
+ typeName_ = input.ReadString();
break;
}
case 58: {
- input.ReadString(ref defaultValue_);
+ defaultValue_ = input.ReadString();
break;
}
case 66: {
@@ -1502,7 +1452,7 @@ namespace Google.Protobuf.DescriptorProtos {
break;
}
case 72: {
- input.ReadInt32(ref oneofIndex_);
+ oneofIndex_ = input.ReadInt32();
break;
}
}
@@ -1592,10 +1542,9 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Name != "") {
- output.WriteString(1, fieldNames[0], Name);
+ output.WriteString(1, Name);
}
}
@@ -1615,16 +1564,9 @@ namespace Google.Protobuf.DescriptorProtos {
}
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -1634,7 +1576,7 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 10: {
- input.ReadString(ref name_);
+ name_ = input.ReadString();
break;
}
}
@@ -1707,14 +1649,13 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Name != "") {
- output.WriteString(1, fieldNames[0], Name);
+ output.WriteString(1, Name);
}
- output.WriteMessageArray(2, fieldNames[2], value_);
+ output.WriteMessageArray(2, value_);
if (options_ != null) {
- output.WriteMessage(3, fieldNames[1], Options);
+ output.WriteMessage(3, Options);
}
}
@@ -1747,16 +1688,9 @@ namespace Google.Protobuf.DescriptorProtos {
}
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -1766,11 +1700,11 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 10: {
- input.ReadString(ref name_);
+ name_ = input.ReadString();
break;
}
case 18: {
- input.ReadMessageArray(tag, fieldName, value_, global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto.Parser);
+ input.ReadMessageArray(tag, value_, global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto.Parser);
break;
}
case 26: {
@@ -1852,16 +1786,15 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Name != "") {
- output.WriteString(1, fieldNames[0], Name);
+ output.WriteString(1, Name);
}
if (Number != 0) {
- output.WriteInt32(2, fieldNames[1], Number);
+ output.WriteInt32(2, Number);
}
if (options_ != null) {
- output.WriteMessage(3, fieldNames[2], Options);
+ output.WriteMessage(3, Options);
}
}
@@ -1896,16 +1829,9 @@ namespace Google.Protobuf.DescriptorProtos {
}
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -1915,11 +1841,11 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 10: {
- input.ReadString(ref name_);
+ name_ = input.ReadString();
break;
}
case 16: {
- input.ReadInt32(ref number_);
+ number_ = input.ReadInt32();
break;
}
case 26: {
@@ -1999,14 +1925,13 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Name != "") {
- output.WriteString(1, fieldNames[1], Name);
+ output.WriteString(1, Name);
}
- output.WriteMessageArray(2, fieldNames[0], method_);
+ output.WriteMessageArray(2, method_);
if (options_ != null) {
- output.WriteMessage(3, fieldNames[2], Options);
+ output.WriteMessage(3, Options);
}
}
@@ -2039,16 +1964,9 @@ namespace Google.Protobuf.DescriptorProtos {
}
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -2058,11 +1976,11 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 10: {
- input.ReadString(ref name_);
+ name_ = input.ReadString();
break;
}
case 18: {
- input.ReadMessageArray(tag, fieldName, method_, global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto.Parser);
+ input.ReadMessageArray(tag, method_, global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto.Parser);
break;
}
case 26: {
@@ -2174,25 +2092,24 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Name != "") {
- output.WriteString(1, fieldNames[2], Name);
+ output.WriteString(1, Name);
}
if (InputType != "") {
- output.WriteString(2, fieldNames[1], InputType);
+ output.WriteString(2, InputType);
}
if (OutputType != "") {
- output.WriteString(3, fieldNames[4], OutputType);
+ output.WriteString(3, OutputType);
}
if (options_ != null) {
- output.WriteMessage(4, fieldNames[3], Options);
+ output.WriteMessage(4, Options);
}
if (ClientStreaming != false) {
- output.WriteBool(5, fieldNames[0], ClientStreaming);
+ output.WriteBool(5, ClientStreaming);
}
if (ServerStreaming != false) {
- output.WriteBool(6, fieldNames[5], ServerStreaming);
+ output.WriteBool(6, ServerStreaming);
}
}
@@ -2245,16 +2162,9 @@ namespace Google.Protobuf.DescriptorProtos {
}
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -2264,15 +2174,15 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 10: {
- input.ReadString(ref name_);
+ name_ = input.ReadString();
break;
}
case 18: {
- input.ReadString(ref inputType_);
+ inputType_ = input.ReadString();
break;
}
case 26: {
- input.ReadString(ref outputType_);
+ outputType_ = input.ReadString();
break;
}
case 34: {
@@ -2283,11 +2193,11 @@ namespace Google.Protobuf.DescriptorProtos {
break;
}
case 40: {
- input.ReadBool(ref clientStreaming_);
+ clientStreaming_ = input.ReadBool();
break;
}
case 48: {
- input.ReadBool(ref serverStreaming_);
+ serverStreaming_ = input.ReadBool();
break;
}
}
@@ -2482,51 +2392,50 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (JavaPackage != "") {
- output.WriteString(1, fieldNames[9], JavaPackage);
+ output.WriteString(1, JavaPackage);
}
if (JavaOuterClassname != "") {
- output.WriteString(8, fieldNames[8], JavaOuterClassname);
+ output.WriteString(8, JavaOuterClassname);
}
if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) {
- output.WriteEnum(9, fieldNames[12], (int) OptimizeFor);
+ output.WriteEnum(9, (int) OptimizeFor);
}
if (JavaMultipleFiles != false) {
- output.WriteBool(10, fieldNames[7], JavaMultipleFiles);
+ output.WriteBool(10, JavaMultipleFiles);
}
if (GoPackage != "") {
- output.WriteString(11, fieldNames[4], GoPackage);
+ output.WriteString(11, GoPackage);
}
if (CcGenericServices != false) {
- output.WriteBool(16, fieldNames[1], CcGenericServices);
+ output.WriteBool(16, CcGenericServices);
}
if (JavaGenericServices != false) {
- output.WriteBool(17, fieldNames[6], JavaGenericServices);
+ output.WriteBool(17, JavaGenericServices);
}
if (PyGenericServices != false) {
- output.WriteBool(18, fieldNames[13], PyGenericServices);
+ output.WriteBool(18, PyGenericServices);
}
if (JavaGenerateEqualsAndHash != false) {
- output.WriteBool(20, fieldNames[5], JavaGenerateEqualsAndHash);
+ output.WriteBool(20, JavaGenerateEqualsAndHash);
}
if (Deprecated != false) {
- output.WriteBool(23, fieldNames[3], Deprecated);
+ output.WriteBool(23, Deprecated);
}
if (JavaStringCheckUtf8 != false) {
- output.WriteBool(27, fieldNames[10], JavaStringCheckUtf8);
+ output.WriteBool(27, JavaStringCheckUtf8);
}
if (CcEnableArenas != false) {
- output.WriteBool(31, fieldNames[0], CcEnableArenas);
+ output.WriteBool(31, CcEnableArenas);
}
if (ObjcClassPrefix != "") {
- output.WriteString(36, fieldNames[11], ObjcClassPrefix);
+ output.WriteString(36, ObjcClassPrefix);
}
if (CsharpNamespace != "") {
- output.WriteString(37, fieldNames[2], CsharpNamespace);
+ output.WriteString(37, CsharpNamespace);
}
- output.WriteMessageArray(999, fieldNames[14], uninterpretedOption_);
+ output.WriteMessageArray(999, uninterpretedOption_);
}
public int CalculateSize() {
@@ -2627,16 +2536,9 @@ namespace Google.Protobuf.DescriptorProtos {
uninterpretedOption_.Add(other.uninterpretedOption_);
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -2646,64 +2548,63 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 10: {
- input.ReadString(ref javaPackage_);
+ javaPackage_ = input.ReadString();
break;
}
case 66: {
- input.ReadString(ref javaOuterClassname_);
+ javaOuterClassname_ = input.ReadString();
break;
}
case 72: {
- int tmp = 0;
- input.ReadEnum(ref tmp);
- optimizeFor_ = (global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode) tmp;break;
+ optimizeFor_ = (global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode) input.ReadEnum();
+ break;
}
case 80: {
- input.ReadBool(ref javaMultipleFiles_);
+ javaMultipleFiles_ = input.ReadBool();
break;
}
case 90: {
- input.ReadString(ref goPackage_);
+ goPackage_ = input.ReadString();
break;
}
case 128: {
- input.ReadBool(ref ccGenericServices_);
+ ccGenericServices_ = input.ReadBool();
break;
}
case 136: {
- input.ReadBool(ref javaGenericServices_);
+ javaGenericServices_ = input.ReadBool();
break;
}
case 144: {
- input.ReadBool(ref pyGenericServices_);
+ pyGenericServices_ = input.ReadBool();
break;
}
case 160: {
- input.ReadBool(ref javaGenerateEqualsAndHash_);
+ javaGenerateEqualsAndHash_ = input.ReadBool();
break;
}
case 184: {
- input.ReadBool(ref deprecated_);
+ deprecated_ = input.ReadBool();
break;
}
case 216: {
- input.ReadBool(ref javaStringCheckUtf8_);
+ javaStringCheckUtf8_ = input.ReadBool();
break;
}
case 248: {
- input.ReadBool(ref ccEnableArenas_);
+ ccEnableArenas_ = input.ReadBool();
break;
}
case 290: {
- input.ReadString(ref objcClassPrefix_);
+ objcClassPrefix_ = input.ReadString();
break;
}
case 298: {
- input.ReadString(ref csharpNamespace_);
+ csharpNamespace_ = input.ReadString();
break;
}
case 7994: {
- input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
+ input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
break;
}
}
@@ -2810,21 +2711,20 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (MessageSetWireFormat != false) {
- output.WriteBool(1, fieldNames[2], MessageSetWireFormat);
+ output.WriteBool(1, MessageSetWireFormat);
}
if (NoStandardDescriptorAccessor != false) {
- output.WriteBool(2, fieldNames[3], NoStandardDescriptorAccessor);
+ output.WriteBool(2, NoStandardDescriptorAccessor);
}
if (Deprecated != false) {
- output.WriteBool(3, fieldNames[0], Deprecated);
+ output.WriteBool(3, Deprecated);
}
if (MapEntry != false) {
- output.WriteBool(7, fieldNames[1], MapEntry);
+ output.WriteBool(7, MapEntry);
}
- output.WriteMessageArray(999, fieldNames[4], uninterpretedOption_);
+ output.WriteMessageArray(999, uninterpretedOption_);
}
public int CalculateSize() {
@@ -2865,16 +2765,9 @@ namespace Google.Protobuf.DescriptorProtos {
uninterpretedOption_.Add(other.uninterpretedOption_);
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -2884,23 +2777,23 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 8: {
- input.ReadBool(ref messageSetWireFormat_);
+ messageSetWireFormat_ = input.ReadBool();
break;
}
case 16: {
- input.ReadBool(ref noStandardDescriptorAccessor_);
+ noStandardDescriptorAccessor_ = input.ReadBool();
break;
}
case 24: {
- input.ReadBool(ref deprecated_);
+ deprecated_ = input.ReadBool();
break;
}
case 56: {
- input.ReadBool(ref mapEntry_);
+ mapEntry_ = input.ReadBool();
break;
}
case 7994: {
- input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
+ input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
break;
}
}
@@ -3015,27 +2908,26 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) {
- output.WriteEnum(1, fieldNames[0], (int) Ctype);
+ output.WriteEnum(1, (int) Ctype);
}
if (Packed != false) {
- output.WriteBool(2, fieldNames[4], Packed);
+ output.WriteBool(2, Packed);
}
if (Deprecated != false) {
- output.WriteBool(3, fieldNames[1], Deprecated);
+ output.WriteBool(3, Deprecated);
}
if (Lazy != false) {
- output.WriteBool(5, fieldNames[3], Lazy);
+ output.WriteBool(5, Lazy);
}
if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) {
- output.WriteEnum(6, fieldNames[2], (int) Jstype);
+ output.WriteEnum(6, (int) Jstype);
}
if (Weak != false) {
- output.WriteBool(10, fieldNames[6], Weak);
+ output.WriteBool(10, Weak);
}
- output.WriteMessageArray(999, fieldNames[5], uninterpretedOption_);
+ output.WriteMessageArray(999, uninterpretedOption_);
}
public int CalculateSize() {
@@ -3088,16 +2980,9 @@ namespace Google.Protobuf.DescriptorProtos {
uninterpretedOption_.Add(other.uninterpretedOption_);
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -3107,33 +2992,31 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 8: {
- int tmp = 0;
- input.ReadEnum(ref tmp);
- ctype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType) tmp;break;
+ ctype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType) input.ReadEnum();
+ break;
}
case 16: {
- input.ReadBool(ref packed_);
+ packed_ = input.ReadBool();
break;
}
case 24: {
- input.ReadBool(ref deprecated_);
+ deprecated_ = input.ReadBool();
break;
}
case 40: {
- input.ReadBool(ref lazy_);
+ lazy_ = input.ReadBool();
break;
}
case 48: {
- int tmp = 0;
- input.ReadEnum(ref tmp);
- jstype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType) tmp;break;
+ jstype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType) input.ReadEnum();
+ break;
}
case 80: {
- input.ReadBool(ref weak_);
+ weak_ = input.ReadBool();
break;
}
case 7994: {
- input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
+ input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
break;
}
}
@@ -3226,15 +3109,14 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (AllowAlias != false) {
- output.WriteBool(2, fieldNames[0], AllowAlias);
+ output.WriteBool(2, AllowAlias);
}
if (Deprecated != false) {
- output.WriteBool(3, fieldNames[1], Deprecated);
+ output.WriteBool(3, Deprecated);
}
- output.WriteMessageArray(999, fieldNames[2], uninterpretedOption_);
+ output.WriteMessageArray(999, uninterpretedOption_);
}
public int CalculateSize() {
@@ -3263,16 +3145,9 @@ namespace Google.Protobuf.DescriptorProtos {
uninterpretedOption_.Add(other.uninterpretedOption_);
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -3282,15 +3157,15 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 16: {
- input.ReadBool(ref allowAlias_);
+ allowAlias_ = input.ReadBool();
break;
}
case 24: {
- input.ReadBool(ref deprecated_);
+ deprecated_ = input.ReadBool();
break;
}
case 7994: {
- input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
+ input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
break;
}
}
@@ -3355,12 +3230,11 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Deprecated != false) {
- output.WriteBool(1, fieldNames[0], Deprecated);
+ output.WriteBool(1, Deprecated);
}
- output.WriteMessageArray(999, fieldNames[1], uninterpretedOption_);
+ output.WriteMessageArray(999, uninterpretedOption_);
}
public int CalculateSize() {
@@ -3383,16 +3257,9 @@ namespace Google.Protobuf.DescriptorProtos {
uninterpretedOption_.Add(other.uninterpretedOption_);
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -3402,11 +3269,11 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 8: {
- input.ReadBool(ref deprecated_);
+ deprecated_ = input.ReadBool();
break;
}
case 7994: {
- input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
+ input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
break;
}
}
@@ -3471,12 +3338,11 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Deprecated != false) {
- output.WriteBool(33, fieldNames[0], Deprecated);
+ output.WriteBool(33, Deprecated);
}
- output.WriteMessageArray(999, fieldNames[1], uninterpretedOption_);
+ output.WriteMessageArray(999, uninterpretedOption_);
}
public int CalculateSize() {
@@ -3499,16 +3365,9 @@ namespace Google.Protobuf.DescriptorProtos {
uninterpretedOption_.Add(other.uninterpretedOption_);
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -3518,11 +3377,11 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 264: {
- input.ReadBool(ref deprecated_);
+ deprecated_ = input.ReadBool();
break;
}
case 7994: {
- input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
+ input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
break;
}
}
@@ -3587,12 +3446,11 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (Deprecated != false) {
- output.WriteBool(33, fieldNames[0], Deprecated);
+ output.WriteBool(33, Deprecated);
}
- output.WriteMessageArray(999, fieldNames[1], uninterpretedOption_);
+ output.WriteMessageArray(999, uninterpretedOption_);
}
public int CalculateSize() {
@@ -3615,16 +3473,9 @@ namespace Google.Protobuf.DescriptorProtos {
uninterpretedOption_.Add(other.uninterpretedOption_);
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -3634,11 +3485,11 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 264: {
- input.ReadBool(ref deprecated_);
+ deprecated_ = input.ReadBool();
break;
}
case 7994: {
- input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
+ input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser);
break;
}
}
@@ -3753,26 +3604,25 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
- output.WriteMessageArray(2, fieldNames[3], name_);
+ public void WriteTo(pb::CodedOutputStream output) {
+ output.WriteMessageArray(2, name_);
if (IdentifierValue != "") {
- output.WriteString(3, fieldNames[2], IdentifierValue);
+ output.WriteString(3, IdentifierValue);
}
if (PositiveIntValue != 0UL) {
- output.WriteUInt64(4, fieldNames[5], PositiveIntValue);
+ output.WriteUInt64(4, PositiveIntValue);
}
if (NegativeIntValue != 0L) {
- output.WriteInt64(5, fieldNames[4], NegativeIntValue);
+ output.WriteInt64(5, NegativeIntValue);
}
if (DoubleValue != 0D) {
- output.WriteDouble(6, fieldNames[1], DoubleValue);
+ output.WriteDouble(6, DoubleValue);
}
if (StringValue != pb::ByteString.Empty) {
- output.WriteBytes(7, fieldNames[6], StringValue);
+ output.WriteBytes(7, StringValue);
}
if (AggregateValue != "") {
- output.WriteString(8, fieldNames[0], AggregateValue);
+ output.WriteString(8, AggregateValue);
}
}
@@ -3826,16 +3676,9 @@ namespace Google.Protobuf.DescriptorProtos {
}
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -3845,31 +3688,31 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 18: {
- input.ReadMessageArray(tag, fieldName, name_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart.Parser);
+ input.ReadMessageArray(tag, name_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart.Parser);
break;
}
case 26: {
- input.ReadString(ref identifierValue_);
+ identifierValue_ = input.ReadString();
break;
}
case 32: {
- input.ReadUInt64(ref positiveIntValue_);
+ positiveIntValue_ = input.ReadUInt64();
break;
}
case 40: {
- input.ReadInt64(ref negativeIntValue_);
+ negativeIntValue_ = input.ReadInt64();
break;
}
case 49: {
- input.ReadDouble(ref doubleValue_);
+ doubleValue_ = input.ReadDouble();
break;
}
case 58: {
- input.ReadBytes(ref stringValue_);
+ stringValue_ = input.ReadBytes();
break;
}
case 66: {
- input.ReadString(ref aggregateValue_);
+ aggregateValue_ = input.ReadString();
break;
}
}
@@ -3937,13 +3780,12 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
+ public void WriteTo(pb::CodedOutputStream output) {
if (NamePart_ != "") {
- output.WriteString(1, fieldNames[1], NamePart_);
+ output.WriteString(1, NamePart_);
}
if (IsExtension != false) {
- output.WriteBool(2, fieldNames[0], IsExtension);
+ output.WriteBool(2, IsExtension);
}
}
@@ -3969,16 +3811,9 @@ namespace Google.Protobuf.DescriptorProtos {
}
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -3988,11 +3823,11 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 10: {
- input.ReadString(ref namePart_);
+ namePart_ = input.ReadString();
break;
}
case 16: {
- input.ReadBool(ref isExtension_);
+ isExtension_ = input.ReadBool();
break;
}
}
@@ -4052,9 +3887,8 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
- output.WriteMessageArray(1, fieldNames[0], location_);
+ public void WriteTo(pb::CodedOutputStream output) {
+ output.WriteMessageArray(1, location_);
}
public int CalculateSize() {
@@ -4071,16 +3905,9 @@ namespace Google.Protobuf.DescriptorProtos {
location_.Add(other.location_);
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -4090,7 +3917,7 @@ namespace Google.Protobuf.DescriptorProtos {
}
break;
case 10: {
- input.ReadMessageArray(tag, fieldName, location_, global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location.Parser);
+ input.ReadMessageArray(tag, location_, global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location.Parser);
break;
}
}
@@ -4182,17 +4009,16 @@ namespace Google.Protobuf.DescriptorProtos {
return hash;
}
- public void WriteTo(pb::ICodedOutputStream output) {
- string[] fieldNames = _fieldNames;
- output.WritePackedInt32Array(1, fieldNames[2], path_);
- output.WritePackedInt32Array(2, fieldNames[3], span_);
+ public void WriteTo(pb::CodedOutputStream output) {
+ output.WritePackedInt32Array(1, path_);
+ output.WritePackedInt32Array(2, span_);
if (LeadingComments != "") {
- output.WriteString(3, fieldNames[0], LeadingComments);
+ output.WriteString(3, LeadingComments);
}
if (TrailingComments != "") {
- output.WriteString(4, fieldNames[4], TrailingComments);
+ output.WriteString(4, TrailingComments);
}
- output.WriteStringArray(6, fieldNames[1], leadingDetachedComments_);
+ output.WriteStringArray(6, leadingDetachedComments_);
}
public int CalculateSize() {
@@ -4248,16 +4074,9 @@ namespace Google.Protobuf.DescriptorProtos {
leadingDetachedComments_.Add(other.leadingDetachedComments_);
}
- public void MergeFrom(pb::ICodedInputStream input) {
+ public void MergeFrom(pb::CodedInputStream input) {
uint tag;
- string fieldName;
- while (input.ReadTag(out tag, out fieldName)) {
- if (tag == 0 && fieldName != null) {
- int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);
- if (fieldOrdinal >= 0) {
- tag = _fieldTags[fieldOrdinal];
- }
- }
+ while (input.ReadTag(out tag)) {
switch(tag) {
case 0:
throw pb::InvalidProtocolBufferException.InvalidTag();
@@ -4268,24 +4087,24 @@ namespace Google.Protobuf.DescriptorProtos {
break;
case 10:
case 8: {
- input.ReadInt32Array(tag, fieldName, path_);
+ input.ReadInt32Array(tag, path_);
break;
}
case 18:
case 16: {
- input.ReadInt32Array(tag, fieldName, span_);
+ input.ReadInt32Array(tag, span_);
break;
}
case 26: {
- input.ReadString(ref leadingComments_);
+ leadingComments_ = input.ReadString();
break;
}
case 34: {
- input.ReadString(ref trailingComments_);
+ trailingComments_ = input.ReadString();
break;
}
case 50: {
- input.ReadStringArray(tag, fieldName, leadingDetachedComments_);
+ input.ReadStringArray(tag, leadingDetachedComments_);
break;
}
}
diff --git a/csharp/src/ProtocolBuffers/Extensions.cs b/csharp/src/ProtocolBuffers/Extensions.cs
index 29288f51..7f23057e 100644
--- a/csharp/src/ProtocolBuffers/Extensions.cs
+++ b/csharp/src/ProtocolBuffers/Extensions.cs
@@ -49,7 +49,7 @@ namespace Google.Protobuf
codedOutput.Flush();
}
- public static void WriteTo(this IMessage message, ICodedOutputStream output)
+ public static void WriteTo(this IMessage message, CodedOutputStream output)
{
message.WriteTo(output);
}
diff --git a/csharp/src/ProtocolBuffers/ICodedInputStream.cs b/csharp/src/ProtocolBuffers/ICodedInputStream.cs
deleted file mode 100644
index d962e62b..00000000
--- a/csharp/src/ProtocolBuffers/ICodedInputStream.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;
-using System.Collections.Generic;
-using Google.Protobuf.Descriptors;
-
-//Disable warning CS3010: CLS-compliant interfaces must have only CLS-compliant members
-#pragma warning disable 3010
-
-namespace Google.Protobuf
-{
- 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, IMessage message);
-
- /// <summary>
- /// Reads an embedded message field value from the stream.
- /// </summary>
- void ReadMessage(IMessage message);
-
- /// <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. This performs no checking
- /// as to whether the enum value is known to the enum type as it was present
- /// when the code was generated.
- /// </summary>
- bool ReadEnum(ref int value);
-
- /// <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<T>(uint fieldTag, string fieldName, ICollection<T> list)
- where T : struct, IComparable, IFormattable;
-
- /// <summary>
- /// Reads a set of messages using the <paramref name="parser"/> to read individual messages.
- /// </summary>
- void ReadMessageArray<T>(uint fieldTag, string fieldName, ICollection<T> list, MessageParser<T> parser) where T : IMessage<T>;
-
- /// <summary>
- /// Reads a set of messages using the <paramref name="parser"/> as a template.
- /// </summary>
- void ReadGroupArray<T>(uint fieldTag, string fieldName, ICollection<T> list, MessageParser<T> parser) where T : IMessage<T>;
-
- /// <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 921400ac..00000000
--- a/csharp/src/ProtocolBuffers/ICodedOutputStream.cs
+++ /dev/null
@@ -1,347 +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 Google.Protobuf.Collections;
-using Google.Protobuf.Descriptors;
-
-//Disable warning CS3010: CLS-compliant interfaces must have only CLS-compliant members
-#pragma warning disable 3010
-
-namespace Google.Protobuf
-{
- /// <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 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, IMessage value);
-
- /// <summary>
- /// Writes a message field value, including tag, to the stream.
- /// </summary>
- void WriteMessage(int fieldNumber, string fieldName, IMessage 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);
-
- /// <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, RepeatedField<T> list)
- where T : IMessage;
-
- /// <summary>
- /// Writes a repeated message value, including tag(s), to the stream.
- /// </summary>
- void WriteMessageArray<T>(int fieldNumber, string fieldName, RepeatedField<T> list)
- where T : IMessage;
-
- /// <summary>
- /// Writes a repeated string value, including tag(s), to the stream.
- /// </summary>
- void WriteStringArray(int fieldNumber, string fieldName, RepeatedField<string> list);
-
- /// <summary>
- /// Writes a repeated ByteString value, including tag(s), to the stream.
- /// </summary>
- void WriteBytesArray(int fieldNumber, string fieldName, RepeatedField<ByteString> list);
-
- /// <summary>
- /// Writes a repeated boolean value, including tag(s), to the stream.
- /// </summary>
- void WriteBoolArray(int fieldNumber, string fieldName, RepeatedField<bool> list);
-
- /// <summary>
- /// Writes a repeated Int32 value, including tag(s), to the stream.
- /// </summary>
- void WriteInt32Array(int fieldNumber, string fieldName, RepeatedField<int> list);
-
- /// <summary>
- /// Writes a repeated SInt32 value, including tag(s), to the stream.
- /// </summary>
- void WriteSInt32Array(int fieldNumber, string fieldName, RepeatedField<int> list);
-
- /// <summary>
- /// Writes a repeated UInt32 value, including tag(s), to the stream.
- /// </summary>
- void WriteUInt32Array(int fieldNumber, string fieldName, RepeatedField<uint> list);
-
- /// <summary>
- /// Writes a repeated Fixed32 value, including tag(s), to the stream.
- /// </summary>
- void WriteFixed32Array(int fieldNumber, string fieldName, RepeatedField<uint> list);
-
- /// <summary>
- /// Writes a repeated SFixed32 value, including tag(s), to the stream.
- /// </summary>
- void WriteSFixed32Array(int fieldNumber, string fieldName, RepeatedField<int> list);
-
- /// <summary>
- /// Writes a repeated Int64 value, including tag(s), to the stream.
- /// </summary>
- void WriteInt64Array(int fieldNumber, string fieldName, RepeatedField<long> list);
-
- /// <summary>
- /// Writes a repeated SInt64 value, including tag(s), to the stream.
- /// </summary>
- void WriteSInt64Array(int fieldNumber, string fieldName, RepeatedField<long> list);
-
- /// <summary>
- /// Writes a repeated UInt64 value, including tag(s), to the stream.
- /// </summary>
- void WriteUInt64Array(int fieldNumber, string fieldName, RepeatedField<ulong> list);
-
- /// <summary>
- /// Writes a repeated Fixed64 value, including tag(s), to the stream.
- /// </summary>
- void WriteFixed64Array(int fieldNumber, string fieldName, RepeatedField<ulong> list);
-
- /// <summary>
- /// Writes a repeated SFixed64 value, including tag(s), to the stream.
- /// </summary>
- void WriteSFixed64Array(int fieldNumber, string fieldName, RepeatedField<long> list);
-
- /// <summary>
- /// Writes a repeated Double value, including tag(s), to the stream.
- /// </summary>
- void WriteDoubleArray(int fieldNumber, string fieldName, RepeatedField<double> list);
-
- /// <summary>
- /// Writes a repeated Float value, including tag(s), to the stream.
- /// </summary>
- void WriteFloatArray(int fieldNumber, string fieldName, RepeatedField<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, RepeatedField<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, RepeatedField<bool> list);
-
- /// <summary>
- /// Writes a packed repeated Int32, including tag and length, to the stream.
- /// </summary>
- void WritePackedInt32Array(int fieldNumber, string fieldName, RepeatedField<int> list);
-
- /// <summary>
- /// Writes a packed repeated SInt32, including tag and length, to the stream.
- /// </summary>
- void WritePackedSInt32Array(int fieldNumber, string fieldName, RepeatedField<int> list);
-
- /// <summary>
- /// Writes a packed repeated UInt32, including tag and length, to the stream.
- /// </summary>
- void WritePackedUInt32Array(int fieldNumber, string fieldName, RepeatedField<uint> list);
-
- /// <summary>
- /// Writes a packed repeated Fixed32, including tag and length, to the stream.
- /// </summary>
- void WritePackedFixed32Array(int fieldNumber, string fieldName, RepeatedField<uint> list);
-
- /// <summary>
- /// Writes a packed repeated SFixed32, including tag and length, to the stream.
- /// </summary>
- void WritePackedSFixed32Array(int fieldNumber, string fieldName, RepeatedField<int> list);
-
- /// <summary>
- /// Writes a packed repeated Int64, including tag and length, to the stream.
- /// </summary>
- void WritePackedInt64Array(int fieldNumber, string fieldName, RepeatedField<long> list);
-
- /// <summary>
- /// Writes a packed repeated SInt64, including tag and length, to the stream.
- /// </summary>
- void WritePackedSInt64Array(int fieldNumber, string fieldName, RepeatedField<long> list);
-
- /// <summary>
- /// Writes a packed repeated UInt64, including tag and length, to the stream.
- /// </summary>
- void WritePackedUInt64Array(int fieldNumber, string fieldName, RepeatedField<ulong> list);
-
- /// <summary>
- /// Writes a packed repeated Fixed64, including tag and length, to the stream.
- /// </summary>
- void WritePackedFixed64Array(int fieldNumber, string fieldName, RepeatedField<ulong> list);
-
- /// <summary>
- /// Writes a packed repeated SFixed64, including tag and length, to the stream.
- /// </summary>
- void WritePackedSFixed64Array(int fieldNumber, string fieldName, RepeatedField<long> list);
-
- /// <summary>
- /// Writes a packed repeated Double, including tag and length, to the stream.
- /// </summary>
- void WritePackedDoubleArray(int fieldNumber, string fieldName, RepeatedField<double> list);
-
- /// <summary>
- /// Writes a packed repeated Float, including tag and length, to the stream.
- /// </summary>
- void WritePackedFloatArray(int fieldNumber, string fieldName, RepeatedField<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, RepeatedField<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 4e06f6e8..55b6fc5d 100644
--- a/csharp/src/ProtocolBuffers/IMessage.cs
+++ b/csharp/src/ProtocolBuffers/IMessage.cs
@@ -51,8 +51,8 @@ namespace Google.Protobuf
public interface IMessage
{
- void MergeFrom(ICodedInputStream input);
- void WriteTo(ICodedOutputStream output);
+ void MergeFrom(CodedInputStream input);
+ void WriteTo(CodedOutputStream output);
int CalculateSize();
}
diff --git a/csharp/src/ProtocolBuffers/MessageParser.cs b/csharp/src/ProtocolBuffers/MessageParser.cs
index 399a9043..722435cc 100644
--- a/csharp/src/ProtocolBuffers/MessageParser.cs
+++ b/csharp/src/ProtocolBuffers/MessageParser.cs
@@ -47,7 +47,7 @@ namespace Google.Protobuf
return message;
}
- public T ParseFrom(ICodedInputStream input)
+ public T ParseFrom(CodedInputStream input)
{
T message = factory();
message.MergeFrom(input);
diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj
index efd387a2..3a07e87f 100644
--- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj
+++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj
@@ -93,8 +93,6 @@
<Compile Include="FieldAccess\FieldAccessorTable.cs" />
<Compile Include="FieldAccess\OneofAccessor.cs" />
<Compile Include="FrameworkPortability.cs" />
- <Compile Include="ICodedInputStream.cs" />
- <Compile Include="ICodedOutputStream.cs" />
<Compile Include="IMessage.cs" />
<Compile Include="InvalidProtocolBufferException.cs" />
<Compile Include="LimitedInputStream.cs" />