More map tests, and various production code improvements.
Generated code in next commit.
diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs
index 905cdb9..dab3e5e 100644
--- a/csharp/src/ProtocolBuffers/CodedInputStream.cs
+++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs
@@ -456,14 +456,16 @@
}
/// <summary>
- /// Returns true if the next tag is also part of the same unpacked array.
+ /// Peeks at the next tag in the stream. If it matches <paramref name="tag"/>,
+ /// the tag is consumed and the method returns <c>true</c>; otherwise, the
+ /// stream is left in the original position and the method returns <c>false</c>.
/// </summary>
- private bool ContinueArray(uint currentTag)
+ public bool MaybeConsumeTag(uint tag)
{
uint next;
if (PeekNextTag(out next))
{
- if (next == currentTag)
+ if (next == tag)
{
hasNextTag = false;
return true;
@@ -486,17 +488,7 @@
}
return true;
}
-
- uint next;
- if (PeekNextTag(out next))
- {
- if (next == currentTag)
- {
- hasNextTag = false;
- return true;
- }
- }
- return false;
+ return MaybeConsumeTag(currentTag);
}
/// <summary>
@@ -512,7 +504,7 @@
do
{
list.Add(ReadString());
- } while (ContinueArray(fieldTag));
+ } while (MaybeConsumeTag(fieldTag));
}
public void ReadBytesArray(ICollection<ByteString> list)
@@ -521,7 +513,7 @@
do
{
list.Add(ReadBytes());
- } while (ContinueArray(fieldTag));
+ } while (MaybeConsumeTag(fieldTag));
}
public void ReadBoolArray(ICollection<bool> list)
@@ -729,7 +721,7 @@
do
{
list.Add((T)(object) ReadEnum());
- } while (ContinueArray(fieldTag));
+ } while (MaybeConsumeTag(fieldTag));
}
}
@@ -742,7 +734,7 @@
T message = messageParser.CreateTemplate();
ReadMessage(message);
list.Add(message);
- } while (ContinueArray(fieldTag));
+ } while (MaybeConsumeTag(fieldTag));
}
#endregion