Skip to content
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

Merged
merged 1 commit into from
Feb 23, 2017

Conversation

thomasvl
Copy link
Collaborator

Also add tests to confirm partial and full serialization work as
expected.

/// 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 {
Copy link
Collaborator

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.)

Copy link
Collaborator

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.

Copy link
Collaborator

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 {
}
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

@tbkka tbkka left a 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.

Also add tests to confirm partial and full serialization work as
expected.
@thomasvl thomasvl merged commit 6e1b268 into apple:master Feb 23, 2017
@thomasvl thomasvl deleted the partial_encode branch February 23, 2017 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants