[src] Remove redundant null checks before Class.GetHandle(Type)#24695
[src] Remove redundant null checks before Class.GetHandle(Type)#24695rolfbjarne merged 1 commit intomainfrom
Conversation
`Class.GetHandle(Type?)` already handles null input by returning `NativeHandle.Zero`, making the `x is null ? IntPtr.Zero : Class.GetHandle(x)` ternary patterns unnecessary.
There was a problem hiding this comment.
Pull request overview
This PR simplifies several UIKit/AppKit convenience APIs by removing redundant null checks before calling ObjCRuntime.Class.GetHandle (Type?), relying on GetHandle’s built-in null handling (returns a zero handle) to preserve existing behavior.
Changes:
- Replaced
type is null ? IntPtr.Zero : Class.GetHandle (type)patterns withClass.GetHandle (type)across several registration helpers. - Simplified popover background view type setters to assign the handle directly via
Class.GetHandle.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/UIKit/UITableView.cs | Simplifies cell/header-footer class registration helpers by removing redundant null ternaries. |
| src/UIKit/UIPopoverPresentationController.cs | Simplifies PopoverBackgroundViewType setter to use Class.GetHandle (value) directly. |
| src/UIKit/UIPopoverController.cs | Simplifies PopoverBackgroundViewType setter to use Class.GetHandle (value) directly. |
| src/UIKit/UINavigationController.cs | Simplifies LookupClass helper to directly call Class.GetHandle. |
| src/UIKit/UICollectionViewLayout.cs | Simplifies decoration view registration helper to directly call Class.GetHandle. |
| src/AppKit/NSCollectionViewLayout.cs | Simplifies decoration view registration helper to directly call Class.GetHandle. |
| src/AppKit/NSCollectionView.cs | Simplifies item/supplementary view registration helpers to directly call Class.GetHandle. |
✅ [CI Build #0a82bdc] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #0a82bdc] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ [CI Build #0a82bdc] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #0a82bdc] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #0a82bdc] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #0a82bdc] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #0a82bdc] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
💻 [CI Build #0a82bdc] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. 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 |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #0a82bdc] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 130 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Class.GetHandle(Type?)already handles null input by returningNativeHandle.Zero, making thex is null ? IntPtr.Zero : Class.GetHandle(x)ternary patterns unnecessary.