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

Implement correct handling of $text fields in enums and add roundtrip tests #574

Merged
merged 7 commits into from
Mar 7, 2023

Conversation

Mingun
Copy link
Collaborator

@Mingun Mingun commented Mar 6, 2023

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.

This is important for Untagged enum for deserialization.
Change all definitions for consistency.
@Mingun Mingun added bug serde Issues related to mapping from Rust types to XML labels Mar 6, 2023
@Mingun Mingun requested a review from dralley March 6, 2023 16:37
@Mingun Mingun mentioned this pull request Mar 6, 2023
13 tasks
@dralley
Copy link
Collaborator

dralley commented Mar 6, 2023

Looking at the serde PRs, it looks a bit stagnant unfortunately. Lots of them open with no progress

@Mingun
Copy link
Collaborator Author

Mingun commented Mar 6, 2023

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`.
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Mingun and others added 5 commits March 7, 2023 20:46
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug serde Issues related to mapping from Rust types to XML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants