private void SkipGroup(uint startGroupTag) { // 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; while (true) { tag = ReadTag(); if (tag == 0) { throw InvalidProtocolBufferException.TruncatedMessage(); } // Can't call SkipLastField for this case- that would throw. if (WireFormat.GetTagWireType(tag) == WireFormat.WireType.EndGroup) { break; } // This recursion will allow us to handle nested groups. SkipLastField(); } int startField = WireFormat.GetTagFieldNumber(startGroupTag); int endField = WireFormat.GetTagFieldNumber(tag); if (startField != endField) { throw new InvalidProtocolBufferException( String.Format("Mismatched end-group tag. Started with field {0}; ended with field {1}", startField, endField)); } recursionDepth--; }
/// <summary> /// Encodes and writes a tag. /// </summary> /// <param name="fieldNumber">The number of the field to write the tag for</param> /// <param name="type">The wire format type of the tag to write</param> public void WriteTag(int fieldNumber, WireFormat.WireType type) { WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type)); }
/// <summary> /// Encodes and writes a tag. /// </summary> /// <param name="fieldNumber">The number of the field to write the tag for</param> /// <param name="type">The wire format type of the tag to write</param> public void WriteTag(int fieldNumber, WireFormat.WireType type) { WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type)); }
/// <summary> /// Encodes and writes a tag. /// </summary> public static void WriteTag(ref Span <byte> buffer, ref WriterInternalState state, int fieldNumber, WireFormat.WireType type) { WriteRawVarint32(ref buffer, ref state, WireFormat.MakeTag(fieldNumber, type)); }
internal bool ContainsInputField(CodedInputStream stream, Type target, out Extension extension) { return(extensions.TryGetValue(new ObjectIntPair <Type>(target, WireFormat.GetTagFieldNumber(stream.LastTag)), out extension)); }
/// <summary> /// Computes the number of bytes that would be needed to encode a tag. /// </summary> public static int ComputeTagSize(int fieldNumber) { return(ComputeRawVarint32Size(WireFormat.MakeTag(fieldNumber, 0))); }
public static int ComputeTagSize(int fieldNumber) { return(CodedOutputStream.ComputeRawVarint32Size(WireFormat.MakeTag(fieldNumber, WireFormat.WireType.Varint))); }