Skip to content

[AppKit] ApplicationIconImage and NSDockTile.ContentView reject valid null values #26449

Description

@tipa

Apple platform

macOS

Framework version

net10.0-*

Affected platform version

macOS 26.6.1 arm64; Xcode 26.6; .NET SDK 10.0.302; macOS workload 26.5.10301.

Description

NSApplication.ApplicationIconImage and NSDockTile.ContentView throw ArgumentNullException when assigned null.

AppKit declares applicationIconImage as null_resettable and contentView as nullable. The generated .NET setters instead call GetNonNullHandle, preventing the documented reset operations.

Expected: forward nil to AppKit.
Actual: throw before calling AppKit.

Binding definitions:

Steps to Reproduce

  1. Create a net10.0-macos app.
  2. Run each statement separately:
NSApplication.SharedApplication.ApplicationIconImage = null!;
NSApplication.SharedApplication.DockTile.ContentView = null!;
  1. Each setter throws ArgumentNullException from GetNonNullHandle.

Did you find any workaround?

A correctly typed objc_msgSend call can forward nil:

[DllImport("/usr/lib/libobjc.A.dylib", EntryPoint = "objc_msgSend")]
static extern void SendVoid(IntPtr receiver, IntPtr selector, IntPtr value);

SendVoid((IntPtr)receiver.Handle, Selector.GetHandle(setterName), IntPtr.Zero);

Relevant logs

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions