-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix XmlDeserializer when XML uses same tag in nested elements #2336
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
base: dev
Are you sure you want to change the base?
Conversation
…sted XML * Fix XmlDeserializer nested element bugs - Fix Bug #1: HandleListDerivative now uses Elements() on containers instead of Descendants() - Fix Bug #2: Deserialize RootElement selection prefers shallowest match - Fix Bug #3: RemoveNamespace filters null values - Add comprehensive tests for all three fixes
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
|
@dotnet-policy-service agree |
User description
Description
This pull request improves the robustness and correctness of XML deserialization in the
XmlDeserializerclass, particularly around handling nested elements and root element selection. It addresses bugs where nested lists were incorrectly flattened and where ambiguous root element names caused errors. The changes are thoroughly tested with new unit tests and supporting sample classes.Improvements to XML deserialization logic:
Elements()) instead of all descendants (viaDescendants()), preventing deeply nested items from being incorrectly included in top-level lists. [1] [2]Bug fixes and test coverage:
Purposee
Checklist
Auto-created Ticket
#2337
PR Type
Bug fix, Tests
Description
Fix nested list deserialization using Elements() instead of Descendants()
Improve root element selection to prefer shallowest matching element
Filter null values in RemoveNamespace method
Add validation for XML element names containing invalid characters
Enhance container-based list handling with direct child element matching
Diagram Walkthrough
File Walkthrough
XmlDeserializer.cs
Refactor root selection and list deserialization logicsrc/RestSharp.Serializers.Xml/XmlDeserializer.cs
using OrderBy on ancestor count
DescendantsAndSelf() with ordering
containing backticks
searching descendants
of Descendants()
assignments
children only
NestedElementTestClasses.cs
Add test sample classes for nested elementstest/RestSharp.Tests.Serializers.Xml/SampleClasses/NestedElementTestClasses.cs
XmlDeserializerTests.cs
Add comprehensive tests for nested element fixestest/RestSharp.Tests.Serializers.Xml/XmlDeserializerTests.cs
throwing