Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UIKit] Fix a few nullability issues in UIApplication[Delegate]. Fixes #22278. #22285

Merged
merged 4 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/uikit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2362,7 +2362,7 @@ interface UIApplication : UIAccessibility {

[Export ("canOpenURL:")]
[PreSnippet ("if (url is null) return false;", Optimizable = true)] // null not really allowed (but it's a behaviour change with known bug reports)
bool CanOpenUrl ([NullAllowed] NSUrl url);
bool CanOpenUrl (NSUrl url);

[Export ("sendEvent:")]
void SendEvent (UIEvent uievent);
Expand Down Expand Up @@ -2734,7 +2734,7 @@ interface UIApplication : UIAccessibility {
[NoTV]
[MacCatalyst (13, 1)]
[Export ("supportedInterfaceOrientationsForWindow:")]
UIInterfaceOrientationMask SupportedInterfaceOrientationsForWindow ([Transient] UIWindow window);
UIInterfaceOrientationMask SupportedInterfaceOrientationsForWindow ([NullAllowed][Transient] UIWindow window);

[MacCatalyst (13, 1)]
[Field ("UITrackingRunLoopMode")]
Expand All @@ -2756,7 +2756,7 @@ interface UIApplication : UIAccessibility {
[ThreadSafe]
[RequiresSuper]
[Export ("beginBackgroundTaskWithName:expirationHandler:")]
nint BeginBackgroundTask (string taskName, Action expirationHandler);
nint BeginBackgroundTask ([NullAllowed] string taskName, [NullAllowed] Action expirationHandler);

[MacCatalyst (13, 1)]
[Field ("UIApplicationBackgroundFetchIntervalMinimum")]
Expand Down Expand Up @@ -3483,7 +3483,7 @@ interface UIApplicationDelegate {
void FinishedLaunching (UIApplication application);

[Export ("application:didFinishLaunchingWithOptions:")]
bool FinishedLaunching (UIApplication application, NSDictionary launchOptions);
bool FinishedLaunching (UIApplication application, [NullAllowed] NSDictionary launchOptions);

[Export ("applicationDidBecomeActive:")]
void OnActivated (UIApplication application);
Expand Down Expand Up @@ -3592,13 +3592,14 @@ interface UIApplicationDelegate {
// 6.0
//
[Export ("application:willFinishLaunchingWithOptions:")]
bool WillFinishLaunching (UIApplication application, NSDictionary launchOptions);
bool WillFinishLaunching (UIApplication application, [NullAllowed] NSDictionary launchOptions);

[NoTV]
[MacCatalyst (13, 1)]
[Export ("application:supportedInterfaceOrientationsForWindow:")]
UIInterfaceOrientationMask GetSupportedInterfaceOrientations (UIApplication application, [Transient] UIWindow forWindow);
UIInterfaceOrientationMask GetSupportedInterfaceOrientations (UIApplication application, [NullAllowed][Transient] UIWindow forWindow);

[return: NullAllowed]
[Export ("application:viewControllerWithRestorationIdentifierPath:coder:")]
UIViewController GetViewController (UIApplication application, string [] restorationIdentifierComponents, NSCoder coder);

Expand Down Expand Up @@ -3724,7 +3725,7 @@ interface UIApplicationDelegate {

[MacCatalyst (13, 1)]
[Export ("application:handleWatchKitExtensionRequest:reply:")]
void HandleWatchKitExtensionRequest (UIApplication application, NSDictionary userInfo, Action<NSDictionary> reply);
void HandleWatchKitExtensionRequest (UIApplication application, [NullAllowed] NSDictionary userInfo, Action<NSDictionary> reply);

[MacCatalyst (13, 1)]
[Export ("applicationShouldRequestHealthAuthorization:")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@

# Initial result from new rule extra-null-allowed
!extra-null-allowed! 'Foundation.NSIndexPath UIKit.UICollectionViewDataSource::GetIndexPath(UIKit.UICollectionView,System.String,System.IntPtr)' has a extraneous [NullAllowed] on return type
!extra-null-allowed! 'System.Boolean UIKit.UIApplication::CanOpenUrl(Foundation.NSUrl)' has a extraneous [NullAllowed] on parameter #0
!extra-null-allowed! 'System.Void UIKit.UIAccessibilityCustomAction::.ctor(Foundation.NSAttributedString,UIKit.UIAccessibilityCustomActionHandler)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void UIKit.UIAccessibilityCustomAction::.ctor(System.String,UIKit.UIAccessibilityCustomActionHandler)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void UIKit.UIAccessibilityCustomAction::set_Name(System.String)' has a extraneous [NullAllowed] on parameter #0
Expand Down Expand Up @@ -146,8 +145,6 @@
!missing-null-allowed! 'Foundation.NSArray Foundation.NSBundle::LoadNib(System.String,Foundation.NSObject,Foundation.NSDictionary)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'Foundation.NSAttributedString UIKit.UIPickerViewDelegate::GetAttributedTitle(UIKit.UIPickerView,System.IntPtr,System.IntPtr)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'Foundation.NSProgress UIKit.UIDocument::get_Progress()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'System.Boolean UIKit.UIApplicationDelegate::FinishedLaunching(UIKit.UIApplication,Foundation.NSDictionary)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'System.Boolean UIKit.UIApplicationDelegate::WillFinishLaunching(UIKit.UIApplication,Foundation.NSDictionary)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'System.Boolean UIKit.UIManagedDocument::ConfigurePersistentStoreCoordinator(Foundation.NSUrl,System.String,System.String,Foundation.NSDictionary,Foundation.NSError)' is missing an [NullAllowed] on parameter #2
!missing-null-allowed! 'System.Boolean UIKit.UIManagedDocument::ConfigurePersistentStoreCoordinator(Foundation.NSUrl,System.String,System.String,Foundation.NSDictionary,Foundation.NSError)' is missing an [NullAllowed] on parameter #3
!missing-null-allowed! 'System.Boolean UIKit.UIManagedDocument::ConfigurePersistentStoreCoordinator(Foundation.NSUrl,System.String,System.String,Foundation.NSDictionary,Foundation.NSError)' is missing an [NullAllowed] on parameter #4
Expand All @@ -157,13 +154,10 @@
!missing-null-allowed! 'System.Boolean UIKit.UISplitViewControllerDelegate::EventShowDetailViewController(UIKit.UISplitViewController,UIKit.UIViewController,Foundation.NSObject)' is missing an [NullAllowed] on parameter #2
!missing-null-allowed! 'System.Boolean UIKit.UISplitViewControllerDelegate::EventShowViewController(UIKit.UISplitViewController,UIKit.UIViewController,Foundation.NSObject)' is missing an [NullAllowed] on parameter #2
!missing-null-allowed! 'System.Double UIKit.UIViewControllerAnimatedTransitioning::TransitionDuration(UIKit.IUIViewControllerContextTransitioning)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.IntPtr UIKit.UIApplication::BeginBackgroundTask(System.String,System.Action)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.IntPtr UIKit.UIApplication::BeginBackgroundTask(System.String,System.Action)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'System.Void Foundation.NSObject::set_AccessibilityAttributedUserInputLabels(Foundation.NSAttributedString[])' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void Foundation.NSObject::set_AccessibilityUserInputLabels(System.String[])' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void UIKit.UIAccessibilityCustomAction::.ctor(System.String,Foundation.NSObject,ObjCRuntime.Selector)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'System.Void UIKit.UIAlertController::AddTextField(System.Action`1<UIKit.UITextField>)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void UIKit.UIApplicationDelegate::HandleWatchKitExtensionRequest(UIKit.UIApplication,Foundation.NSDictionary,System.Action`1<Foundation.NSDictionary>)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'System.Void UIKit.UICollectionViewController::set_CollectionView(UIKit.UICollectionView)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void UIKit.UIControl::EndTracking(UIKit.UITouch,UIKit.UIEvent)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void UIKit.UIDocument::set_FileModificationDate(Foundation.NSDate)' is missing an [NullAllowed] on parameter #0
Expand Down Expand Up @@ -282,8 +276,6 @@
!missing-null-allowed! 'UIKit.UIImageView UIKit.UIButton::get_ImageView()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIInputViewController UIKit.UIResponder::get_InputAccessoryViewController()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIInputViewController UIKit.UIResponder::get_InputViewController()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIInterfaceOrientationMask UIKit.UIApplication::SupportedInterfaceOrientationsForWindow(UIKit.UIWindow)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'UIKit.UIInterfaceOrientationMask UIKit.UIApplicationDelegate::GetSupportedInterfaceOrientations(UIKit.UIApplication,UIKit.UIWindow)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'UIKit.UIKeyCommand[] UIKit.UIResponder::get_KeyCommands()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UILabel UIKit.UIButton::get_TitleLabel()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UINavigationItem UIKit.UINavigationBar::get_BackItem()' is missing an [NullAllowed] on return type
Expand Down Expand Up @@ -319,7 +311,6 @@
!missing-null-allowed! 'UIKit.UIView UIKit.UIViewControllerContextTransitioning::GetViewFor(Foundation.NSString)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIViewController UIKit.UIActivity::get_ViewController()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIViewController UIKit.UIAdaptivePresentationControllerDelegate::GetViewControllerForAdaptivePresentation(UIKit.UIPresentationController,UIKit.UIModalPresentationStyle)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIViewController UIKit.UIApplicationDelegate::GetViewController(UIKit.UIApplication,System.String[],Foundation.NSCoder)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIViewController UIKit.UINavigationController::get_TopViewController()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIViewController UIKit.UINavigationController::get_VisibleViewController()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIViewController UIKit.UINavigationController::PopViewController(System.Boolean)' is missing an [NullAllowed] on return type
Expand Down
9 changes: 0 additions & 9 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-UIKit.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@

# Initial result from new rule extra-null-allowed
!extra-null-allowed! 'Foundation.NSIndexPath UIKit.UICollectionViewDataSource::GetIndexPath(UIKit.UICollectionView,System.String,System.IntPtr)' has a extraneous [NullAllowed] on return type
!extra-null-allowed! 'System.Boolean UIKit.UIApplication::CanOpenUrl(Foundation.NSUrl)' has a extraneous [NullAllowed] on parameter #0
!extra-null-allowed! 'System.Void UIKit.UIAccessibilityCustomAction::.ctor(Foundation.NSAttributedString,UIKit.UIAccessibilityCustomActionHandler)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void UIKit.UIAccessibilityCustomAction::.ctor(System.String,UIKit.UIAccessibilityCustomActionHandler)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void UIKit.UIAccessibilityCustomAction::set_Name(System.String)' has a extraneous [NullAllowed] on parameter #0
Expand Down Expand Up @@ -150,8 +149,6 @@
!missing-null-allowed! 'Foundation.NSArray Foundation.NSBundle::LoadNib(System.String,Foundation.NSObject,Foundation.NSDictionary)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'Foundation.NSAttributedString UIKit.UIPickerViewDelegate::GetAttributedTitle(UIKit.UIPickerView,System.IntPtr,System.IntPtr)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'Foundation.NSProgress UIKit.UIDocument::get_Progress()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'System.Boolean UIKit.UIApplicationDelegate::FinishedLaunching(UIKit.UIApplication,Foundation.NSDictionary)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'System.Boolean UIKit.UIApplicationDelegate::WillFinishLaunching(UIKit.UIApplication,Foundation.NSDictionary)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'System.Boolean UIKit.UIManagedDocument::ConfigurePersistentStoreCoordinator(Foundation.NSUrl,System.String,System.String,Foundation.NSDictionary,Foundation.NSError)' is missing an [NullAllowed] on parameter #2
!missing-null-allowed! 'System.Boolean UIKit.UIManagedDocument::ConfigurePersistentStoreCoordinator(Foundation.NSUrl,System.String,System.String,Foundation.NSDictionary,Foundation.NSError)' is missing an [NullAllowed] on parameter #3
!missing-null-allowed! 'System.Boolean UIKit.UIManagedDocument::ConfigurePersistentStoreCoordinator(Foundation.NSUrl,System.String,System.String,Foundation.NSDictionary,Foundation.NSError)' is missing an [NullAllowed] on parameter #4
Expand All @@ -161,13 +158,10 @@
!missing-null-allowed! 'System.Boolean UIKit.UISplitViewControllerDelegate::EventShowDetailViewController(UIKit.UISplitViewController,UIKit.UIViewController,Foundation.NSObject)' is missing an [NullAllowed] on parameter #2
!missing-null-allowed! 'System.Boolean UIKit.UISplitViewControllerDelegate::EventShowViewController(UIKit.UISplitViewController,UIKit.UIViewController,Foundation.NSObject)' is missing an [NullAllowed] on parameter #2
!missing-null-allowed! 'System.Double UIKit.UIViewControllerAnimatedTransitioning::TransitionDuration(UIKit.IUIViewControllerContextTransitioning)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.IntPtr UIKit.UIApplication::BeginBackgroundTask(System.String,System.Action)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.IntPtr UIKit.UIApplication::BeginBackgroundTask(System.String,System.Action)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'System.Void Foundation.NSObject::set_AccessibilityAttributedUserInputLabels(Foundation.NSAttributedString[])' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void Foundation.NSObject::set_AccessibilityUserInputLabels(System.String[])' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void UIKit.UIAccessibilityCustomAction::.ctor(System.String,Foundation.NSObject,ObjCRuntime.Selector)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'System.Void UIKit.UIAlertController::AddTextField(System.Action`1<UIKit.UITextField>)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void UIKit.UIApplicationDelegate::HandleWatchKitExtensionRequest(UIKit.UIApplication,Foundation.NSDictionary,System.Action`1<Foundation.NSDictionary>)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'System.Void UIKit.UICollectionViewController::set_CollectionView(UIKit.UICollectionView)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void UIKit.UIControl::EndTracking(UIKit.UITouch,UIKit.UIEvent)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void UIKit.UIDocument::set_FileModificationDate(Foundation.NSDate)' is missing an [NullAllowed] on parameter #0
Expand Down Expand Up @@ -286,8 +280,6 @@
!missing-null-allowed! 'UIKit.UIImageView UIKit.UIButton::get_ImageView()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIInputViewController UIKit.UIResponder::get_InputAccessoryViewController()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIInputViewController UIKit.UIResponder::get_InputViewController()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIInterfaceOrientationMask UIKit.UIApplication::SupportedInterfaceOrientationsForWindow(UIKit.UIWindow)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'UIKit.UIInterfaceOrientationMask UIKit.UIApplicationDelegate::GetSupportedInterfaceOrientations(UIKit.UIApplication,UIKit.UIWindow)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'UIKit.UIKeyCommand[] UIKit.UIResponder::get_KeyCommands()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UILabel UIKit.UIButton::get_TitleLabel()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UINavigationItem UIKit.UINavigationBar::get_BackItem()' is missing an [NullAllowed] on return type
Expand Down Expand Up @@ -323,7 +315,6 @@
!missing-null-allowed! 'UIKit.UIView UIKit.UIViewControllerContextTransitioning::GetViewFor(Foundation.NSString)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIViewController UIKit.UIActivity::get_ViewController()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIViewController UIKit.UIAdaptivePresentationControllerDelegate::GetViewControllerForAdaptivePresentation(UIKit.UIPresentationController,UIKit.UIModalPresentationStyle)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIViewController UIKit.UIApplicationDelegate::GetViewController(UIKit.UIApplication,System.String[],Foundation.NSCoder)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIViewController UIKit.UINavigationController::get_TopViewController()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIViewController UIKit.UINavigationController::get_VisibleViewController()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'UIKit.UIViewController UIKit.UINavigationController::PopViewController(System.Boolean)' is missing an [NullAllowed] on return type
Expand Down
Loading
Loading