-
Notifications
You must be signed in to change notification settings - Fork 236
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 correct handling of $text
fields in enums and add roundtrip tests
#574
Conversation
This is important for Untagged enum for deserialization. Change all definitions for consistency.
Looking at the |
Yeah, it is. Quite surprising for that widely used library. |
@@ -75,7 +70,23 @@ enum ExternallyTagged { | |||
Empty {}, | |||
} | |||
|
|||
/// Having both `#[serde(flatten)]` and `'static` fields in one struct leads to | |||
/// incorrect code generation when deriving `Deserialize`. |
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.
Can we have a consistent way we can mark code which depends on fixing external bugs, such that they can be easily searched? Maybe TODO(external)
or something.
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.
Yes, I forgot to mark those places with a TODO, will do!
I used an usual TODO
and NOTE
markers -- there are not many of them and the todo-tree VSCode extension shows them very well.
failures (23): with_root::char_space with_root::enum_::externally_tagged::text::tuple with_root::enum_::internally_tagged::nested_struct with_root::enum_::internally_tagged::newtype with_root::enum_::internally_tagged::struct_ with_root::enum_::internally_tagged::text with_root::enum_::untagged::nested_struct with_root::enum_::untagged::newtype with_root::enum_::untagged::struct_ with_root::enum_::untagged::text with_root::enum_::untagged::tuple_struct with_root::enum_::untagged::unit with_root::flatten_struct with_root::str_escaped with_root::tuple without_root::enum_::externally_tagged::text::tuple without_root::enum_::internally_tagged::nested_struct without_root::enum_::internally_tagged::newtype without_root::enum_::internally_tagged::struct_ without_root::enum_::internally_tagged::text without_root::enum_::untagged::nested_struct without_root::enum_::untagged::struct_ without_root::enum_::untagged::text
Internally tagged and untagged enums implemented via intermediate buffering which extracts incorrect form from the XML deserializer (Map or Str). Attempt to deserialize types from that representation failed, because only the deserializer knows, how to convert types using the requested type hints failures (5): with_root::char_space with_root::enum_::externally_tagged::text::tuple with_root::str_escaped with_root::tuple without_root::enum_::externally_tagged::text::tuple
failures (2): with_root::enum_::externally_tagged::text::tuple without_root::enum_::externally_tagged::text::tuple
This is follow-up PR for #541 in which I forgot to make a corresponding serialization for the deserialization. In order to not make this mistake again, the last 6 commits enables serialization-deserialization roundtrip in serialization tests -- we try to deserialize what was serialized and check that we get the same object.
During that I found that some roundrips does not work, mostly because of serde-rs/serde#1183. That tests does not check the roundtrip.
Some structs failed to derive
Deserialize
due to serde-rs/serde#2371. Although it is possible to implement it manually or use my fork where that error is fixed specially for that, the same tests suffers from the serde-rs/serde#1183 too, so I ended up with the current approach in order to reduce dependencies.