Project

Profile

Help

Bug #5183

FeatureKey<Class> mechanism in C# doesn't work

Added by Michael Kay about 2 months ago. Updated 17 days ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
.NET API
Sprint/Milestone:
-
Start date:
2021-12-03
Due date:
% Done:

0%

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

Description

SaxonCS had adopted the same scheme of defining FeatureKey as a generic class parameterised by the type of the property. In Java this means you can do

processor.setProperty(FeatureKey.TIMING, true)

and you get a type error if you try to supply a string rather than a boolean.

On C# this doesn't work.

Firstly, you have to specify the type explicitly:

processor.setProperty(FeatureKey<boolean>.TIMING, true)

which tends to outweigh any convenience factor.

More seriously, it's not possible to do

processor.setProperty(FeatureKey<URIResolver>.URI_RESOLVER, new MyResolver())

if MyResolver is a subclass of URIResolver.

I'm therefore proposing to degenerify Feature and FeatureKey, with a loss of type-safety by an improvement in usability.

This is an incompatible change.

History

#3 Updated by Michael Kay 17 days ago

  • Category set to .NET API
  • Status changed from New to Resolved
  • Priority changed from Low to Normal
  • Applies to branch 11, trunk added
  • Fix Committed on Branch trunk added

The change has been made and documented and will affect SaxonCS 11.1.

Please register to edit this issue

Also available in: Atom PDF