Incorrect(?) "Possible NullReferenceException" with XLinq

I have the following XLinq query:

XDocument.Load("toc.xml").Descendants("Command").Where(o =>
o.Attribute("name") != null).Distinct().OrderBy(o =>
o.Attribute("name").Value)

R# notes that 'o.Attribute("name")' in the OrderBy lambda parameter could
produce a NullReferenceException. However, I believe the structures used in
XLinq are immutable, so the previous Where clause should ensure a non-null
value here. This would seem to be a special case that R# should be capable
of handling.

Cheers,
Mike

Please sign in to leave a comment.