-
-
Notifications
You must be signed in to change notification settings - Fork 544
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
BeXmlSerializable does not respect XmlIgnoreAttribute #2626
Comments
I'm not sure this is an issue with the process not ignoring members. Based on the code for the fluentassertions/Src/FluentAssertions/ObjectAssertionsExtensions.cs Lines 100 to 121 in 060c463
According to line 107 there, the deserialized object should be equivalent to the subject of the assertion. This, combined with my (albeit severely lacking) understanding of how the equivalency test works, should (currently) fail because the ignored members won't be set in the deserialized object. @dennisdoomen, can this be assigned to me? |
After further investigation, this is certainly not an issue with XML serialization, but rather how the assertion process handles equivalency: As my screenshot shows, ignored members are not set during the deserialization process, and as a result the equivalency will fail. I am currently researching how involved of a change it would be to add support for this. I think the most surgical route would be to update deserializedObject.Should().BeEquivalentTo(assertions.Subject,
static options => options
.RespectingRuntimeTypes()
.IncludingFields()
.IncludingProperties()
.ExcludeIgnoredMembers()); My biggest remaining question is if this new method should be specific to XML or not as |
I've defined a unit test to cover this scenario and opened a draft PR to begin working this in full. I simply need guidance on the following to prove as effective as possible on the issue:
|
I think a simpler approach could be to add a custom |
Is it possible to choose an implementation that also enables |
Description
BeXmlSerializable creates a clone using XmlSerializer. XmlSerializer ignores members marked by XmlIgnoreAttribute.
The resulting clone is compared with the original. But this comparison does NOT ignore members marked by XmlIgnoreAttibute.
Reproduction Steps
Expected behavior
Test should succeed.
Actual behavior
Test fails.
Regression?
No response
Known Workarounds
No response
Configuration
FluentAssertions Version="6.12.0"
MSTest.TestAdapter/Framework Version="2.2.8"
net472 and net6.0-windows
Other information
No response
Are you willing to help with a pull-request?
No
The text was updated successfully, but these errors were encountered: