-
Notifications
You must be signed in to change notification settings - Fork 733
Allow customizing the equivalency behavior for BeXmlSerializable #3107
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
Conversation
Pull Request Test Coverage Report for Build 18471605921Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Qodana for .NETIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at [email protected]
|
…roperty.cs and JsonProperty.cs. Added property ExcludeXmlIgnoredMembers to IEquivalencyOptions.cs. Implemented it in CollectionMemberOptionsDecorator.cs. Implemented it in SelfReferenceEquivalencyOptions.cs. Added class ExcludeXmlIgnoredMembersRule.cs implementing IMemberSelectionRule testing IMember.IsXmlIgnored. Updated SelfReferenceEquivalencyOptions.cs to represent ExcludeXmlIgnoredMembers in the enumeration given by the SelectionRules property using an instance of ExcludeXmlIgnoredMembersRule. Added test When_an_object_is_xml_serializable_and_has_properties_marked_XmlIgnore_it_should_succeed to ObjectAssertionSpecs.BeXmlSerializable. Updated the implementation of ObjectAssertionsExtensions.BeXmlSerializable to include the .ExcludingXmlIgnoredMembers specification. This fixes test When_an_object_is_xml_serializable_and_has_properties_marked_XmlIgnore_it_should_succeed.
….cs, Property.cs and JsonProperty.cs. Added property ExcludeNonSerializedFields to IEquivalencyOptions.cs. Implemented it in CollectionMemberOptionsDecorator.cs. Implemented it in SelfReferenceEquivalencyOptions.cs. Added class ExcludeNonSerializedFieldsRule.cs implementing IMemberSelectionRule testing IMember.IsNonSerialized. Updated SelfReferenceEquivalencyOptions.cs to represent ExcludeNonSerializedFields in the enumeration given by the SelectionRules property using an instance of ExcludeNonSerializedFieldsRule. Added test When_an_object_is_binary_serializable_and_has_properties_marked_NonSerialized_it_should_succeed() to ObjectAssertionSpecs.BeDataContractSerializable. Updated the implementation of ObjectAssertionsExtensions.BeDataContractSerializable to include the .ExcludingXmlIgnoredMembers specification. This fixes test When_an_object_is_binary_serializable_and_has_properties_marked_NonSerialized_it_should_succeed().
…ield.cs, Property.cs and JsonProperty.cs. Added property ExcludeIgnoredDataMembers to IEquivalencyOptions.cs. Implemented it in CollectionMemberOptionsDecorator.cs. Implemented it in SelfReferenceEquivalencyOptions.cs. Added class ExcludeIgnoredDataMembersRule.cs implementing IMemberSelectionRule testing IMember.IsIgnoredDataMember. Updated SelfReferenceEquivalencyOptions.cs to represent ExcludeIgnoredDataMembers in the enumeration given by the SelectionRules property using an instance of ExcludeIgnoredDataMembersRule. Added test When_an_object_is_not_binary_serializable_and_has_properties_marked_IgnoreDataMember_it_should_succeed to ObjectAssertionSpecs.BeDataContractSerializable. Removed test When_a_data_contract_serializable_object_doesnt_restore_an_ignored_property_it_should_succeed. Updated the implementation of ObjectAssertionsExtensions.BeDataContractSerializable to include the .ExcludingIgnoredDataMembers specification. This fixes test When_an_object_is_not_binary_serializable_and_has_properties_marked_IgnoreDataMember_it_should_succeed.
|
Rebased to resolve merge conflict in releases.md. Took the opportunity to restructure and streamline those changes at the same time. |
…s, ExcludingIgnoredDataMembers, IncludingIgnoredDataMembers, ExcludingNonSerializedFields and IncludingNonSerializedFields from SelfReferenceEquivalencyOptions.cs. Removed calls from ObjectAssertionsExtensions.cs. Removed properties ExcludeXmlIgnoredMembers, ExcludeIgnoredDataMembers and ExcludeNonSerializedFields from IEquivalencyOptions.cs. Updated implementations in SelfReferenceEquivalencyOptions.cs and CollectionMemberOptionsDecorator.cs correspondingly. Removed the ExcludeXmlIGnoredMembersRule, ExcludeIgnoredDataMembersRule and ExcludeNonSerializedFieldsRule logic from the SelfReferenceEquivalencyOptions.SelectionRules accessor. Made the IsXmlIgnored, IsIgnoredDataMember and IsNonSerialized properties in IMember internal. Updated the implementations in Field.cs, Property.cs and JsonProperty.cs correspondingly. Added overloads of ObjectAssertionsExtensions.BeXmlSerializable and ObjectAssertionsExtensions.BeDataContractSerializable that allows EquivalencyOptions to be configured. Updated unit tests in ObjectAssertionSpecs.BeDataContractSerializable.cs and ObjectAssertionSpecs.BeXmlSerializable.cs to test that the default behaviour fails with ignored members, and that the assertion succeeds if the corresponding IMemberSelectionRule classes are `.Using()`ed. Updated releases.md and the basicassertions.md documentation page to reflect the new publicly-visible changes.
…ExcludeNonSerializedFieldsRule public.
…zable from IMember. Deleted implementations from Field.cs, Property.cs and JsonProperty.cs. Deleted types ExcludeXmlIgnoredMembersRule.cs, ExcludeIgnoredDataMembersRule.cs and ExcludeNonSerializedFieldsRule.cs. Removed tests from ObjectAssentionSpecs depending on these rules. Updated the objectgraphs.md documentation to include user-side implementations of IMemberSelectionRule providing the same functionality for ExcludeXmlIgnoredMembersRule, ExcludeIgnoredDataMembersRule and ExcludeNonSerializedFieldsRule outside of the FluentAssertions codebase.
…tAssertionSpecs.BeXmlSerializable and ObjectAssertionSpecs.BeDataContractSerializable. Moved all information about ignored members in the context of XML or Data Contract Serialization to the tips.md documentation age. Left just a one-line reference to it next to the mention of BeXmlSerializable and BeDataContractSerializable in basicassertions.md. Updated the description of the change in releases.md to track changes in the scope of the PR.
# Conflicts: # docs/_pages/releases.md
…ges/serializationignoredmembers.md. Added an entry to _data/navigation.yml to link to serializationignoredmembers under the Tips & Tricks heading.
|
|
||
| [Fact] | ||
| public void When_a_data_contract_serializable_object_doesnt_restore_an_ignored_property_it_should_succeed() | ||
| public void When_an_object_is_not_binary_serializable_and_has_properties_marked_IgnoreDataMember_and_ExcludeIgnoredDataMembers_is_not_used_it_should_fail() |
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.
🔧This and the other test tiles don't make sense anymore.
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.
Sorted 🙂
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.
Sorry, I don't get those titles. There's no support for those attributes, so why would you mention them in the test title.
Also, we don't explicitly use technical names in test titles. The titles need to remain functional.
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.
The attributes are processed by XML serialization and Data Contract serialization themselves. Their support isn't within FluentAssertions but within the framework.
BeDataContractSerializable.When_an_object_is_not_binary_serializable_and_has_properties_marked_IgnoreDataMember_it_should_fail()
This test verifies the expectation that BeDataContractSerializable fails specifically when you hand an object that is not binary-serializable and which has properties marked [IgnoreDataMember]. This behaviour is baked into the definition of what BeDataContractSerializable is, because of how the underlying DataContract serializer system works. If you present it with that and the assertion doesn't fail, then something is wrong with BeDataContractSerializable. If you give it an object that is not binary-serializable, but doesn't have [IgnoreDataMember], or an object that has fields marked [IgnoreDataMember] but also the type is marked [Serializable], then the assertion isn't expected to fail for that reason.
The names make sense in my brain, but I don't object to changing them. I'm just not sure what would be better names.
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.
Ah yes, I wasn't fully in context when I was reviewing. In this case, you can use a more generic term like "and has explicitly excluded properties" or something like that.
…ormation about ignored members.
…tests that exercise BeXmlSerializable and BeDataContractSerializable.
This PR:
[XmlIgnore].[IgnoreDataMember].[NonSerialized]..Should().BeXmlSerializable()and.Should().BeDataContractSerializable()..BeXmlSerializable()and.BeDataContractSerializable()using the new infrastructure.The first three changes are very similar to one another.
I haven't yet created an issue for the API changes.
Closes: #2626
Closes: #3108
IMPORTANT
./build.sh --target spellcheckor.\build.ps1 --target spellcheckbefore pushing and check the good outcomeCONTRIBUTOR LICENSE GRANT
By submitting this contribution, the contributor hereby irrevocably grants to the project owners and maintainers a perpetual, worldwide, royalty-free, irrevocable license to use, reproduce, modify, distribute, sublicense, and create derivative works of the contribution for any purpose and under any terms, including proprietary licensing.
The contributor waives any moral rights in the contribution to the extent permitted by law and agrees not to assert any claim of authorship or control over the contribution. The contributor represents that they are the sole author of the contribution and that it is provided free of any third-party claims.
The contributor understands and agrees that the maintainers may, at their sole discretion, use, license, or redistribute the contribution as part of any work and under any terms they choose, without further permission or attribution.