-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement message set wire format #836
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a few nits.
continue outer; | ||
} | ||
} else { | ||
throw UnsupportedError('Invalid message set item (tag = $tagNumber)'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it is better to ignore the extra field here.
I wonder what other implementations do.
Probably OK to throw. We don't have anywhere to put unknown fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we could ignore the field as the encoding is basically a repeated message encoding, and when decoding messages extra fields are always OK.
OTOH if there's an extra field here it probably means some kind of non-standard behavior or a bug in the program generating the message.
No strong opinions either way..
One concern here is binary sizes and runtime performance when the new class is not used. For binary sizes I checked a large internal dart2js app that currently does not use message sets. The binary size increased 0.007% so that should be OK. I don't know yet why the size increased though. Because the difference is so small I suspect it may just be some non-determinism in compilation. For runtime performance I checked the benchmarks in the repo. The binaries before and after this PR are identical, so it seems like at least for small apps that don't use the feature there will be no difference in generated code and runtime performance. |
Message set wire format is old and deprecated format used instead of extensions
in ancient protos.
This adds a new
GeneratedMessage
subclass$_MessageSet
to override binaryserialization and deserialization methods for message sets. Message set
messages now extend
$_MessageSet
instead ofGeneratedMessage
.The new class is prefixed as
$_
to make the addition backwards compatible.