Skip to content

XmlDeserializer issue not handling lowercase + dash root elements in some cases #269

@zidad

Description

@zidad

Issue description in this post:
https://groups.google.com/forum/?fromgroups#!topic/restsharp/xww5tH0QAC0

Quoted here:
I'm writing a wrapper for BaseCamp API and ran into an issue.

The xml I'm getting back has this structure:

<todo-lists>
<todo-list>
</todo-list>
</todo-lists>

The problem is in HandleListDerivative since it does not try the
lowercased, "undashed" version for element names.

What I don't know is that what is the idea behind on operating on
Descendants when deserializing a list and not operating on children
nodes only?

Adding this code fixes this problem:

if (!elements.Any())
{
var lowerName = name.ToLower().AsNamespaced(Namespace);
elements = root.Descendants().Where(e => e.Name.LocalName.RemoveUnderscoresAndDashes() == lowerName);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions