dahomey-technologies/Dahomey.Cbor

Consider letting CborReader.SkipDataItem skip semantic tags

Closed this issue · 1 comments

rmja commented

Currently a call to CborReader.SkipDataItem() does not skip semantic tags like any other call to the reader (e.g. ReadInt32).
This may lead to subtle errors where if a tag is later included in a cbor file to provide some metadata information, then the reader code fails because the call to SkipDataItem() now skips the tag and not the data as intended.

I know that this is a breaking change, however if one really wanted to skip the semantic tag, then they should call reader.TryReadSemanticTag(out _) instead of SkipDataItem().

rmja commented

This is a bug. Consider CborReader.SkipArray():

private void SkipArray()
        {
            int size = ReadSize();

            while (size > 0 || size < 0 && GetCurrentDataItemType() != CborDataItemType.Break)
            {
                SkipDataItem();
                size--;
            }

            _state = CborReaderState.Start;
        }

This code fails if any item in the array has a tag.