Skip to content

Commit

Permalink
[AppKit] Fix nullability for numerous NSView members. Fixes #21598.
Browse files Browse the repository at this point in the history
Fixes #21598.
  • Loading branch information
snechaev authored and rolfbjarne committed Nov 13, 2024
1 parent 377f0f0 commit 768c9e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 33 deletions.
34 changes: 25 additions & 9 deletions src/appkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16090,18 +16090,22 @@ partial interface NSView : NSDraggingDestination, NSAnimatablePropertyContainer,
[Export ("initWithFrame:")]
NativeHandle Constructor (CGRect frameRect);

[NullAllowed]
[Export ("window")]
NSWindow Window { get; }

[NullAllowed]
[Export ("superview")]
NSView Superview { get; }

[Export ("isDescendantOf:")]
bool IsDescendantOf (NSView aView);

[return: NullAllowed]
[Export ("ancestorSharedWithView:")]
NSView AncestorSharedWithView (NSView aView);

[NullAllowed]
[Export ("opaqueAncestor")]
NSView OpaqueAncestor { get; }

Expand Down Expand Up @@ -16142,10 +16146,10 @@ partial interface NSView : NSDraggingDestination, NSAnimatablePropertyContainer,
void ViewDidMoveToSuperview ();

[Export ("didAddSubview:")]
void DidAddSubview ([NullAllowed] NSView subview);
void DidAddSubview (NSView subview);

[Export ("willRemoveSubview:")]
void WillRemoveSubview ([NullAllowed] NSView subview);
void WillRemoveSubview (NSView subview);

[Export ("removeFromSuperview")]
void RemoveFromSuperview ();
Expand Down Expand Up @@ -16304,6 +16308,7 @@ partial interface NSView : NSDraggingDestination, NSAnimatablePropertyContainer,
[Export ("displayRectIgnoringOpacity:inContext:")]
void DisplayRectIgnoringOpacity (CGRect aRect, NSGraphicsContext context);

[return: NullAllowed]
[Export ("bitmapImageRepForCachingDisplayInRect:")]
NSBitmapImageRep BitmapImageRepForCachingDisplayInRect (CGRect rect);

Expand Down Expand Up @@ -16352,12 +16357,14 @@ partial interface NSView : NSDraggingDestination, NSAnimatablePropertyContainer,
[Export ("translateRectsNeedingDisplayInRect:by:")]
void TranslateRectsNeedingDisplay (CGRect clipRect, CGSize delta);

[return: NullAllowed]
[Export ("hitTest:")]
NSView HitTest (CGPoint aPoint);

[Export ("mouse:inRect:")]
bool IsMouseInRect (CGPoint aPoint, CGRect aRect);

[return: NullAllowed]
[Export ("viewWithTag:")]
NSObject ViewWithTag (nint aTag);

Expand All @@ -16368,7 +16375,7 @@ partial interface NSView : NSDraggingDestination, NSAnimatablePropertyContainer,
bool PerformKeyEquivalent (NSEvent theEvent);

[Export ("acceptsFirstMouse:")]
bool AcceptsFirstMouse (NSEvent theEvent);
bool AcceptsFirstMouse ([NullAllowed] NSEvent theEvent);

[Export ("shouldDelayWindowOrderingForEvent:")]
bool ShouldDelayWindowOrderingForEvent (NSEvent theEvent);
Expand Down Expand Up @@ -16416,12 +16423,15 @@ partial interface NSView : NSDraggingDestination, NSAnimatablePropertyContainer,
[Export ("shouldDrawColor")]
bool ShouldDrawColor { get; }

[NullAllowed]
[Export ("enclosingScrollView")]
NSScrollView EnclosingScrollView { get; }

[return: NullAllowed]
[Export ("menuForEvent:")]
NSMenu MenuForEvent (NSEvent theEvent);

[return: NullAllowed]
[Static]
[Export ("defaultMenu")]
NSMenu DefaultMenu ();
Expand Down Expand Up @@ -16473,6 +16483,7 @@ partial interface NSView : NSDraggingDestination, NSAnimatablePropertyContainer,
//[Export ("getRectsExposedDuringLiveResize:count:")]
// void GetRectsExposedDuringLiveResizecount

[NullAllowed]
[Export ("inputContext")]
NSTextInputContext InputContext { get; }

Expand Down Expand Up @@ -16535,15 +16546,16 @@ partial interface NSView : NSDraggingDestination, NSAnimatablePropertyContainer,
[Export ("alphaValue")]
nfloat AlphaValue { get; set; }

[Export ("backgroundFilters", ArgumentSemantic.Copy), NullAllowed]
[Export ("backgroundFilters", ArgumentSemantic.Copy)]
CIFilter [] BackgroundFilters { get; set; }

[Export ("compositingFilter", ArgumentSemantic.Retain), NullAllowed]
[Export ("compositingFilter", ArgumentSemantic.Retain)]
CIFilter CompositingFilter { get; set; }

[Export ("contentFilters", ArgumentSemantic.Copy), NullAllowed]
[Export ("contentFilters", ArgumentSemantic.Copy)]
CIFilter [] ContentFilters { get; set; }

[NullAllowed]
[Export ("shadow", ArgumentSemantic.Copy)]
NSShadow Shadow { get; set; }

Expand Down Expand Up @@ -16578,10 +16590,10 @@ partial interface NSView : NSDraggingDestination, NSAnimatablePropertyContainer,
bool DragPromisedFilesOfTypes (string [] typeArray, CGRect aRect, NSObject sourceObject, bool slideBack, NSEvent theEvent);

[Export ("exitFullScreenModeWithOptions:")]
void ExitFullscreenModeWithOptions (NSDictionary options);
void ExitFullscreenModeWithOptions ([NullAllowed] NSDictionary options);

[Export ("enterFullScreenMode:withOptions:")]
bool EnterFullscreenModeWithOptions (NSScreen screen, NSDictionary options);
bool EnterFullscreenModeWithOptions (NSScreen screen, [NullAllowed] NSDictionary options);

[Export ("isInFullScreenMode")]
bool IsInFullscreenMode { get; }
Expand Down Expand Up @@ -16708,12 +16720,15 @@ partial interface NSView : NSDraggingDestination, NSAnimatablePropertyContainer,
[Export ("nextKeyView")]
NSView NextKeyView { get; set; }

[NullAllowed]
[Export ("previousKeyView")]
NSView PreviousKeyView { get; }

[NullAllowed]
[Export ("nextValidKeyView")]
NSView NextValidKeyView { get; }

[NullAllowed]
[Export ("previousValidKeyView")]
NSView PreviousValidKeyView { get; }

Expand Down Expand Up @@ -16748,7 +16763,7 @@ partial interface NSView : NSDraggingDestination, NSAnimatablePropertyContainer,
NSData DataWithPdfInsideRect (CGRect rect);

[Export ("print:")]
void Print (NSObject sender);
void Print ([NullAllowed] NSObject sender);

[Export ("printJobTitle")]
string PrintJobTitle { get; }
Expand Down Expand Up @@ -16884,6 +16899,7 @@ partial interface NSView : NSDraggingDestination, NSAnimatablePropertyContainer,
[Export ("preparedContentRect")]
CGRect PreparedContentRect { get; set; }

[NullAllowed]
[Export ("pressureConfiguration", ArgumentSemantic.Strong)]
NSPressureConfiguration PressureConfiguration { get; set; }

Expand Down
24 changes: 0 additions & 24 deletions tests/xtro-sharpie/api-annotations-dotnet/macOS-AppKit.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,6 @@
!extra-null-allowed! 'System.Void AppKit.NSTypesetter::WillSetLineFragment(CoreGraphics.CGRect&,Foundation.NSRange,CoreGraphics.CGRect&,System.Runtime.InteropServices.NFloat&)' has a extraneous [NullAllowed] on parameter #0
!extra-null-allowed! 'System.Void AppKit.NSView::AdjustPageHeightNew(System.Runtime.InteropServices.NFloat&,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat)' has a extraneous [NullAllowed] on parameter #0
!extra-null-allowed! 'System.Void AppKit.NSView::AdjustPageWidthNew(System.Runtime.InteropServices.NFloat&,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat)' has a extraneous [NullAllowed] on parameter #0
!extra-null-allowed! 'System.Void AppKit.NSView::DidAddSubview(AppKit.NSView)' has a extraneous [NullAllowed] on parameter #0
!extra-null-allowed! 'System.Void AppKit.NSView::set_BackgroundFilters(CoreImage.CIFilter[])' has a extraneous [NullAllowed] on parameter #0
!extra-null-allowed! 'System.Void AppKit.NSView::set_ContentFilters(CoreImage.CIFilter[])' has a extraneous [NullAllowed] on parameter #0
!extra-null-allowed! 'System.Void AppKit.NSView::WillRemoveSubview(AppKit.NSView)' has a extraneous [NullAllowed] on parameter #0
!extra-null-allowed! 'System.Void Foundation.NSAttributedString::.ctor(Foundation.NSData,Foundation.NSDictionary,Foundation.NSDictionary&)' has a extraneous [NullAllowed] on parameter #1

# Initial result from new rule missing-null-allowed
Expand All @@ -244,7 +240,6 @@
!missing-null-allowed! 'AppKit.NSAppearance AppKit.NSAppearance::GetAppearance(Foundation.NSString)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSBitmapImageRep AppKit.NSBitmapImageRep::ConvertingToColorSpace(AppKit.NSColorSpace,AppKit.NSColorRenderingIntent)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSBitmapImageRep AppKit.NSBitmapImageRep::RetaggedWithColorSpace(AppKit.NSColorSpace)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSBitmapImageRep AppKit.NSView::BitmapImageRepForCachingDisplayInRect(CoreGraphics.CGRect)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSButton AppKit.NSAlert::get_SuppressionButton()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSButton AppKit.NSWindow::StandardWindowButton(AppKit.NSWindowButton)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSButton AppKit.NSWindow::StandardWindowButton(AppKit.NSWindowButton,AppKit.NSWindowStyle)' is missing an [NullAllowed] on return type
Expand Down Expand Up @@ -347,8 +342,6 @@
!missing-null-allowed! 'AppKit.NSMenu AppKit.NSTextViewDelegate::MenuForEvent(AppKit.NSTextView,AppKit.NSMenu,AppKit.NSEvent,System.UIntPtr)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSMenu AppKit.NSTokenFieldCellDelegate::GetMenu(AppKit.NSTokenFieldCell,Foundation.NSObject)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSMenu AppKit.NSTokenFieldDelegate::GetMenu(AppKit.NSTokenField,Foundation.NSObject)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSMenu AppKit.NSView::DefaultMenu()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSMenu AppKit.NSView::MenuForEvent(AppKit.NSEvent)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSMenuItem AppKit.NSMenuItem::get_ParentItem()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSMenuItem AppKit.NSPopUpButton::get_LastItem()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSMenuItem AppKit.NSPopUpButton::get_SelectedItem()' is missing an [NullAllowed] on return type
Expand Down Expand Up @@ -379,7 +372,6 @@
!missing-null-allowed! 'AppKit.NSScreen AppKit.NSScreen::get_MainScreen()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSScreen AppKit.NSWindow::get_DeepestScreen()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSScreen AppKit.NSWindow::get_Screen()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSScrollView AppKit.NSView::get_EnclosingScrollView()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSScrubberItemView AppKit.NSScrubber::GetItemViewForItem(System.IntPtr)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSScrubberItemView AppKit.NSScrubber::MakeItem(System.String,Foundation.NSObject)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSScrubberLayoutAttributes AppKit.NSScrubberLayout::LayoutAttributesForItem(System.IntPtr)' is missing an [NullAllowed] on return type
Expand All @@ -405,7 +397,6 @@
!missing-null-allowed! 'AppKit.NSTextContainer AppKit.NSTypesetter::get_CurrentTextContainer()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSTextContainer[] AppKit.NSTypesetter::get_TextContainers()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSTextInputContext AppKit.NSTextInputContext::get_CurrentInputContext()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSTextInputContext AppKit.NSView::get_InputContext()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSTextStorage AppKit.NSTextView::get_TextStorage()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSTextTab AppKit.NSTypesetter::GetTextTab(System.Runtime.InteropServices.NFloat,Foundation.NSWritingDirection,System.Runtime.InteropServices.NFloat)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSTextView AppKit.NSCell::FieldEditorForView(AppKit.NSView)' is missing an [NullAllowed] on return type
Expand All @@ -424,13 +415,6 @@
!missing-null-allowed! 'AppKit.NSView AppKit.NSTableViewDelegate::GetViewForItem(AppKit.NSTableView,AppKit.NSTableColumn,System.IntPtr)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'AppKit.NSView AppKit.NSTableViewDelegate::GetViewForItem(AppKit.NSTableView,AppKit.NSTableColumn,System.IntPtr)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSView AppKit.NSTextFinderBarContainer::get_ContentView()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSView AppKit.NSView::AncestorSharedWithView(AppKit.NSView)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSView AppKit.NSView::get_NextValidKeyView()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSView AppKit.NSView::get_OpaqueAncestor()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSView AppKit.NSView::get_PreviousKeyView()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSView AppKit.NSView::get_PreviousValidKeyView()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSView AppKit.NSView::get_Superview()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSView AppKit.NSView::HitTest(CoreGraphics.CGPoint)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSViewController AppKit.NSBrowserDelegate::HeaderViewControllerForItem(AppKit.NSBrowser,Foundation.NSObject)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'AppKit.NSViewController AppKit.NSBrowserDelegate::HeaderViewControllerForItem(AppKit.NSBrowser,Foundation.NSObject)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSViewController AppKit.NSBrowserDelegate::PreviewViewControllerForLeafItem(AppKit.NSBrowser,Foundation.NSObject)' is missing an [NullAllowed] on return type
Expand All @@ -446,7 +430,6 @@
!missing-null-allowed! 'AppKit.NSWindow AppKit.NSEvent::get_Window()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSWindow AppKit.NSPopoverDelegate::GetDetachableWindowForPopover(AppKit.NSPopover)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSWindow AppKit.NSSharingServiceDelegate::SourceWindowForShareItems(AppKit.NSSharingService,Foundation.NSObject[],AppKit.NSSharingContentScope)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSWindow AppKit.NSView::get_Window()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSWindow AppKit.NSWindow::get_AttachedSheet()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSWindow AppKit.NSWindow::get_SheetParent()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'AppKit.NSWindow[] AppKit.NSWindow::get_ChildWindows()' is missing an [NullAllowed] on return type
Expand Down Expand Up @@ -547,7 +530,6 @@
!missing-null-allowed! 'Foundation.NSObject AppKit.NSTouch::get_Device()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'Foundation.NSObject AppKit.NSTrackingArea::get_Owner()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'Foundation.NSObject AppKit.NSTreeNode::get_RepresentedObject()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'Foundation.NSObject AppKit.NSView::ViewWithTag(System.IntPtr)' is missing an [NullAllowed] on return type
!missing-null-allowed! 'Foundation.NSObject AppKit.NSWindow::get_ContentLayoutGuide()' is missing an [NullAllowed] on return type
!missing-null-allowed! 'Foundation.NSObject AppKit.NSWindow::ValidRequestorForSendType(System.String,System.String)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'Foundation.NSObject AppKit.NSWindow::ValidRequestorForSendType(System.String,System.String)' is missing an [NullAllowed] on parameter #1
Expand Down Expand Up @@ -606,8 +588,6 @@
!missing-null-allowed! 'System.Boolean AppKit.NSTextView::ShouldChangeText(Foundation.NSArray,System.String[])' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'System.Boolean AppKit.NSTextViewDelegate::ShouldChangeTextInRanges(AppKit.NSTextView,Foundation.NSValue[],System.String[])' is missing an [NullAllowed] on parameter #2
!missing-null-allowed! 'System.Boolean AppKit.NSTreeController::SetSelectionIndexPath(Foundation.NSIndexPath)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Boolean AppKit.NSView::AcceptsFirstMouse(AppKit.NSEvent)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Boolean AppKit.NSView::EnterFullscreenModeWithOptions(AppKit.NSScreen,Foundation.NSDictionary)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'System.Boolean AppKit.NSWindow::TryToPerform(ObjCRuntime.Selector,Foundation.NSObject)' is missing an [NullAllowed] on parameter #1
!missing-null-allowed! 'System.Boolean AppKit.NSWorkspace::SelectFile(System.String,System.String)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Boolean AppKit.NSWorkspace::SetDesktopImageUrl(Foundation.NSUrl,AppKit.NSScreen,Foundation.NSDictionary,Foundation.NSError)' is missing an [NullAllowed] on parameter #3
Expand Down Expand Up @@ -1036,10 +1016,6 @@
!missing-null-allowed! 'System.Void AppKit.NSUserDefaultsController::RevertToInitialValues(Foundation.NSObject)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void AppKit.NSUserDefaultsController::Save(Foundation.NSObject)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void AppKit.NSUserDefaultsController::set_InitialValues(Foundation.NSDictionary)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void AppKit.NSView::ExitFullscreenModeWithOptions(Foundation.NSDictionary)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void AppKit.NSView::Print(Foundation.NSObject)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void AppKit.NSView::set_PressureConfiguration(AppKit.NSPressureConfiguration)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void AppKit.NSView::set_Shadow(AppKit.NSShadow)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void AppKit.NSViewController::DismissController(Foundation.NSObject)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void AppKit.NSViewController::set_RepresentedObject(Foundation.NSObject)' is missing an [NullAllowed] on parameter #0
!missing-null-allowed! 'System.Void AppKit.NSViewController::set_Title(System.String)' is missing an [NullAllowed] on parameter #0
Expand Down

0 comments on commit 768c9e5

Please sign in to comment.