Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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));
        }