We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
skip_serializing and skip_serializing_if are not working for Enum, Struct (children of the root) and Vec.
The following snippets of code can be inserted in the skip.rs test suite to reproduce the bug for skip_serializing
skip.rs
#[test] fn skip_serializing_for_nested_struct() { init(); #[derive(YaSerialize, PartialEq, Debug)] #[yaserde(rename = "base")] pub struct XmlStruct { #[yaserde(skip_serializing)] skipped_serializing: XmlStructChild, } #[derive(YaSerialize, PartialEq, Debug)] #[yaserde(rename = "child")] pub struct XmlStructChild { } let model = XmlStruct { skipped_serializing: XmlStructChild{}, }; let content = "<base />"; serialize_and_validate!(model, content); } #[test] fn skip_serializing_for_enum() { init(); #[derive(YaSerialize, PartialEq, Debug)] #[yaserde(rename = "base")] pub struct XmlStruct { #[yaserde(skip_serializing)] skipped_serializing: XmlEnum, } #[derive(YaSerialize, PartialEq, Debug)] #[yaserde(rename = "child")] pub enum XmlEnum { Ok } let model = XmlStruct { skipped_serializing: XmlEnum::Ok, }; let content = "<base />"; serialize_and_validate!(model, content); } #[test] fn skip_serializing_for_vec() { init(); #[derive(YaSerialize, PartialEq, Debug)] #[yaserde(rename = "base")] pub struct XmlStruct { #[yaserde(skip_serializing)] skipped_serializing: Vec<i8>, } let model = XmlStruct { skipped_serializing: vec![1,2,3], }; let content = "<base />"; serialize_and_validate!(model, content); }
the following snippets can be used in serializing_if.rs file to reproduce the conditional serialization issue
serializing_if.rs
#[test] fn skip_serializing_if_for_nested_struct() { init(); #[derive(YaSerialize, PartialEq, Debug)] #[yaserde(rename = "base")] pub struct XmlStruct { #[yaserde(skip_serializing_if="check_child")] skipped_serializing: XmlStructChild, } impl XmlStruct { fn check_child(&self, _child:&XmlStructChild)->bool { true } } #[derive(YaSerialize, PartialEq, Debug)] #[yaserde(rename = "child")] pub struct XmlStructChild { } let model = XmlStruct { skipped_serializing: XmlStructChild{}, }; let content = "<base />"; serialize_and_validate!(model, content); } #[test] fn skip_serializing_if_for_enum() { init(); #[derive(YaSerialize, PartialEq, Debug)] #[yaserde(rename = "base")] pub struct XmlStruct { #[yaserde(skip_serializing_if="check_enum")] skipped_serializing: XmlEnum, } impl XmlStruct { fn check_enum(&self, _child:&XmlEnum)->bool { true } } #[derive(YaSerialize, PartialEq, Debug)] #[yaserde(rename = "child")] pub enum XmlEnum { Ok } let model = XmlStruct { skipped_serializing: XmlEnum::Ok, }; let content = "<base />"; serialize_and_validate!(model, content); } #[test] fn skip_serializing_if_for_vec() { init(); #[derive(YaSerialize, PartialEq, Debug)] #[yaserde(rename = "base")] pub struct XmlStruct { #[yaserde(skip_serializing_if="check_vec")] skipped_serializing: Vec<i8>, } impl XmlStruct { fn check_vec(&self, _child:&Vec<i8>)->bool { true } } let model = XmlStruct { skipped_serializing: vec![1,2,3], }; let content = "<base />"; serialize_and_validate!(model, content); }
The issue is located expand_struct.rs where the conditions are generated, but never kept in consideration for Enum, Struct and Vec
expand_struct.rs
I'm working on pull request that fix the issue
Related, but different or partial issues are: #131 #139
The text was updated successfully, but these errors were encountered:
With the merge of #153 this is now solved
Sorry, something went wrong.
No branches or pull requests
Description
skip_serializing and skip_serializing_if are not working for Enum, Struct (children of the root) and Vec.
How to procedure
The following snippets of code can be inserted in the
skip.rs
test suite to reproduce the bug for skip_serializingthe following snippets can be used in
serializing_if.rs
file to reproduce the conditional serialization issueAnalisys
The issue is located
expand_struct.rs
where the conditions are generated, but never kept in consideration for Enum, Struct and VecSolutions
I'm working on pull request that fix the issue
Notes
Related, but different or partial issues are:
#131
#139
The text was updated successfully, but these errors were encountered: