aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/Google.Protobuf')
-rw-r--r--csharp/src/Google.Protobuf/CodedInputStream.cs55
-rw-r--r--csharp/src/Google.Protobuf/Collections/MapField.cs5
-rw-r--r--csharp/src/Google.Protobuf/FieldCodec.cs7
-rw-r--r--csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs6
-rw-r--r--csharp/src/Google.Protobuf/MessageExtensions.cs6
-rw-r--r--csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs110
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Any.cs5
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Api.cs10
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs5
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs5
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs5
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs5
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs15
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs5
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Type.cs25
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs45
-rw-r--r--csharp/src/Google.Protobuf/WireFormat.cs10
17 files changed, 104 insertions, 220 deletions
diff --git a/csharp/src/Google.Protobuf/CodedInputStream.cs b/csharp/src/Google.Protobuf/CodedInputStream.cs
index 0e2495f1..dcd19e48 100644
--- a/csharp/src/Google.Protobuf/CodedInputStream.cs
+++ b/csharp/src/Google.Protobuf/CodedInputStream.cs
@@ -236,17 +236,16 @@ namespace Google.Protobuf
#region Validation
/// <summary>
- /// Verifies that the last call to ReadTag() returned the given tag value.
- /// This is used to verify that a nested group ended with the correct
- /// end tag.
+ /// Verifies that the last call to ReadTag() returned tag 0 - in other words,
+ /// we've reached the end of the stream when we expected to.
/// </summary>
- /// <exception cref="InvalidProtocolBufferException">The last
+ /// <exception cref="InvalidProtocolBufferException">The
/// tag read was not the one specified</exception>
- internal void CheckLastTagWas(uint value)
+ internal void CheckReadEndOfStreamTag()
{
- if (lastTag != value)
+ if (lastTag != 0)
{
- throw InvalidProtocolBufferException.InvalidEndTag();
+ throw InvalidProtocolBufferException.MoreDataAvailable();
}
}
#endregion
@@ -275,6 +274,11 @@ namespace Google.Protobuf
/// <summary>
/// Reads a field tag, returning the tag of 0 for "end of stream".
/// </summary>
+ /// <remarks>
+ /// If this method returns 0, it doesn't necessarily mean the end of all
+ /// the data in this CodedInputStream; it may be the end of the logical stream
+ /// for an embedded message, for example.
+ /// </remarks>
/// <returns>The next field tag, or 0 for end of stream. (0 is never a valid tag.)</returns>
public uint ReadTag()
{
@@ -329,22 +333,24 @@ namespace Google.Protobuf
}
/// <summary>
- /// Consumes the data for the field with the tag we've just read.
+ /// Skips the data for the field with the tag we've just read.
/// This should be called directly after <see cref="ReadTag"/>, when
/// the caller wishes to skip an unknown field.
/// </summary>
- public void ConsumeLastField()
+ public void SkipLastField()
{
if (lastTag == 0)
{
- throw new InvalidOperationException("ConsumeLastField cannot be called at the end of a stream");
+ throw new InvalidOperationException("SkipLastField cannot be called at the end of a stream");
}
switch (WireFormat.GetTagWireType(lastTag))
{
case WireFormat.WireType.StartGroup:
+ SkipGroup();
+ break;
case WireFormat.WireType.EndGroup:
- // TODO: Work out how to skip them instead? See issue 688.
- throw new InvalidProtocolBufferException("Group tags not supported by proto3 C# implementation");
+ // Just ignore; there's no data following the tag.
+ break;
case WireFormat.WireType.Fixed32:
ReadFixed32();
break;
@@ -361,6 +367,29 @@ namespace Google.Protobuf
}
}
+ private void SkipGroup()
+ {
+ // Note: Currently we expect this to be the way that groups are read. We could put the recursion
+ // depth changes into the ReadTag method instead, potentially...
+ recursionDepth++;
+ if (recursionDepth >= recursionLimit)
+ {
+ throw InvalidProtocolBufferException.RecursionLimitExceeded();
+ }
+ uint tag;
+ do
+ {
+ tag = ReadTag();
+ if (tag == 0)
+ {
+ throw InvalidProtocolBufferException.TruncatedMessage();
+ }
+ // This recursion will allow us to handle nested groups.
+ SkipLastField();
+ } while (WireFormat.GetTagWireType(tag) != WireFormat.WireType.EndGroup);
+ recursionDepth--;
+ }
+
/// <summary>
/// Reads a double field from the stream.
/// </summary>
@@ -475,7 +504,7 @@ namespace Google.Protobuf
int oldLimit = PushLimit(length);
++recursionDepth;
builder.MergeFrom(this);
- CheckLastTagWas(0);
+ CheckReadEndOfStreamTag();
// Check that we've read exactly as much data as expected.
if (!ReachedLimit)
{
diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs
index 5eb2c2fc..dc4b04cb 100644
--- a/csharp/src/Google.Protobuf/Collections/MapField.cs
+++ b/csharp/src/Google.Protobuf/Collections/MapField.cs
@@ -637,10 +637,9 @@ namespace Google.Protobuf.Collections
{
Value = codec.valueCodec.Read(input);
}
- else if (WireFormat.IsEndGroupTag(tag))
+ else
{
- // TODO(jonskeet): Do we need this? (Given that we don't support groups...)
- return;
+ input.SkipLastField();
}
}
}
diff --git a/csharp/src/Google.Protobuf/FieldCodec.cs b/csharp/src/Google.Protobuf/FieldCodec.cs
index 15d52c7d..20a1f438 100644
--- a/csharp/src/Google.Protobuf/FieldCodec.cs
+++ b/csharp/src/Google.Protobuf/FieldCodec.cs
@@ -304,12 +304,13 @@ namespace Google.Protobuf
{
value = codec.Read(input);
}
- if (WireFormat.IsEndGroupTag(tag))
+ else
{
- break;
+ input.SkipLastField();
}
+
}
- input.CheckLastTagWas(0);
+ input.CheckReadEndOfStreamTag();
input.PopLimit(oldLimit);
return value;
diff --git a/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs b/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs
index 6905a6a3..01d55395 100644
--- a/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs
+++ b/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs
@@ -45,6 +45,12 @@ namespace Google.Protobuf
{
}
+ internal static InvalidProtocolBufferException MoreDataAvailable()
+ {
+ return new InvalidProtocolBufferException(
+ "Completed reading a message while more data was available in the stream.");
+ }
+
internal static InvalidProtocolBufferException TruncatedMessage()
{
return new InvalidProtocolBufferException(
diff --git a/csharp/src/Google.Protobuf/MessageExtensions.cs b/csharp/src/Google.Protobuf/MessageExtensions.cs
index ee78dc8d..d2d057c0 100644
--- a/csharp/src/Google.Protobuf/MessageExtensions.cs
+++ b/csharp/src/Google.Protobuf/MessageExtensions.cs
@@ -50,7 +50,7 @@ namespace Google.Protobuf
Preconditions.CheckNotNull(data, "data");
CodedInputStream input = new CodedInputStream(data);
message.MergeFrom(input);
- input.CheckLastTagWas(0);
+ input.CheckReadEndOfStreamTag();
}
/// <summary>
@@ -64,7 +64,7 @@ namespace Google.Protobuf
Preconditions.CheckNotNull(data, "data");
CodedInputStream input = data.CreateCodedInput();
message.MergeFrom(input);
- input.CheckLastTagWas(0);
+ input.CheckReadEndOfStreamTag();
}
/// <summary>
@@ -78,7 +78,7 @@ namespace Google.Protobuf
Preconditions.CheckNotNull(input, "input");
CodedInputStream codedInput = new CodedInputStream(input);
message.MergeFrom(codedInput);
- codedInput.CheckLastTagWas(0);
+ codedInput.CheckReadEndOfStreamTag();
}
/// <summary>
diff --git a/csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs b/csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs
index d66bdb80..59c5e69b 100644
--- a/csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs
+++ b/csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs
@@ -242,10 +242,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
file_.AddEntriesFrom(input, _repeated_file_codec);
@@ -539,10 +536,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
@@ -833,10 +827,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
@@ -1000,10 +991,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
Start = input.ReadInt32();
@@ -1131,10 +1119,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
Start = input.ReadInt32();
@@ -1424,10 +1409,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
@@ -1597,10 +1579,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
@@ -1741,10 +1720,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
@@ -1904,10 +1880,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
@@ -2059,10 +2032,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
@@ -2288,10 +2258,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
@@ -2716,10 +2683,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
JavaPackage = input.ReadString();
@@ -2969,10 +2933,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
MessageSetWireFormat = input.ReadBool();
@@ -3214,10 +3175,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
ctype_ = (global::Google.Protobuf.Reflection.FieldOptions.Types.CType) input.ReadEnum();
@@ -3397,10 +3355,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 16: {
AllowAlias = input.ReadBool();
@@ -3524,10 +3479,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
Deprecated = input.ReadBool();
@@ -3647,10 +3599,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 264: {
Deprecated = input.ReadBool();
@@ -3770,10 +3719,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 264: {
Deprecated = input.ReadBool();
@@ -4003,10 +3949,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 18: {
name_.AddEntriesFrom(input, _repeated_name_codec);
@@ -4155,10 +4098,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
NamePart_ = input.ReadString();
@@ -4261,10 +4201,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
location_.AddEntriesFrom(input, _repeated_location_codec);
@@ -4431,10 +4368,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10:
case 8: {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
index 9fc653b0..204b37cf 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
@@ -150,10 +150,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
TypeUrl = input.ReadString();
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
index 8a94e7b0..a5f95093 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
@@ -213,10 +213,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
@@ -439,10 +436,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
index d74636d4..aa34f2d8 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
@@ -151,10 +151,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
Seconds = input.ReadInt64();
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
index 0f1d7f50..7d699c1d 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
@@ -106,10 +106,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
}
}
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
index 9bd47a96..0dac4403 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
@@ -120,10 +120,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
paths_.AddEntriesFrom(input, _repeated_paths_codec);
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
index ae79884f..8347999d 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
@@ -129,10 +129,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
FileName = input.ReadString();
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
index ea8b1055..1e8a8236 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
@@ -139,10 +139,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
fields_.AddEntriesFrom(input, _map_fields_codec);
@@ -392,10 +389,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
kind_ = input.ReadEnum();
@@ -520,10 +514,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
values_.AddEntriesFrom(input, _repeated_values_codec);
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
index 89355bdc..d7c0954f 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
@@ -151,10 +151,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
Seconds = input.ReadInt64();
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
index 36116a65..ff2ecc57 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
@@ -226,10 +226,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
@@ -496,10 +493,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
kind_ = (global::Google.Protobuf.WellKnownTypes.Field.Types.Kind) input.ReadEnum();
@@ -716,10 +710,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
@@ -872,10 +863,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
@@ -1010,10 +998,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Name = input.ReadString();
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
index 19ed599d..9ecaf47c 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
@@ -138,10 +138,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 9: {
Value = input.ReadDouble();
@@ -243,10 +240,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 13: {
Value = input.ReadFloat();
@@ -348,10 +342,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
Value = input.ReadInt64();
@@ -453,10 +444,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
Value = input.ReadUInt64();
@@ -558,10 +546,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
Value = input.ReadInt32();
@@ -663,10 +648,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
Value = input.ReadUInt32();
@@ -768,10 +750,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 8: {
Value = input.ReadBool();
@@ -873,10 +852,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Value = input.ReadString();
@@ -978,10 +954,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- return;
- }
- input.ConsumeLastField();
+ input.SkipLastField();
break;
case 10: {
Value = input.ReadBytes();
diff --git a/csharp/src/Google.Protobuf/WireFormat.cs b/csharp/src/Google.Protobuf/WireFormat.cs
index bbd7e4f9..b0e4a41f 100644
--- a/csharp/src/Google.Protobuf/WireFormat.cs
+++ b/csharp/src/Google.Protobuf/WireFormat.cs
@@ -99,16 +99,6 @@ namespace Google.Protobuf
}
/// <summary>
- /// Determines whether the given tag is an end group tag.
- /// </summary>
- /// <param name="tag">The tag to check.</param>
- /// <returns><c>true</c> if the given tag is an end group tag; <c>false</c> otherwise.</returns>
- public static bool IsEndGroupTag(uint tag)
- {
- return (WireType) (tag & TagTypeMask) == WireType.EndGroup;
- }
-
- /// <summary>
/// Given a tag value, determines the field number (the upper 29 bits).
/// </summary>
public static int GetTagFieldNumber(uint tag)