private void SkipGroup() { var startGroupTag = _lastTag; while (true) { var tag = ReadTag(); if (tag == 0U) { throw OutOfInputException(); } if (WireFormat.GetWireType(tag) != WireType.EndGroup) { SkipField(); continue; } var startGroupFieldNumber = WireFormat.GetFieldNumber(startGroupTag); var endGroupFieldNumber = WireFormat.GetFieldNumber(tag); if (startGroupFieldNumber == endGroupFieldNumber) { return; } var message = $"Mismatched end-group tag. Started with field {startGroupFieldNumber}; ended with field {endGroupFieldNumber}"; throw new InvalidDataException(message); } }
private static void AssertTagOk(int field, WireType wireType) { var tag = WireFormat.MakeTag(field, wireType); Assert.Equal(field, WireFormat.GetFieldNumber(tag)); Assert.Equal(wireType, WireFormat.GetWireType(tag)); Assert.Equal(wireType, (WireType)(tag & 7)); Assert.Equal(field, (int)(tag >> 3)); }