Skip to content
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

Visitors example in README doesn't work #33

Open
CoderNate opened this issue May 12, 2015 · 1 comment
Open

Visitors example in README doesn't work #33

CoderNate opened this issue May 12, 2015 · 1 comment

Comments

@CoderNate
Copy link

The visitors example in the README that adds an xsi:nil attribute doesn't work. The "when" function never sees values that are null. In ObjectNode.cs, members with null values are filtered out in the EnumerateMembers function before they can ever be tested by the "when" function of the visitor:

if (Context.Mode.IsSerialize()) members = members
                .Where(x => x.Value.Instance != null && ...

Also, if the 'when' test did pass, the visitor action would fail when trying to create an XAttribute:

var xsiNamespace = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance");
var succeeds = new XAttribute(xsiNamespace + "nil", "true"); //Succeeds
// The following fails with XmlException "The ':' character, hexadecimal value 0x3A, cannot be included in a name."
var fails = new XAttribute("xsi:nil", "true"); 
@mikeobrien
Copy link
Owner

Thx for catching that, I'll get it fixed.

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

No branches or pull requests

2 participants