Bug 43928 - Selectors for optional protocol methods are undiscoverable (e.g., IINSearchForMessagesIntentHandling)
Summary: Selectors for optional protocol methods are undiscoverable (e.g., IINSearchFo...
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 9.99 (iOS 10 previews)
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2016-08-31 23:53 UTC by Larry O'Brien
Modified: 2016-09-01 07:24 UTC (History)
3 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 2016-08-31 23:53:34 UTC
In Intents, there are a number of IN{Foo}Handling protocols (for instance, IINSearchForMessagesIntentHandling). The optional methods for the protocols are implemented using the {Foo}_Extensions pattern but these methods are associated with selectors. We (apparently) require the developer to Export the correct selector (see, for instance, the Intents Extension template).  

For instance, a person implementing the method defined in INSearchForMessagesIntentHandling_Extensions.ResolveRecipients must not only implement the method (which is expected) but must also decorate that method with the appropriate ExportAttribute:

 [Export ("resolveRecipientsForSearchForMessages:withCompletion:")]
 public void ResolveRecipients (INSendMessageIntent intent, Action<INPersonResolutionResult []> completion)

How would a user (a) anticipate that this is necessary and (b) know what selector to export? 

I'm not sure if this is a general problem with the ProtocolAttribute or has to do with the particular way it was used to bind Intents. Obviously I can explain what needs to happen in the API docs, but is this really the best experience we can provide our users?
Comment 1 Sebastien Pouliot 2016-09-01 02:05:09 UTC
C# has no support for optional members in interfaces and we can't implement stubs because their mere presence influence how code is executed.

There's more details in [1] but that should (and I thought was [1]) handled by the IDE, a bit like overriding a virtual method. 

@Rolf do you recall about the IDE part ?

[1] https://trello.com/c/OaYCjOw7/117-protocol-improvements
Comment 2 Rolf Bjarne Kvinge [MSFT] 2016-09-01 07:24:14 UTC
In Xamarin Studio you can write "override " and the optional methods will show up in the completion list (if optional members don't show up it's a bug).

I'm not sure the same thing works in Visual Studio though.