From e238dac2965f8e1febe8d53da384123b43c7799f Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Thu, 12 Jan 2017 14:35:11 -0500 Subject: [PATCH] [ios][uikit] Fix [Model] in public API w/workarounds --- src/UIKit/Compat.cs | 12 +++++++++++ src/UIKit/UIActionSheet.cs | 6 ++++-- src/UIKit/UIAlertView.cs | 8 +++++++- src/uikit.cs | 11 ++++++++-- tests/introspection/ApiSignatureTest.cs | 2 +- .../introspection/iOS/iOSApiSignatureTest.cs | 20 +++++++++++++++++++ 6 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/UIKit/Compat.cs b/src/UIKit/Compat.cs index 73c504a7ea..5d12fd35a8 100644 --- a/src/UIKit/Compat.cs +++ b/src/UIKit/Compat.cs @@ -8,6 +8,7 @@ using System; +using XamCore.CoreGraphics; namespace XamCore.UIKit { @@ -77,5 +78,16 @@ namespace XamCore.UIKit { { } } + +#if !TVOS + public partial class UIPreviewInteraction { + [Obsolete ("Use overload accepting a IUICoordinateSpace")] + public virtual CGPoint GetLocationInCoordinateSpace (UICoordinateSpace coordinateSpace) + { + return GetLocationInCoordinateSpace ((IUICoordinateSpace) coordinateSpace); + } + } +#endif + #endif } diff --git a/src/UIKit/UIActionSheet.cs b/src/UIKit/UIActionSheet.cs index 566fb58f3d..c409922572 100644 --- a/src/UIKit/UIActionSheet.cs +++ b/src/UIKit/UIActionSheet.cs @@ -18,7 +18,8 @@ using XamCore.Foundation; namespace XamCore.UIKit { public partial class UIActionSheet : IEnumerable { -#if !XAMCORE_3_0 +#if !XAMCORE_4_0 + [Obsolete ("Use overload with a IUIActionSheetDelegate parameter")] public UIActionSheet (string title, UIActionSheetDelegate del, string cancelTitle, string destroy, params string [] other) : this (title, del as IUIActionSheetDelegate, cancelTitle, destroy, other) { @@ -46,7 +47,8 @@ namespace XamCore.UIKit { CancelButtonIndex = AddButton (cancelTitle); } -#if !XAMCORE_3_0 +#if !XAMCORE_4_0 + [Obsolete ("Use overload with a IUIActionSheetDelegate parameter")] public UIActionSheet (string title, UIActionSheetDelegate del) : this (title, del as IUIActionSheetDelegate, null, null, (string) null) { diff --git a/src/UIKit/UIAlertView.cs b/src/UIKit/UIAlertView.cs index 1ec59a0aeb..e1bddc7b30 100644 --- a/src/UIKit/UIAlertView.cs +++ b/src/UIKit/UIAlertView.cs @@ -16,7 +16,7 @@ using XamCore.Foundation; namespace XamCore.UIKit { public partial class UIAlertView { - public UIAlertView (string title, string message, UIAlertViewDelegate del, string cancelButtonTitle, params string [] otherButtons) + public UIAlertView (string title, string message, IUIAlertViewDelegate del, string cancelButtonTitle, params string [] otherButtons) : this (title, message, del, cancelButtonTitle, otherButtons == null || otherButtons.Length == 0 ? IntPtr.Zero : new NSString (otherButtons [0]).Handle, IntPtr.Zero, IntPtr.Zero) { if (otherButtons == null) @@ -26,6 +26,12 @@ namespace XamCore.UIKit { for (int i = 1; i < otherButtons.Length; i++) AddButton (otherButtons [i]); } + + [Obsolete ("Use overload with a IUIAlertViewDelegate parameter")] + public UIAlertView (string title, string message, UIAlertViewDelegate del, string cancelButtonTitle, params string [] otherButtons) + : this (title, message, (IUIAlertViewDelegate) del, cancelButtonTitle, otherButtons) + { + } } } diff --git a/src/uikit.cs b/src/uikit.cs index dc8f745310..3c831cd547 100644 --- a/src/uikit.cs +++ b/src/uikit.cs @@ -2065,6 +2065,8 @@ namespace XamCore.UIKit { UIAlertAction PreferredAction { get; set; } } + interface IUIAlertViewDelegate {} + [NoTV] [BaseType (typeof (UIView), KeepRefUntil="Dismissed", Delegates=new string [] { "WeakDelegate" }, Events=new Type [] {typeof(UIAlertViewDelegate)})] [Availability (Deprecated = Platform.iOS_9_0, Message = "Use UIAlertController with a UIAlertControllerStyle.Alert type instead")] @@ -2083,7 +2085,7 @@ namespace XamCore.UIKit { // arguments (id, SEL), which means we only need 7 more. And 'mustAlsoBeNull' is that 7th argument. // So on ARM64 the 8th argument ('mustBeNull') is ignored, and iOS sees the 9th argument ('mustAlsoBeNull') as the 8th argument. [Availability (Deprecated=Platform.iOS_8_0, Message="Use UIAlertController instead")] - IntPtr Constructor ([NullAllowed] string title, [NullAllowed] string message, [NullAllowed] UIAlertViewDelegate viewDelegate, [NullAllowed] string cancelButtonTitle, IntPtr otherButtonTitles, IntPtr mustBeNull, IntPtr mustAlsoBeNull); + IntPtr Constructor ([NullAllowed] string title, [NullAllowed] string message, [NullAllowed] IUIAlertViewDelegate viewDelegate, [NullAllowed] string cancelButtonTitle, IntPtr otherButtonTitles, IntPtr mustBeNull, IntPtr mustAlsoBeNull); [Wrap ("WeakDelegate")] [Protocolize] @@ -8781,7 +8783,12 @@ namespace XamCore.UIKit { [NullAllowed] // by default this property is null [Export ("dataSource", ArgumentSemantic.Assign)] +#if XAMCORE_4_0 + IUIPickerViewDataSource DataSource { get; set; } +#else + // should have been WeakDataSource NSObject DataSource { get; set; } +#endif [Export ("delegate", ArgumentSemantic.Assign)][NullAllowed] NSObject WeakDelegate { get; set; } @@ -15931,7 +15938,7 @@ namespace XamCore.UIKit { IUIPreviewInteractionDelegate Delegate { get; set; } [Export ("locationInCoordinateSpace:")] - CGPoint GetLocationInCoordinateSpace ([NullAllowed] UICoordinateSpace coordinateSpace); + CGPoint GetLocationInCoordinateSpace ([NullAllowed] IUICoordinateSpace coordinateSpace); [Export ("cancelInteraction")] void CancelInteraction (); diff --git a/tests/introspection/ApiSignatureTest.cs b/tests/introspection/ApiSignatureTest.cs index 6d44ffb90f..ed3ffaeca6 100644 --- a/tests/introspection/ApiSignatureTest.cs +++ b/tests/introspection/ApiSignatureTest.cs @@ -855,7 +855,7 @@ namespace Introspection { if (t == pt) continue; if (!CheckType (pt, ref n)) - ReportError ($"`{t.Name}.{m.Name}` includes a paramater of type `{pt.Name}` which is a concrete type `[Model]` and not an interface `[Protocol]`"); + ReportError ($"`{t.Name}.{m.Name}` includes a parameter of type `{pt.Name}` which is a concrete type `[Model]` and not an interface `[Protocol]`"); } if (!m.IsConstructor) { var rt = (m as MethodInfo).ReturnType; diff --git a/tests/introspection/iOS/iOSApiSignatureTest.cs b/tests/introspection/iOS/iOSApiSignatureTest.cs index 38805ceb87..2242736ae8 100644 --- a/tests/introspection/iOS/iOSApiSignatureTest.cs +++ b/tests/introspection/iOS/iOSApiSignatureTest.cs @@ -190,6 +190,26 @@ namespace Introspection { if (t.Name == "UICollectionView") return; break; + case "get_SearchResultsSource": + case "set_SearchResultsSource": + // UITableViewSource is our own creation and we did not make an interface out of it + if (t.Name == "UISearchDisplayController") + return; + break; + case "get_ImagePickerControllerDelegate": + case "set_ImagePickerControllerDelegate": + case "get_NavigationControllerDelegate": + case "set_NavigationControllerDelegate": + // fixed in XAMCORE_4_0 - alternative are the Weak* delegates + if (t.Name == "UIImagePickerController") + return; + break; + case "get_Model": + case "set_Model": + // UIPickerViewModel is our own creation and we did not make an interface out of it + if (t.Name == "UIPickerView") + return; + break; } #endif base.CheckManagedMemberSignatures (m, t, ref n);