Bug 58792 - PresentAsync (and other methods) contain out parameter that is captured in task type
Summary: PresentAsync (and other methods) contain out parameter that is captured in ta...
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools (show other bugs)
Version: XI 10.99 (xcode9)
Hardware: PC Mac OS
: Normal normal
Target Milestone: Future Cycle (TBD)
Assignee: Alex Soto [MSFT]
Depends on:
Reported: 2017-08-15 21:09 UTC by Mike Norman
Modified: 2017-08-15 21:32 UTC (History)
2 users (show)

See Also:
Is this bug a regression?: No
Last known good build:


Description Mike Norman 2017-08-15 21:09:10 UTC

In MonoTouch.UIKit.UIPrinterPickerController, the method:

public virtual System.Threading.Tasks.Task<MonoTouch.UIKit.UIPrinterPickerCompletionResult>; PresentAsync (bool animated, out bool result);

contains an `out bool` parameter that captures (I think) whether or not the user selected a printer. The UIPrinterPickerCompletionResult that is passed to the Task<T> contains a field that does exactly this. There are other versions of PresentAsync that make more sense to asyncify.

This is not an isolated issue, as there are other places (in UIKit, alone) where this occurs.

Maybe only asyncify the PresentAsync overload that does not contain an `out bool` parameter that is captured in the return value. (Though that sounded like snark, I meant only to convey that, while I can't see a reason for these bindings, there may be one of which I am not aware.)
Comment 1 Sebastien Pouliot 2017-08-15 21:32:06 UTC
Thanks @Mike!

There might be other cases but both `out` and `ref` are good signs of API that are not really usable with async.

What we need to do, in no particular order

1. btouch should emit a warning if `[Async]` is used on such API; it cannot be an error since it would break binary compatibility for anyone who made that mistake. It's possible to use `-warnaserror` to avoid future mistakes;

2. Our introspection tests should spot those conditions and report errors on the bots;

3. Obsolete our existing API that expose `out` or `ref` parameters and exclude them from XAMCORE_4_0;

@Alex please start with #1. I'll try to handle #2 and #3 independently.

Note You need to log in before you can comment on or make changes to this bug.