Skip to content

Conversation

Copy link

Copilot AI commented Jan 6, 2026

Removes experimental plural form matching logic from XmlDeserializer.HandleListDerivative() while preserving the core nested element fix. Refactors test classes from domain-specific names (Category/Categories) to generic names (Item/Items).

Changes

XmlDeserializer.cs

  • Removed plural form attempts (name + "s", lowercase + "s") from container lookup
  • Container matching now only uses property name directly
  • Preserved Elements() vs Descendants() logic that fixes nested element inclusion bug
  • Added IsValidXmlElementName() helper for generic type name validation
  • Fixed RemoveNamespace() to filter null attributes
  • Fixed RootElement selection to prefer shallowest match

Test classes (NestedElementTestClasses.cs)

  • CategoryItem
  • CategoryContainerItemContainer
  • CategoryWithAssociationsItemWithGroup
  • CategoryAssociationsItemGroup
  • CategoriesResponseItemsResponse
  • All XML test data uses <item>, <items>, <subitems> instead of category terminology

Example

Before (with plural logic):

// Tried multiple plural variations
container = GetElementByName(root, (name.ToLower() + "s").AsNamespaced(Namespace));
container = GetElementByName(root, (name + "s").AsNamespaced(Namespace));

After (property name only):

// Direct property name lookup only
if (IsValidXmlElementName(propName)) {
    container = GetElementByName(root, propName.AsNamespaced(Namespace));
}

Tests validate proper handling of nested structures without relying on pluralization heuristics:

<items>
    <item>
        <id>1</id>
        <subitems>
            <item><id>2</id></item>  <!-- Not included in parent list -->
        </subitems>
    </item>
</items>
Original prompt

in branch copilot/fix-xml-deserializer-bugs remove in xmldeserializer tries with plural forms and in new test added make it more general samples avoid use category or associations but something like item items group subgroupt etc


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix XML deserializer plural forms and improve test samples Remove plural form heuristics from XmlDeserializer and use generic test names Jan 6, 2026
Copilot AI requested a review from pumamood January 6, 2026 22:23
@pumamood pumamood marked this pull request as ready for review January 6, 2026 22:24
@pumamood pumamood merged commit b528c1c into dev Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants