[AppKit] Add bindings for the new APIs in Xcode 27. - #25777
Conversation
Bind the missing AppKit APIs reported by xtro for Xcode 27, emptying macOS-AppKit.todo and MacCatalyst-AppKit.todo. New types: NSViewCornerRadius, NSViewCornerConfiguration, NSViewCornerRadii, NSRefreshController, NSStatusItemExpandedInterfaceSession and NSTextSelectionManager. New protocols: NSStatusItemExpandedInterfaceDelegate, NSTextSelectionManagerDelegate and the NSTextViewportRenderingSurface / NSTextViewportRenderingSurfaceKey marker protocols. New enums: NSControlEvents, NSMenuItemImageVisibility, NSScreenTouchCapabilities, NSSegmentedControlRole, NSTextSelectionMode, NSToolbarItemGroupRole, NSTextAttachmentViewProviderReusePolicy, NSViewExclusiveGestureBehavior and the NSApplicationPresentationDisableScreenCornerInteractions option. New members on NSView, NSControl, NSScrollView, NSScreen, NSMenuItem, NSSegmentedControl, NSStatusItem, NSTextView, NSTextBlock, NSBrowserDelegate, NSGestureRecognizer, NSPanGestureRecognizer, NSGlassEffectView and NSEvent, plus the new NSTextAlignmentToCTTextAlignment / NSTextAlignmentFromCTTextAlignment P/Invokes (covered by a new monotouch-test). Also deprecate NSPanGestureRecognizer.NumberOfTouchesRequired, fix the nullability of the new NSView corner properties, NSStatusItem.ExpandedInterfaceSession and NSTextBlock.DrawBackground, and make NSPaperMarginDocumentAttribute available on macOS. The shared TextKit changes in xkit.cs (NSTextLayoutManagerDelegate, NSTextLocation, NSTextLayoutFragment and NSTextViewportLayoutControllerDelegate) also resolve the equivalent entries in the iOS, tvOS and Mac Catalyst UIKit .todo files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the AppKit (and shared TextKit) bindings to cover the newly introduced APIs in Xcode 27, and updates the xtro-sharpie .todo/.ignore lists plus test coverage to reflect the new surface area.
Changes:
- Added new AppKit bindings (types/protocols/enums/members) for Xcode 27, including corner configuration APIs, refresh controller, status item expanded interface, new control/menu/screen enums, and additional selectors.
- Added shared TextKit protocol bindings and updated introspection skipping for an Xcode 27 runtime/header mismatch.
- Updated xtro-sharpie todo/ignore files and added a new monotouch-test validating NSTextAlignment ↔ CTTextAlignment conversion P/Invokes.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/xtro-sharpie/api-annotations-dotnet/tvOS-UIKit.todo | Removes resolved TextKit-related todo entries. |
| tests/xtro-sharpie/api-annotations-dotnet/macOS-AppKit.todo | Emptied by binding the missing AppKit APIs (file removed). |
| tests/xtro-sharpie/api-annotations-dotnet/macOS-AppKit.ignore | Adds ignores for NSTextLocation required-member abstractness deferral. |
| tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-UIKit.todo | Removes resolved TextKit-related todo entries. |
| tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-AppKit.todo | Emptied by binding the missing AppKit APIs (file removed). |
| tests/xtro-sharpie/api-annotations-dotnet/iOS-UIKit.todo | Removes resolved TextKit-related todo entries. |
| tests/xtro-sharpie/api-annotations-dotnet/common-UIKit.ignore | Adds ignores for NSTextLocation required-member abstractness deferral. |
| tests/monotouch-test/AppKit/NSTextAlignmentConversionTest.cs | New test validating NSTextAlignment/CTTextAlignment conversion wrappers. |
| tests/introspection/ApiProtocolTest.cs | Skips a known Xcode 27 runtime mismatch for marker protocol conformance. |
| tests/cecil-tests/Documentation.KnownFailures.txt | Adds doc known-failure entries for newly bound enum values/members. |
| src/xkit.cs | Adds shared TextKit protocol members and marker protocols (viewport rendering surface/key). |
| src/AppKit/Functions.cs | Adds P/Invoke wrappers for NSTextAlignment ↔ CTTextAlignment conversion functions. |
| src/AppKit/Enums.cs | Adds NSApplicationPresentationOptions.DisableScreenCornerInteractions. |
| src/appkit.cs | Adds new AppKit bindings (NSControlEvents, NSRefreshController, status item expanded interface, corner APIs, etc.). |
| [Mac (27, 0), NoMacCatalyst] | ||
| [BaseType (typeof (NSObject))] | ||
| interface NSStatusItemExpandedInterfaceSession { | ||
| [Export ("cancel")] |
There was a problem hiding this comment.
@dalexsoto the [DisableDefaultCtor] might be valid here (the removal of [Export ("cancel")] obviously isn't)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| [Mac (11, 0)] | ||
| [Export ("addTarget:action:forControlEvents:")] | ||
| void AddTarget ([NullAllowed] NSObject target, Selector action, NSControlEvents controlEvents); | ||
|
|
||
| [Mac (11, 0)] | ||
| [Export ("removeTarget:action:forControlEvents:")] | ||
| void RemoveTarget ([NullAllowed] NSObject target, [NullAllowed] Selector action, NSControlEvents controlEvents); |
There was a problem hiding this comment.
This could be done in a separate PR if we decide to do it: having a delegate API would be more C#-like:
void AddTarget (Action action, NSControlEvents controlEvents);
void RemoveTarget (Action action, NSControlEvents controlEvents);or maybe something like this, where disposing of the return value removes the target:
IDisposable AddTarget (Action action, NSControlEvents controlEvents);
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
* Make NSTextLocation's isEqual: and hash unconditionally [Abstract] instead of gating [Abstract] behind XAMCORE_5_0 (adding [Abstract] to a protocol member is no longer a breaking change), and drop the now-unnecessary incorrect-protocol-member xtro ignore entries. * Rename the new NSTextBlock 'widthValueTypeForLayer:rectEdge:' binding from WidthValueTypeForLayer to GetWidthValueType to follow .NET naming conventions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
❌ [CI Build #a9b9861] Prepare .NET Release failed ❌The following jobs reported a non-successful result:
📦 Signed NuGet packages (32 packages)iOS
MacCatalyst
macOS
tvOS
Other
Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…adii. The macOS 27 runtime conforms NSViewCornerRadii to NSCoding and NSSecureCoding, but the Xcode 27 beta 2 SDK header declares only 'NSViewCornerRadii : NSObject <NSCopying>'. Since the conformance is not declared in the headers, skip the Coding and SecureCoding introspection checks for this type; the binding stays faithful to the header (NSCopying only). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…rnerRadii. The previous commit added the NSViewCornerRadii exclusion intended for NSSecureCoding into the adjacent NSCopying switch block by mistake, so the SecureCoding introspection test still failed on macOS 27 (while Coding passed). Move the exclusion into the correct NSSecureCoding block, and drop the stray NSCopying entry so NSViewCornerRadii's legitimate INSCopying conformance keeps being tested. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #4f95070] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #4f95070] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [PR Build #4f95070] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #4f95070] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 196 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
|
/review |
|
✅ .NET for Apple Platforms PR Reviewer completed successfully! |
There was a problem hiding this comment.
✅ Review Complete
This PR adds comprehensive AppKit bindings for Xcode 27, including new types, protocols, and members across multiple frameworks. The changes follow the repository's binding conventions well. CI is green ✅ — all tests passed.
Summary
- New types: 8 (NSViewCornerRadius, NSViewCornerConfiguration, NSViewCornerRadii, NSRefreshController, NSStatusItemExpandedInterfaceSession, NSTextSelectionManager, and protocols)
- New enums: 9 (NSControlEvents, NSMenuItemImageVisibility, NSScreenTouchCapabilities, NSSegmentedControlRole, NSTextSelectionMode, NSToolbarItemGroupRole, NSTextAttachmentViewProviderReusePolicy, NSViewExclusiveGestureBehavior, plus enum value)
- New members: ~100+ across NSView, NSControl, NSScrollView, NSScreen, NSMenuItem, NSSegmentedControl, NSStatusItem, NSTextView, NSTextBlock, NSBrowserDelegate, NSGestureRecognizer, NSPanGestureRecognizer, NSGlassEffectView, NSEvent, and TextKit shared types
What's Good
✅ Platform availability attributes are consistently applied
✅ [NullAllowed] is correctly used for nullable parameters and return values
✅ Deprecated API (NSPanGestureRecognizer.NumberOfTouchesRequired) correctly marked with [Deprecated] and replacement provided
✅ Shared TextKit protocol changes (NSTextLayoutManagerDelegate, NSTextLocation, NSTextLayoutFragment, NSTextViewportLayoutControllerDelegate) correctly resolve .todo entries across iOS, tvOS, and Mac Catalyst
✅ Proper use of ArgumentSemantic for properties
✅ Test exclusions added for known runtime/header discrepancies (NSViewCornerRadii conformance, NSTextLayoutFragment protocol)
✅ All .todo files properly emptied for resolved APIs
Suggestions (💡)
I've posted 8 inline suggestions for minor improvements:
- Verify platform availability consistency for NSViewCornerRadius vs related types
- Confirm nullability of NSView.CornerConfiguration (read-only property)
- Check if NSRefreshController and NSStatusItemExpandedInterfaceSession need constructors
- Verify
ArgumentSemantic.Assignusage for NSTextSelectionManager.TextSelectionMode - Confirm NSTextLocation.IsEqual allows nil parameter
- Consider adding documentation for GetNativeHash() method
- Ensure NSTextView's
[RequiresSuper]methods are tested
Issue count: 0 errors ❌ | 0 warnings
Great work on a thorough and well-structured binding addition! The bindings follow the repository conventions and the PR description accurately reflects the changes.
Generated by .NET for Apple Platforms PR Reviewer for issue #25777 · 72.2 AIC · ⌖ 10.6 AIC · ⊞ 5.1K
Comment /review to run again
Comments that could not be inline-anchored
src/appkit.cs:346
🤖 💡 Binding definition — NSViewCornerRadius is marked as available on both Mac and MacCatalyst (27, 0), but NSViewCornerConfiguration and NSViewCornerRadii are only marked Mac (27, 0), NoMacCatalyst. This inconsistency should be verified against Apple's headers.
Rule: Platform availability attributes
src/appkit.cs:279
🤖 💡 API design — NSStatusItemExpandedInterfaceSession has only a Cancel() method. Verify if there are any properties (like isActive or lifecycle state) that should be exposed, or if this is intentionally a minimal interface.
Rule: Binding correctness
src/xkit.cs:662
🤖 💡 Protocol binding — The IsEqual method in NSTextLocation protocol is marked [Abstract], which is correct. However, the parameter is [NullAllowed] NSObject anObject. Verify in Apple's headers whether nil is allowed — most isEqual: implementations allow nil for safe comparison, so this looks correct.
Rule: NullAllowed on nullable parameters
src/appkit.cs:482
🤖 💡 Binding definition — NSTextSelectionManager has three separate properties: TextSelectionMode (assign), WeakDelegate (weak), and WeakTextSelectionDataSource (weak). The Wrap properties are correctly generated. Verify that TextSelectionMode should use ArgumentSemantic.Assign — for enums this is typically correct, but double-check the headers.
Rule: ArgumentSemantic for properties
src/xkit.cs:667
🤖 💡 Method naming — The method is named GetNativeHash() to return the hash value. This follows the convention of prefixing property-like accessors with Get to avoid conflicts with the C# GetHashCode() method. Consider documenting why this method exists alongside the standard GetHashCode() to clarify for API consumers.
Rule: Method naming conventions
src/appkit.cs:550
🤖 💡 Testing — NSTextView now implements NSTextViewportLayoutControllerDelegate with five new methods marked with [RequiresSuper] and [Mac (27, 0)]. These are reimplementations (using new) of protocol methods with added attributes. Verify that these overrides are tested, especially the [RequiresSuper] behavior — subclasses must call the base implementation or risk runtime errors.
Rule: Testing
src/appkit.cs:208
🤖 💡 API design — NSRefreshController has no constructor binding. Verify whether this class has a designated initializer or if instances are only created by the framework. If there's a public init or new method in Apple's headers, it should be bound.
Rule: Binding correctness
src/appkit.cs:316
🤖 💡 Binding definition — The CornerConfiguration property on NSView is read-only (no setter), yet it's decorated with [NullAllowed] and ArgumentSemantic.Copy. For read-only properties bound from getters, verify that the property can actually return nil in Apple's documentation. If it's guaranteed non-null, remove [NullAllowed].
Rule: NullAllowed on nullable parameters
Bind the missing AppKit APIs reported by xtro for Xcode 27, emptying macOS-AppKit.todo and MacCatalyst-AppKit.todo.
New types: NSViewCornerRadius, NSViewCornerConfiguration, NSViewCornerRadii, NSRefreshController, NSStatusItemExpandedInterfaceSession and NSTextSelectionManager.
New protocols: NSStatusItemExpandedInterfaceDelegate, NSTextSelectionManagerDelegate and the NSTextViewportRenderingSurface / NSTextViewportRenderingSurfaceKey marker protocols.
New enums: NSControlEvents, NSMenuItemImageVisibility, NSScreenTouchCapabilities, NSSegmentedControlRole, NSTextSelectionMode, NSToolbarItemGroupRole, NSTextAttachmentViewProviderReusePolicy, NSViewExclusiveGestureBehavior and the NSApplicationPresentationDisableScreenCornerInteractions option.
New members on NSView, NSControl, NSScrollView, NSScreen, NSMenuItem, NSSegmentedControl, NSStatusItem, NSTextView, NSTextBlock, NSBrowserDelegate, NSGestureRecognizer, NSPanGestureRecognizer, NSGlassEffectView and NSEvent, plus the new NSTextAlignmentToCTTextAlignment / NSTextAlignmentFromCTTextAlignment P/Invokes (covered by a new monotouch-test).
Also deprecate NSPanGestureRecognizer.NumberOfTouchesRequired, fix the nullability of the new NSView corner properties, NSStatusItem.ExpandedInterfaceSession and NSTextBlock.DrawBackground, and make NSPaperMarginDocumentAttribute available on macOS.
The shared TextKit changes in xkit.cs (NSTextLayoutManagerDelegate, NSTextLocation, NSTextLayoutFragment and NSTextViewportLayoutControllerDelegate) also resolve the equivalent entries in the iOS, tvOS and Mac Catalyst UIKit .todo files.