Skip to content

Remove or document field set implementations for extensions and unknown fields #687

@osa1

Description

@osa1

Currently we have 3 field set implementations:

I don't understand why we need 3 different implementations and it's not documented. Conceptually we just need to map integers (field tags) to proto values. As far as I understand, the only difference between a known field and an unknown field is that for unknown fields FieldInfo won't be available. We don't need this much code for this.

We will probably need a new value class (like PbMap, PbList) for unknown length-delimited values (strings, bytes, messages, repeated fields). The representation will just be Uint8List.

I'm not sure if we need to support groups, but we will need another value class for unknown groups, with Uint8List to store the group contents.

When we need to check whether the field for a tag is known, unknown, or extension, we could have Set<int> unknownFields and Set<int> extensionFields in _FieldInfo.

One question is how to merge two unknown groups or length-delimiteds. Merging values is not specified in proto spec. We have two options:

  • Collect values of merged groups and length-delimited stuff. This means PbUnknownLengthDelimited (or whatever we want to call it) will store List<Uint8List> instead of just Uint8List, and add to the list as we merge values. Same for groups.

    This is currently what we do in UnknownFieldSet.

  • Override the current value. This is simpler.

If I'm missing something and we really need 2 extra classes and a few hundred extra lines and tests then we should document why this is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions