KEMBAR78
[UIKit] Make sure to invoke the correct constructor. Fixes #23122. by rolfbjarne · Pull Request #23127 · dotnet/macios · GitHub
Skip to content

Conversation

@rolfbjarne
Copy link
Member

There are three constructors involved here:

  1. (UIBarButtonSystemItem systemItem, EventHandler handler)
  2. (UIBarButtonSystemItem systemItem, NSObject target, Selector action)
  3. (UIBarButtonSystemItem systemItem, UIAction primaryAction, UIMenu menu)

The first constructor is a manually written convenience constructor, and needs
to call another constructor. Either the second or the third constructor works,
but the third constructor is only available on iOS 16+, while the second is
available on all iOS version.

This means that calling the third constructor is a bad idea, because it won't
work on anything before iOS 16. Unfortunately that's exactly what we did.

So change the code to call the second constructor instead.

This is a regression that was introduced in f431538.

Fixes #23122.

There are three constructors involved here:

1. (UIBarButtonSystemItem systemItem, EventHandler handler)
2. (UIBarButtonSystemItem systemItem, NSObject target, Selector action)
3. (UIBarButtonSystemItem systemItem, UIAction primaryAction, UIMenu menu)

The first constructor is a manually written convenience constructor, and needs
to call another constructor. Either the second or the third constructor works,
but the third constructor is only available on iOS 16+, while the second is
available on all iOS version.

This means that calling the third constructor is a bad idea, because it won't
work on anything before iOS 16. Unfortunately that's exactly what we did.

So change the code to call the second constructor instead.

This is a regression that was introduced in f431538.

Fixes #23122.
@rolfbjarne rolfbjarne requested a review from dalexsoto as a code owner June 23, 2025 11:43
@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #b839649] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: b839649cf2a69e2916dadc7363708580b37deec2 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #b839649] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: b839649cf2a69e2916dadc7363708580b37deec2 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #b839649] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: b839649cf2a69e2916dadc7363708580b37deec2 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #b839649] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: b839649cf2a69e2916dadc7363708580b37deec2 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #b839649] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: b839649cf2a69e2916dadc7363708580b37deec2 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #b839649] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 117 tests passed 🎉

Tests counts

✅ 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. 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. Html Report (VSDrops) Download
✅ introspection: All 6 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 8 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 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

Pipeline on Agent
Hash: b839649cf2a69e2916dadc7363708580b37deec2 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #b839649] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: b839649cf2a69e2916dadc7363708580b37deec2 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

.NET ( No breaking changes )

✅ API diff vs stable

.NET ( No breaking changes )

ℹ️ Generator diff

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

Pipeline on Agent
Hash: b839649cf2a69e2916dadc7363708580b37deec2 [PR build]

@dalexsoto dalexsoto merged commit d9533d0 into main Jun 23, 2025
44 checks passed
@dalexsoto dalexsoto deleted the dev/rolf/issue-23122-uibarbuttonitem-ctor branch June 23, 2025 17:13
dalexsoto pushed a commit that referenced this pull request Jun 23, 2025
…23127)

There are three constructors involved here:

1. (UIBarButtonSystemItem systemItem, EventHandler handler)
2. (UIBarButtonSystemItem systemItem, NSObject target, Selector action)
3. (UIBarButtonSystemItem systemItem, UIAction primaryAction, UIMenu
menu)

The first constructor is a manually written convenience constructor, and
needs
to call another constructor. Either the second or the third constructor
works,
but the third constructor is only available on iOS 16+, while the second
is
available on all iOS version.

This means that calling the third constructor is a bad idea, because it
won't
work on anything before iOS 16. Unfortunately that's exactly what we
did.

So change the code to call the second constructor instead.

This is a regression that was introduced in
f431538.

Fixes #23122.
dalexsoto pushed a commit that referenced this pull request Jun 23, 2025
…23127)

There are three constructors involved here:

1. (UIBarButtonSystemItem systemItem, EventHandler handler)
2. (UIBarButtonSystemItem systemItem, NSObject target, Selector action)
3. (UIBarButtonSystemItem systemItem, UIAction primaryAction, UIMenu
menu)

The first constructor is a manually written convenience constructor, and
needs
to call another constructor. Either the second or the third constructor
works,
but the third constructor is only available on iOS 16+, while the second
is
available on all iOS version.

This means that calling the third constructor is a bad idea, because it
won't
work on anything before iOS 16. Unfortunately that's exactly what we
did.

So change the code to call the second constructor instead.

This is a regression that was introduced in
f431538.

Fixes #23122.
dalexsoto added a commit that referenced this pull request Jun 23, 2025
#23131)

Backport of #23127 

Fixes #23122

There are three constructors involved here:

1. (UIBarButtonSystemItem systemItem, EventHandler handler)
2. (UIBarButtonSystemItem systemItem, NSObject target, Selector action)
3. (UIBarButtonSystemItem systemItem, UIAction primaryAction, UIMenu
menu)

The first constructor is a manually written convenience constructor, and
needs
to call another constructor. Either the second or the third constructor
works,
but the third constructor is only available on iOS 16+, while the second
is
available on all iOS version.

This means that calling the third constructor is a bad idea, because it
won't
work on anything before iOS 16. Unfortunately that's exactly what we
did.

So change the code to call the second constructor instead.

This is a regression that was introduced in
f431538.

Fixes #23122.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
dalexsoto added a commit that referenced this pull request Jun 24, 2025
…onstructor. (#23132)

Backport of #23127 

Fixes #23122

There are three constructors involved here:

1. (UIBarButtonSystemItem systemItem, EventHandler handler)
2. (UIBarButtonSystemItem systemItem, NSObject target, Selector action)
3. (UIBarButtonSystemItem systemItem, UIAction primaryAction, UIMenu
menu)

The first constructor is a manually written convenience constructor, and
needs
to call another constructor. Either the second or the third constructor
works,
but the third constructor is only available on iOS 16+, while the second
is
available on all iOS version.

This means that calling the third constructor is a bad idea, because it
won't
work on anything before iOS 16. Unfortunately that's exactly what we
did.

So change the code to call the second constructor instead.

This is a regression that was introduced in
f431538.

Fixes #23122.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding a PickerField causes MAUI App crash in iOS

3 participants