-
Notifications
You must be signed in to change notification settings - Fork 466
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
Add partial support to binary serialization support. #303
Conversation
/// is throw if any were missing. When `partial` is `true`, then partial | ||
/// messages are allowed, and `Message.isRequired` is not checked. | ||
/// - Throws: An instance of `EncodingError` on failure . | ||
func serializedData(partial: Bool = false) throws -> Data { |
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.
Should this be different for proto2 vs. proto3? (Since proto3 doesn't have required
and never will.)
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.
A proto3 message could still have a proto2 message nested inside it, so partial
needs to be supported there as well.
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.
Ah. Good point.
@@ -167,7 +167,7 @@ class Test_Required: XCTestCase, PBTestHelpers { | |||
} |
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.
Just noticed this: We should have a real text format serializer method in addition to the debugDescription
hook (because people actually do use text format as an interchange format). That would remove the need to play games just above to massage the expected text into the debugDescription
format.
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.
We do (https://github.com/apple/swift-protobuf/blob/master/Sources/SwiftProtobuf/TextFormatTypeAdditions.swift#L22), it still throws, which have an issue to clean up. So for the moment I believe the debugDescription
is a hair easier to deal with. Once it does't throw, we're probably good to use it in testing asserts.
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.
Looks good, though I did put in two questions to satisfy my curiosity.
30bcb65
to
b5ba584
Compare
Also add tests to confirm partial and full serialization work as expected.
b5ba584
to
c51ffc1
Compare
Also add tests to confirm partial and full serialization work as
expected.