protobuf.js icon indicating copy to clipboard operation
protobuf.js copied to clipboard

feat: support $unknownFields

Open indutny-signal opened this issue 2 years ago • 2 comments

This add $unknownFields property to generated code. It is populated on .decode() when decoder encounters currently unknown field, and similarly used by encoder to serialize unknown fields as they are into a binary data.

If user stores unknown fields and then upgrades their protobufs to the latest spec - there is a chance that some of the previously unknown fields will become known. This is handled in the encoder by attempting to decode the fields first.

The name of the field starts with $ because it is not a valid character for a field name according to protobuf v3 specification.

indutny-signal avatar Jul 12 '23 01:07 indutny-signal

Thanks @indutny-signal! We'll need some time to review this one but we'll try to do it soon.

alexander-fenster avatar Aug 21 '23 23:08 alexander-fenster

Thanks a lot! FWIW, most of the changes are just generated code in tests. I can probably rip it out of the Pull Request if you'd like!

indutny-signal avatar Aug 21 '23 23:08 indutny-signal