From 1d3c9f4a0497be602f00ff9ad56ded3216a299f0 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 9 Sep 2020 08:49:08 +0200 Subject: [PATCH] [UIKit] Sprinkle NullAllowed on UIImage according to Apple's headers. Fixes #9597. (#9598) Fixes https://github.com/xamarin/xamarin-macios/issues/9597. --- src/uikit.cs | 13 +++++++++++++ tests/xtro-sharpie/iOS-UIKit.ignore | 13 ------------- tests/xtro-sharpie/tvOS-UIKit.ignore | 13 ------------- tests/xtro-sharpie/watchOS-UIKit.ignore | 10 ---------- 4 files changed, 13 insertions(+), 36 deletions(-) diff --git a/src/uikit.cs b/src/uikit.cs index 5f9714a19d..3a37fcee5b 100644 --- a/src/uikit.cs +++ b/src/uikit.cs @@ -7144,6 +7144,7 @@ namespace UIKit { #endif [ThreadSafe] [Static] [Export ("imageNamed:")][Autorelease] + [return: NullAllowed] UIImage FromBundle (string name); #if !WATCH @@ -7155,15 +7156,18 @@ namespace UIKit { [ThreadSafe] [iOS (8,0)] [Static, Export ("imageNamed:inBundle:compatibleWithTraitCollection:")] + [return: NullAllowed] UIImage FromBundle (string name, [NullAllowed] NSBundle bundle, [NullAllowed] UITraitCollection traitCollection); #endif // !WATCH [Static] [Export ("imageWithContentsOfFile:")][Autorelease] [ThreadSafe] + [return: NullAllowed] UIImage FromFile (string filename); [Static] [Export ("imageWithData:")][Autorelease] [ThreadSafe] + [return: NullAllowed] UIImage LoadFromData (NSData data); [Static] [Export ("imageWithCGImage:")][Autorelease] @@ -7259,14 +7263,17 @@ namespace UIKit { [Static, Export ("animatedImageNamed:duration:")][Autorelease] [ThreadSafe] + [return: NullAllowed] UIImage CreateAnimatedImage (string name, double duration); [Static, Export ("animatedImageWithImages:duration:")][Autorelease] [ThreadSafe] + [return: NullAllowed] UIImage CreateAnimatedImage (UIImage [] images, double duration); [Static, Export ("animatedResizableImageNamed:capInsets:duration:")][Autorelease] [ThreadSafe] + [return: NullAllowed] UIImage CreateAnimatedImage (string name, UIEdgeInsets capInsets, double duration); [Export ("initWithCGImage:")] @@ -7286,11 +7293,13 @@ namespace UIKit { #if !WATCH [Export ("CIImage")] [ThreadSafe] + [NullAllowed] CIImage CIImage { get; } #endif // !WATCH [Export ("images")] [ThreadSafe] + [NullAllowed] UIImage [] Images { get; } [Export ("duration")] @@ -7315,6 +7324,7 @@ namespace UIKit { [Static] [Export ("imageWithData:scale:")] [ThreadSafe, Autorelease] + [return: NullAllowed] UIImage LoadFromData (NSData data, nfloat scale); #if !WATCH @@ -7341,6 +7351,7 @@ namespace UIKit { [Static] [Export ("animatedResizableImageNamed:capInsets:resizingMode:duration:")] [ThreadSafe] + [return: NullAllowed] UIImage CreateAnimatedImage (string name, UIEdgeInsets capInsets, UIImageResizingMode resizingMode, double duration); [Export ("imageWithAlignmentRectInsets:")] @@ -7360,6 +7371,7 @@ namespace UIKit { [iOS (8,0)] [Export ("imageAsset")] [ThreadSafe] + [NullAllowed] UIImageAsset ImageAsset { get; } #endif // !WATCH @@ -7440,6 +7452,7 @@ namespace UIKit { [Watch (6,0), TV (13,0), iOS (13,0)] [Export ("configuration", ArgumentSemantic.Copy)] + [NullAllowed] UIImageConfiguration Configuration { get; } [Watch (6,0), TV (13,0), iOS (13,0)] diff --git a/tests/xtro-sharpie/iOS-UIKit.ignore b/tests/xtro-sharpie/iOS-UIKit.ignore index 4f6c9107fb..89e75178f4 100644 --- a/tests/xtro-sharpie/iOS-UIKit.ignore +++ b/tests/xtro-sharpie/iOS-UIKit.ignore @@ -136,7 +136,6 @@ # Initial result from new rule missing-null-allowed !missing-null-allowed! 'CoreAnimation.CADisplayLink UIKit.UIScreen::CreateDisplayLink(Foundation.NSObject,ObjCRuntime.Selector)' is missing an [NullAllowed] on return type !missing-null-allowed! 'CoreGraphics.CGRect UIKit.NSTextAttachmentContainer::GetAttachmentBounds(UIKit.NSTextContainer,CoreGraphics.CGRect,CoreGraphics.CGPoint,System.nuint)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'CoreImage.CIImage UIKit.UIImage::get_CIImage()' is missing an [NullAllowed] on return type !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.NSArray[] UIKit.UIPasteboard::PasteBoardTypesForSet(Foundation.NSIndexSet)' is missing an [NullAllowed] on parameter #0 !missing-null-allowed! 'Foundation.NSArray[] UIKit.UIPasteboard::PasteBoardTypesForSet(Foundation.NSIndexSet)' is missing an [NullAllowed] on return type @@ -388,15 +387,6 @@ !missing-null-allowed! 'UIKit.UIImage UIKit.UIButton::get_CurrentBackgroundImage()' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UIButton::get_CurrentImage()' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UIButton::ImageForState(UIKit.UIControlState)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::CreateAnimatedImage(System.String,System.Double)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::CreateAnimatedImage(System.String,UIKit.UIEdgeInsets,System.Double)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::CreateAnimatedImage(System.String,UIKit.UIEdgeInsets,UIKit.UIImageResizingMode,System.Double)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::CreateAnimatedImage(UIKit.UIImage[],System.Double)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::FromBundle(System.String)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::FromBundle(System.String,Foundation.NSBundle,UIKit.UITraitCollection)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::FromFile(System.String)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::LoadFromData(Foundation.NSData)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::LoadFromData(Foundation.NSData,System.nfloat)' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UINavigationBar::GetBackgroundImage(UIKit.UIBarMetrics)' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UINavigationBar::GetBackgroundImage(UIKit.UIBarPosition,UIKit.UIBarMetrics)' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UISearchBar::BackgroundImageForBarPosition(UIKit.UIBarPosition,UIKit.UIBarMetrics)' is missing an [NullAllowed] on return type @@ -421,9 +411,6 @@ !missing-null-allowed! 'UIKit.UIImage UIKit.UITabBarItem::get_FinishedUnselectedImage()' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UIToolbar::GetBackgroundImage(UIKit.UIToolbarPosition,UIKit.UIBarMetrics)' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UIToolbar::GetShadowImage(UIKit.UIToolbarPosition)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage[] UIKit.UIImage::get_Images()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImageAsset UIKit.UIImage::get_ImageAsset()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImageConfiguration UIKit.UIImage::get_Configuration()' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImageView UIKit.UIButton::get_ImageView()' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImageView UIKit.UITableViewCell::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 diff --git a/tests/xtro-sharpie/tvOS-UIKit.ignore b/tests/xtro-sharpie/tvOS-UIKit.ignore index 8a38a11517..4890628df2 100644 --- a/tests/xtro-sharpie/tvOS-UIKit.ignore +++ b/tests/xtro-sharpie/tvOS-UIKit.ignore @@ -146,7 +146,6 @@ # Initial result from new rule missing-null-allowed !missing-null-allowed! 'CoreAnimation.CADisplayLink UIKit.UIScreen::CreateDisplayLink(Foundation.NSObject,ObjCRuntime.Selector)' is missing an [NullAllowed] on return type !missing-null-allowed! 'CoreGraphics.CGRect UIKit.NSTextAttachmentContainer::GetAttachmentBounds(UIKit.NSTextContainer,CoreGraphics.CGRect,CoreGraphics.CGPoint,System.nuint)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'CoreImage.CIImage UIKit.UIImage::get_CIImage()' is missing an [NullAllowed] on return type !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.UIButton::get_CurrentAttributedTitle()' is missing an [NullAllowed] on return type !missing-null-allowed! 'Foundation.NSAttributedString UIKit.UIButton::GetAttributedTitle(UIKit.UIControlState)' is missing an [NullAllowed] on return type @@ -320,15 +319,6 @@ !missing-null-allowed! 'UIKit.UIImage UIKit.UIButton::get_CurrentBackgroundImage()' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UIButton::get_CurrentImage()' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UIButton::ImageForState(UIKit.UIControlState)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::CreateAnimatedImage(System.String,System.Double)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::CreateAnimatedImage(System.String,UIKit.UIEdgeInsets,System.Double)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::CreateAnimatedImage(System.String,UIKit.UIEdgeInsets,UIKit.UIImageResizingMode,System.Double)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::CreateAnimatedImage(UIKit.UIImage[],System.Double)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::FromBundle(System.String)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::FromBundle(System.String,Foundation.NSBundle,UIKit.UITraitCollection)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::FromFile(System.String)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::LoadFromData(Foundation.NSData)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::LoadFromData(Foundation.NSData,System.nfloat)' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UINavigationBar::GetBackgroundImage(UIKit.UIBarMetrics)' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UINavigationBar::GetBackgroundImage(UIKit.UIBarPosition,UIKit.UIBarMetrics)' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UISearchBar::BackgroundImageForBarPosition(UIKit.UIBarPosition,UIKit.UIBarMetrics)' is missing an [NullAllowed] on return type @@ -339,9 +329,6 @@ !missing-null-allowed! 'UIKit.UIImage UIKit.UISegmentedControl::DividerImageForLeftSegmentStaterightSegmentStatebarMetrics(UIKit.UIControlState,UIKit.UIControlState,UIKit.UIBarMetrics)' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UISegmentedControl::GetBackgroundImage(UIKit.UIControlState,UIKit.UIBarMetrics)' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImage UIKit.UISegmentedControl::ImageAt(System.nint)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage[] UIKit.UIImage::get_Images()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImageAsset UIKit.UIImage::get_ImageAsset()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImageConfiguration UIKit.UIImage::get_Configuration()' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImageView UIKit.UIButton::get_ImageView()' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIImageView UIKit.UITableViewCell::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 diff --git a/tests/xtro-sharpie/watchOS-UIKit.ignore b/tests/xtro-sharpie/watchOS-UIKit.ignore index fb5ccc6108..f8508cb84d 100644 --- a/tests/xtro-sharpie/watchOS-UIKit.ignore +++ b/tests/xtro-sharpie/watchOS-UIKit.ignore @@ -50,13 +50,3 @@ !missing-null-allowed! 'Foundation.NSFileWrapper Foundation.NSAttributedString::GetFileWrapperFromRange(Foundation.NSRange,Foundation.NSDictionary,Foundation.NSError&)' is missing an [NullAllowed] on return type !missing-null-allowed! 'Foundation.NSObject UIKit.UIFontDescriptor::GetObject(Foundation.NSString)' is missing an [NullAllowed] on return type !missing-null-allowed! 'UIKit.UIFontDescriptor UIKit.UIFontDescriptor::CreateWithTraits(UIKit.UIFontDescriptorSymbolicTraits)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::CreateAnimatedImage(System.String,System.Double)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::CreateAnimatedImage(System.String,UIKit.UIEdgeInsets,System.Double)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::CreateAnimatedImage(System.String,UIKit.UIEdgeInsets,UIKit.UIImageResizingMode,System.Double)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::CreateAnimatedImage(UIKit.UIImage[],System.Double)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::FromBundle(System.String)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::FromFile(System.String)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::LoadFromData(Foundation.NSData)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage UIKit.UIImage::LoadFromData(Foundation.NSData,System.nfloat)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImage[] UIKit.UIImage::get_Images()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'UIKit.UIImageConfiguration UIKit.UIImage::get_Configuration()' is missing an [NullAllowed] on return type