Bug 58093 - CoreML.MLDictionaryFeatureProvider .ctor takes wrong NSDictionary type
Summary: CoreML.MLDictionaryFeatureProvider .ctor takes wrong NSDictionary type
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 10.99 (xcode9)
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2017-07-12 01:37 UTC by Larry O'Brien
Modified: 2017-07-12 19:50 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Larry O'Brien 2017-07-12 01:37:18 UTC
I believe:

MLDictionaryFeatureProvider (MonoTouch.Foundation.NSDictionary<MonoTouch.Foundation.NSString,MonoTouch.Foundation.NSObject> dictionary, out MonoTouch.Foundation.NSError error); 

Should specify CoreML.MLFeatureValue as the second parameterized type rather than NSObject, as evidenced by the `Item` property and `IMLFeatureProvider.GetFeatureValue`.
Comment 1 Vincent Dondain [MSFT] 2017-07-12 19:50:43 UTC

I understand where this is coming from but I don't think it is a valid request.

CoreML.MLDictionaryFeatureProvider's .ctor seems to be taking a NSDictionary<NSString, NSObject> on purpose. At least it's the correct binding for the header which is:

- (nullable instancetype)initWithDictionary:(NSDictionary<NSString *, id> *)dictionary
                                      error:(NSError **)error;

It's taking an id and not a MLFeatureValue *

Unlike `Dictionary`:

@property (readonly, nonatomic) NSDictionary<NSString *, MLFeatureValue *> *dictionary;

The swift version takes `Any` too when they could have strongly typed it: https://developer.apple.com/documentation/coreml/mldictionaryfeatureprovider/2879366-init

And here are the comments in the header file for the constructor:

 * Create from a generic dictionary by converting all values to MLFeatureValues
 * or from a dictionary with values already stored as MLFeatureValues.
 * An error results if the values are not or cannot be represented as MLFeatureValues.

"from a generic dictionary by converting all values to MLFeatureValues".

I think we should leave it as is as it might be because of how they expect people to use the API, we'll see if Apple update that API in the future.