Skip to content

[UIKit] Give priority to the UIMenuIdentifier overload of UIMenu.Create. Fixes #26267. - #26293

Merged
rolfbjarne merged 2 commits into
mainfrom
dev/rolf/issue-26267-net11-source-breaking-new-uimenu-create-25053a
Jul 24, 2026
Merged

[UIKit] Give priority to the UIMenuIdentifier overload of UIMenu.Create. Fixes #26267.#26293
rolfbjarne merged 2 commits into
mainfrom
dev/rolf/issue-26267-net11-source-breaking-new-uimenu-create-25053a

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Description

The .NET 11 iOS bindings added a new UIMenu.Create overload taking an NSString? identifier alongside the pre-existing overload taking a UIMenuIdentifier identifier enum:

UIMenu Create (string title, UIImage? image, UIMenuIdentifier identifier, UIMenuOptions options, UIMenuElement[] children);
UIMenu Create (string title, UIImage? image, NSString? identifier, UIMenuOptions options, UIMenuElement[] children);

This is source-breaking: existing code that passes identifier: default (a common pattern, since the identifier is optional in UIKit) now fails to compile with CS0121 (ambiguous call), because default converts to both UIMenuIdentifier (enum default) and NSString? (null).

Fix

Add [OverloadResolutionPriority (-1)] to the newer NSString overload so the pre-existing UIMenuIdentifier-enum overload wins overload resolution. This keeps identifier: default unambiguous and preserves source compatibility, while still allowing callers to reach the NSString overload by passing an explicit NSString argument.

Also added the missing using System.Runtime.CompilerServices; to src/uikit.cs, which is required for the attribute to compile in the ApiDefinition project.

Testing

Verified with a clean managed build (make all && make install) for iOS. Confirmed the generated UIMenu.g.cs now emits the [OverloadResolutionPriority (-1)] attribute on the NSString overload.

Fixes #26267

🤖 Pull request created by Copilot

The .NET 11 bindings added a new UIMenu.Create overload taking an
'NSString? identifier' alongside the existing 'UIMenuIdentifier identifier'
overload. This made existing calls passing 'identifier: default' (a common
pattern, since the identifier is optional) ambiguous, resulting in CS0121.

Add [OverloadResolutionPriority (-1)] to the new NSString overload so the
pre-existing UIMenuIdentifier-enum overload wins overload resolution, keeping
'identifier: default' unambiguous and preserving source compatibility.

Fixes #26267
The System.Runtime.CompilerServices namespace wasn't imported in uikit.cs,
so the [OverloadResolutionPriority] attribute added to the UIMenu.Create
overload failed to compile the ApiDefinition project.
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne
rolfbjarne marked this pull request as ready for review July 24, 2026 14:19
@rolfbjarne
rolfbjarne requested a review from dalexsoto as a code owner July 24, 2026 14:19
Copilot AI review requested due to automatic review settings July 24, 2026 14:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the UIKit binding surface to preserve source compatibility after introducing a new UIMenu.Create overload that accepts an NSString identifier, by ensuring the pre-existing UIMenuIdentifier overload wins in ambiguous call sites (notably identifier: default).

Changes:

  • Add using System.Runtime.CompilerServices; to allow using OverloadResolutionPriorityAttribute in the binding definition.
  • Apply [OverloadResolutionPriority (-1)] to the NSString-identifier overload so the UIMenuIdentifier overload is preferred during overload resolution.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 30ba2a8209c7877180c24df97aec6bf3fe25a074 [PR build]

@rolfbjarne
rolfbjarne enabled auto-merge (squash) July 24, 2026 15:24
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #30ba2a8] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 203 tests passed 🎉

Tests counts

✅ assembly-processing: All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 19 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 30ba2a8209c7877180c24df97aec6bf3fe25a074 [PR build]

@rolfbjarne
rolfbjarne merged commit f334b14 into main Jul 24, 2026
57 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/issue-26267-net11-source-breaking-new-uimenu-create-25053a branch July 24, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[net11] Source-breaking: new UIMenu.Create(NSString?) overload makes identifier: default ambiguous (CS0121)

4 participants