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

Rewrite serializer #490

Merged
merged 21 commits into from Oct 26, 2022
Merged

Rewrite serializer #490

merged 21 commits into from Oct 26, 2022

Commits on Oct 23, 2022

  1. Correctly test deserialize_ignored_any for simple type deserializers

    We expect that `deserialize_any` was called for a type. The wrapper type is only
    required to add a PartialEq trait for use in assert_eq!, so we add a #[serde(transparent)]
    Mingun committed Oct 23, 2022
    Copy the full SHA
    7883a77 View commit details
    Browse the repository at this point in the history
  2. Replace HEX escape codes in tests with decimal codes to be compatible…

    … with serializer
    
    Roundtrip with serializer will be added soon
    Mingun committed Oct 23, 2022
    Copy the full SHA
    856bfe3 View commit details
    Browse the repository at this point in the history
  3. Remove excess tests, that already covered by other tests more systema…

    …tically
    
    That cases already covered by tests in tests/serde-de.rs in `seq` and `struct_` modules
    Mingun committed Oct 23, 2022
    Copy the full SHA
    512a1e0 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    e1f64af View commit details
    Browse the repository at this point in the history
  5. Do not allow serialize unit structs as XML names. We never use struct…

    … name as a data, except in the root serializer
    Mingun committed Oct 23, 2022
    Copy the full SHA
    bf48446 View commit details
    Browse the repository at this point in the history
  6. Copy the full SHA
    d1b0a9c View commit details
    Browse the repository at this point in the history
  7. Copy the full SHA
    e24716b View commit details
    Browse the repository at this point in the history
  8. Copy the full SHA
    397422e View commit details
    Browse the repository at this point in the history
  9. Implement SimpleTypeSerializer that used for serializing content of a…

    …ttributes and text nodes
    Mingun committed Oct 23, 2022
    Copy the full SHA
    0d955d7 View commit details
    Browse the repository at this point in the history
  10. Remove $unflatten= prefix, introduced in tafia#298

    This prefix just does nothing. Deserialzier already works as with them, out-of-box.
    Support for namespaces will be done in another PR
    
    This commit reverts 8cd971e
    
    Removed tests covered by following existing tests:
    - test_parse_unflatten_field        - serde-de::struct_::elements
    - test_issue305_unflatten_namespace - serde-de::struct_::namespaces
    - test_issue305_unflatten_nesting   - serde-de::nested_struct
    
    Fixes tafia#430
    Mingun committed Oct 23, 2022
    Copy the full SHA
    459b9bf View commit details
    Browse the repository at this point in the history

Commits on Oct 26, 2022

  1. Add a $text special name

    - `$text` serialized as a simple type
    - `$value` serialized as an element with name that depends from value instead of key
    
    - Text or CDATA elements deserialized as `$value` field, if that field is expected,
      and as `#text` field, if not expected
    - any not-listed in known fields elements deserialized as a `$value` field, if that field is expected
    
    doc-test failures (2):
        src\de\mod.rs - de (line 139)
        src\de\mod.rs - de (line 36)
    
    Co-authored-by: Daniel Alley <dalley@redhat.com>
    Mingun and dralley committed Oct 26, 2022
    Copy the full SHA
    931db2e View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    ad854e1 View commit details
    Browse the repository at this point in the history
  3. Implement indentation for new serializer. Fix tafia#361

    Still 2 doc-test failures
    Mingun committed Oct 26, 2022
    Copy the full SHA
    bd0b792 View commit details
    Browse the repository at this point in the history
  4. Change expectations about results of serializing

    Serialization to attributes would be done only when field explicitly marked as an attribute
    
    failures (21):
        with_root::enum_::adjacently_tagged::flatten_struct
        with_root::enum_::adjacently_tagged::nested_struct
        with_root::enum_::adjacently_tagged::newtype
        with_root::enum_::adjacently_tagged::struct_
        with_root::enum_::adjacently_tagged::text
        with_root::enum_::adjacently_tagged::tuple_struct
        with_root::enum_::adjacently_tagged::unit
        with_root::enum_::externally_tagged::nested_struct
        with_root::enum_::externally_tagged::struct_
        with_root::enum_::externally_tagged::text
        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_::internally_tagged::unit
        with_root::enum_::untagged::nested_struct
        with_root::enum_::untagged::struct_
        with_root::enum_::untagged::text
        with_root::nested_struct
        with_root::struct_
        with_root::text
    Mingun committed Oct 26, 2022
    Copy the full SHA
    d7daaf2 View commit details
    Browse the repository at this point in the history
  5. Add tests for serialization of primitives

    This commit changes expectations from serializing primitives - they should be
    wrapped in root tag
    
    failures (53):
        with_root::char_amp
        with_root::char_apos
        with_root::char_gt
        with_root::char_lt
        with_root::char_non_escaped
        with_root::char_quot
        with_root::char_space
        with_root::enum_::adjacently_tagged::flatten_struct
        with_root::enum_::adjacently_tagged::nested_struct
        with_root::enum_::adjacently_tagged::newtype
        with_root::enum_::adjacently_tagged::struct_
        with_root::enum_::adjacently_tagged::text
        with_root::enum_::adjacently_tagged::tuple_struct
        with_root::enum_::adjacently_tagged::unit
        with_root::enum_::externally_tagged::nested_struct
        with_root::enum_::externally_tagged::primitive_unit
        with_root::enum_::externally_tagged::struct_
        with_root::enum_::externally_tagged::text
        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_::internally_tagged::unit
        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::unit
        with_root::f32_
        with_root::f64_
        with_root::false_
        with_root::i128_
        with_root::i16_
        with_root::i32_
        with_root::i64_
        with_root::i8_
        with_root::isize_
        with_root::map
        with_root::nested_struct
        with_root::option_some
        with_root::seq
        with_root::str_escaped
        with_root::str_non_escaped
        with_root::struct_
        with_root::text
        with_root::true_
        with_root::u128_
        with_root::u16_
        with_root::u32_
        with_root::u64_
        with_root::u8_
        with_root::unit
        with_root::usize_
    Mingun committed Oct 26, 2022
    Copy the full SHA
    d050c2b View commit details
    Browse the repository at this point in the history
  6. Copy all serializer tests to test serializer in mode without root tag…

    … specified
    
    Now serializer tested in both modes: with and without root tag specified
    
    failures (114):
        with_root::char_amp
        with_root::char_apos
        with_root::char_gt
        with_root::char_lt
        with_root::char_non_escaped
        with_root::char_quot
        with_root::char_space
        with_root::enum_::adjacently_tagged::empty_struct
        with_root::enum_::adjacently_tagged::flatten_struct
        with_root::enum_::adjacently_tagged::nested_struct
        with_root::enum_::adjacently_tagged::newtype
        with_root::enum_::adjacently_tagged::struct_
        with_root::enum_::adjacently_tagged::text
        with_root::enum_::adjacently_tagged::tuple_struct
        with_root::enum_::adjacently_tagged::unit
        with_root::enum_::externally_tagged::nested_struct
        with_root::enum_::externally_tagged::primitive_unit
        with_root::enum_::externally_tagged::struct_
        with_root::enum_::externally_tagged::text
        with_root::enum_::internally_tagged::empty_struct
        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_::internally_tagged::unit
        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::unit
        with_root::f32_
        with_root::f64_
        with_root::false_
        with_root::i128_
        with_root::i16_
        with_root::i32_
        with_root::i64_
        with_root::i8_
        with_root::isize_
        with_root::map
        with_root::nested_struct
        with_root::option_some
        with_root::seq
        with_root::str_escaped
        with_root::str_non_escaped
        with_root::struct_
        with_root::text
        with_root::true_
        with_root::u128_
        with_root::u16_
        with_root::u32_
        with_root::u64_
        with_root::u8_
        with_root::unit
        with_root::usize_
        without_root::char_amp
        without_root::char_apos
        without_root::char_gt
        without_root::char_lt
        without_root::char_non_escaped
        without_root::char_quot
        without_root::char_space
        without_root::enum_::adjacently_tagged::empty_struct
        without_root::enum_::adjacently_tagged::flatten_struct
        without_root::enum_::adjacently_tagged::nested_struct
        without_root::enum_::adjacently_tagged::newtype
        without_root::enum_::adjacently_tagged::struct_
        without_root::enum_::adjacently_tagged::text
        without_root::enum_::adjacently_tagged::tuple_struct
        without_root::enum_::adjacently_tagged::unit
        without_root::enum_::externally_tagged::nested_struct
        without_root::enum_::externally_tagged::primitive_unit
        without_root::enum_::externally_tagged::struct_
        without_root::enum_::externally_tagged::text
        without_root::enum_::internally_tagged::empty_struct
        without_root::enum_::internally_tagged::flatten_struct
        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_::internally_tagged::unit
        without_root::enum_::untagged::flatten_struct
        without_root::enum_::untagged::nested_struct
        without_root::enum_::untagged::newtype
        without_root::enum_::untagged::struct_
        without_root::enum_::untagged::text
        without_root::enum_::untagged::tuple_struct
        without_root::enum_::untagged::unit
        without_root::f32_
        without_root::f64_
        without_root::false_
        without_root::flatten_struct
        without_root::i128_
        without_root::i16_
        without_root::i32_
        without_root::i64_
        without_root::i8_
        without_root::isize_
        without_root::map
        without_root::nested_struct
        without_root::seq
        without_root::str_escaped
        without_root::str_non_escaped
        without_root::struct_
        without_root::text
        without_root::true_
        without_root::tuple
        without_root::u128_
        without_root::u16_
        without_root::u32_
        without_root::u64_
        without_root::u8_
        without_root::unit
        without_root::usize_
    Mingun committed Oct 26, 2022
    Copy the full SHA
    033be6e View commit details
    Browse the repository at this point in the history
  7. Removed tests, that became duplicates of new tests:

    - serialize_bool                - duplicate of `without_root::false_` and `without_root::true_`
    - serialize_struct              - duplicate of `without_root::struct_`
    - serialize_struct_value_number - duplicate of `without_root::value`
    - serialize_struct_value_string - excess test, duplicate of previous
    - serialize_enum                - duplicate of `without_root::enum_::externally_tagged::newtype`
    - serialize_a_list              - non working test that replaced by `without_root::seq`
    
    - test_empty  - duplicate of `without_root::empty_struct`
    - test_nested - duplicate of `without_root::nested_struct`
    
    Still 114 failures
    Mingun committed Oct 26, 2022
    Copy the full SHA
    0868bee View commit details
    Browse the repository at this point in the history
  8. Switch to new serializer

    Fixes tafia#252
    Fixes tafia#280
    Fixes tafia#287
    Fixes tafia#343
    Fixes tafia#346
    Fixes tafia#361
    Partially addresses tafia#368
    Fixes tafia#429
    Fixes tafia#430
    
    Fixes all tests
    
    Co-authored-by: Daniel Alley <dalley@redhat.com>
    Mingun and dralley committed Oct 26, 2022
    Copy the full SHA
    4f376b1 View commit details
    Browse the repository at this point in the history
  9. Add tests for indentation

    Mingun committed Oct 26, 2022
    Copy the full SHA
    58924da View commit details
    Browse the repository at this point in the history
  10. Change expectations about deserializing attributes

    failures (40):
        enum_::adjacently_tagged::flatten_struct::attributes
        enum_::adjacently_tagged::nested_struct::attributes
        enum_::adjacently_tagged::newtype::attributes
        enum_::adjacently_tagged::struct_::attributes
        enum_::adjacently_tagged::unit::attributes
        enum_::externally_tagged::flatten_struct::attributes
        enum_::externally_tagged::nested_struct::attributes
        enum_::externally_tagged::struct_::attributes
        enum_::internally_tagged::flatten_struct::attributes
        enum_::internally_tagged::nested_struct::attributes
        enum_::internally_tagged::struct_::attributes
        enum_::internally_tagged::unit::attributes
        enum_::untagged::flatten_struct::attributes
        enum_::untagged::nested_struct::attributes
        flatten_struct::attributes
        from_str_should_ignore_encoding
        nested_struct::attributes
        seq::fixed_name::fixed_size::list_of_struct
        seq::fixed_name::variable_size::list_of_struct
        seq::top_level::list_of_struct
        struct_::attribute_and_element
        struct_::attributes
        struct_::excess_attributes
        xml_schema_lists::attribute::bool_
        xml_schema_lists::attribute::byte_buf
        xml_schema_lists::attribute::char_
        xml_schema_lists::attribute::f32_
        xml_schema_lists::attribute::f64_
        xml_schema_lists::attribute::i128_
        xml_schema_lists::attribute::i16_
        xml_schema_lists::attribute::i32_
        xml_schema_lists::attribute::i64_
        xml_schema_lists::attribute::i8_
        xml_schema_lists::attribute::string
        xml_schema_lists::attribute::u128_
        xml_schema_lists::attribute::u16_
        xml_schema_lists::attribute::u32_
        xml_schema_lists::attribute::u64_
        xml_schema_lists::attribute::u8_
        xml_schema_lists::attribute::unit
    Mingun committed Oct 26, 2022
    Copy the full SHA
    d0dc219 View commit details
    Browse the repository at this point in the history
  11. Copy the full SHA
    8b50c64 View commit details
    Browse the repository at this point in the history