C#, .NET 6.0
Short:
XElement is implementing IXmlLineInfo. However, IXmlLineInfo methods are not directly available over an instance of XElement. Why?
Long:
XElement is in the inheritance/implementation tree XElement > XContainer > XNode > XObject > IXmlLineInfo. IXmlLineInfo is declaring two properties and one method. I always though that if X (even indirectly) implements IX, then, on instance of X, I can access all the (public) members of IX. However, over an instance of XElement, those members of IXmlLineInfo are not available. I have to cast XElement to IXmlLineInfo to access the members.
XDocument doc = XDocument.Load("c:\\doc.xml");
XElement root = doc.Root!;
IXmlLineInfo lineInfo = root;
int a = lineInfo.LineNumber; // works correctly
int b = root.LineNumber; // throws a syntax error - why, as the underlying object is the same?
Why are not members of IXmlLineInfo available directly? What am I missing?