XdmEnumerator on .NET
See also issue #4290.
ExtensionFunctionDefinition/ExtensionFunctionCall inferface on .NET requires user-written code to return an
IXdmEnumerator. However, we do not provide any useful ways of constructing an
IXdmEnumerator; we have implementations of this interface, but with the exception of
EmptyEnumerator, they are not exposed.
It would be useful (for starters) if
XdmValue.Enumerate() returned an
IXdmEnumerator rather than its superclass,
IEnumerator<XdmItem>. Alternatively we could relax the definition of
ExtensionFunctionCall.Call() so it is allowed to return any
IEnumerator<XdmItem>, not necessarily an
#1 Updated by Michael Kay 26 days ago
XQueryEvaluator both have the capability to return an
IEnumerator (should be
IEnumerator<XdmItem> perhaps?), rather than XdmEnumerator. I suggest we move towards returning
XdmEnumerator, while accepting
IEnumerator<XdmItem>. But we should probably review more carefully all the usages of these classes.
#2 Updated by Michael Kay 16 days ago
This whole area looks very messy. I've spent some time looking at it, and I'm inclined to do the following:
(a) Wind back some of the changes we made in 9.9 to generify things. That is, get rid of the generified
IXdmEnumerator<XdmItem>, as well as
XdmValue.GetEnumerator() return non-generic
IEnumerator as it did in 9.8. Having
IXdmEnumerator<XdmItem> rather than the non-generic
IXdmEnumerator doesn't add value, given that we're not overriding it with methods that return a more specific type, e.g.
XdmAtomicValue.GetEnumerator() isn't declared to return
(b) In 10.0, get rid of
IXdmEnumerator entirely. It's only used in
ExtensionFunctionCall. Have its implementing classes implement
IEnumerator<XdmItem> instead; and make
GetEnumerator() on subtypes return a more specific type, e.g.
IEnumerator<XdmAtomicValue>. Change the
ExtensionFunctionCall.Call() method to accept and return
(c) For 9.9 as well as 10.0, ensure that an implementation of
ExtensionFunctionCall.Call() can construct its return value using, for example,
new XdmAtomicValue(123).GetEnumerator(). To do this, relax the return type of the method if necessary.
#4 Updated by Michael Kay 15 days ago
We've decided to clean this up, at the cost of taking a bit of a hit in terms of backwards compatibility.
IXdmEnumerable disappear; in their place we use
Any code that implements
ExtensionFunctionCall will need to change; in most cases it's just a matter of changing
IEnumerator<XdmItem> in both the arguments and the result type of the
Also affected is any 9.8 code that explicitly casts the results of (for example)
IXdmEnumerator (as was done in some of the sample applications, which have now been rewritten).
Please register to edit this issue