Project

Profile

Help

Bug #4296

closed

XdmEnumerator on .NET

Added by Michael Kay about 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Category:
.NET API
Sprint/Milestone:
-
Start date:
2019-08-23
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.9, trunk
Fix Committed on Branch:
9.9, trunk
Fixed in Maintenance Release:
Platforms:

Description

See also issue #4290.

The 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 IXdmEnumerator.

Actions #1

Updated by Michael Kay about 5 years ago

Note also XPathSelector and 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.

Actions #2

Updated by Michael Kay about 5 years 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 IXdmEnumerable. Make XdmValue.GetEnumerator() return non-generic IEnumerator as it did in 9.8. Having XdmValue.GetEnumerator() return 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 IXdmEnumerator<XdmAtomicValue>.

(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 IEnumerable<XdmItem>.

(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.

Actions #3

Updated by Michael Kay about 5 years ago

  • Status changed from New to In Progress
Actions #4

Updated by Michael Kay about 5 years ago

We've decided to clean this up, at the cost of taking a bit of a hit in terms of backwards compatibility.

The classes IXdmEnumerator and IXdmEnumerable disappear; in their place we use IEnumerator<XdmItem> and IEnumerable<XdmItem>.

Any code that implements ExtensionFunctionCall will need to change; in most cases it's just a matter of changing IXdmEnumerator to IEnumerator<XdmItem> in both the arguments and the result type of the Call() method.

Also affected is any 9.8 code that explicitly casts the results of (for example) XPathSelector.GetEnumerator() to IXdmEnumerator (as was done in some of the sample applications, which have now been rewritten).

Actions #5

Updated by Michael Kay about 5 years ago

  • Status changed from In Progress to Resolved
  • Applies to branch 9.9, trunk added
  • Fix Committed on Branch 9.9, trunk added
Actions #6

Updated by O'Neil Delpratt about 5 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 9.9.1.5 added

Bug fix applied in the Saxon 9.9.1.5 maintenance release.

Please register to edit this issue

Also available in: Atom PDF