-
Notifications
You must be signed in to change notification settings - Fork 108
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
Override features defined in enclosed scopes. #479
Conversation
…troduced by Protobuf Editions. Also fixed a bug with DELIMITED encoding, i.e., the encoding for proto2 groups, that was detected by the rewritten tests.
[ const (testCase "NONE (skipped)" (pure ())) $ | ||
-- We actually cannot disable validation of UTF-8 in strings. | ||
-- This could be done by passing down the verification mode | ||
-- to the code generator and using decodeUtf8Lenient instead | ||
-- when verification is disabled. This may not be worth it; | ||
-- the content with a string containing invalid UTF-8 is undefined, | ||
-- and changing it to a bytes field would be a straightforward fix. | ||
-- | ||
-- If this was done, we would stop ignoring this test case. | ||
deserializeFrom "NONE" | ||
(Just $ defFeatures & utf8ValidationNone .~ "depends on decoding") | ||
(tagged 8 $ Lengthy invalidUtf8) |
Check warning
Code scanning / HLint
Evaluate Warning test
Found:
const (testCase "NONE (skipped)" (pure ()))
$ deserializeFrom
"NONE"
(Just $ defFeatures & utf8ValidationNone .~ "depends on decoding")
(tagged 8 $ Lengthy invalidUtf8)
Perhaps:
(testCase "NONE (skipped)" (pure ()))
, const (testCase "LENGTH_PREFIXED (skipped)" (pure ())) $ | ||
-- proto-lens sets DELIMITED encoding by message type, not field. | ||
-- Full compatability with Protobuf Editions would require it to be | ||
-- by field. However, given the usual use case for DELIMITED encoding, | ||
-- where it is to support legacy proto2 groups in which message types | ||
-- and fields are tied toggether, this may not be worth fixing. | ||
-- | ||
-- If this was done, we would stop ignoring this test case. | ||
serializeTo "LENGTH_PREFIXED" | ||
(defFeatures & messageEncodingLengthPrefixed . foo .~ 21) | ||
(braced "message_encoding_length_prefixed" $ keyedInt "foo" 21) | ||
(tagged 11 $ Lengthy $ tagged 1 $ VarInt 21) |
Check warning
Code scanning / HLint
Evaluate Warning test
Found:
const (testCase "LENGTH_PREFIXED (skipped)" (pure ()))
$ serializeTo
"LENGTH_PREFIXED"
(defFeatures & messageEncodingLengthPrefixed . foo .~ 21)
(braced "message_encoding_length_prefixed" $ keyedInt "foo" 21)
(tagged 11 $ Lengthy $ tagged 1 $ VarInt 21)
Perhaps:
(testCase "LENGTH_PREFIXED (skipped)" (pure ()))
@agrue, this last change completes support for Protobuf Editions. |
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.
Thanks for all the tests!
This completes support of Protobuf Editions to the same level that proto-lens supports proto2 and proto3 except for the following, which I do not think are critical bugs:
features.utf8_validation = NONE
does not disable UTF-8 validation.If more than one field sharing the same message type are in a single message type, and if one of the fields has
features.message_encoding = DELIMITED
, then all of these fields will useDELIMITED
encoding.Unevaluated tests are intentionally included despite warnings by HLint so that they are still built and can be easily enabled later if the above are fixed.
Resolves #468.