[UIKit] Enable nullability and clean up UICollectionView.#24599
[UIKit] Enable nullability and clean up UICollectionView.#24599rolfbjarne merged 3 commits intomainfrom
Conversation
This is file 5 of 30 files with nullability disabled in UIKit. * Enable nullability (#nullable enable). * Remove unused System.Threading.Tasks using directive. * Use ArgumentNullException.ThrowIfNull() instead of manual null checks. * Add nullable annotation for Source property (UICollectionViewSource?). * Simplify Source property getter with expression body. * Replace include file references with inlined XML documentation. * Remove inlined DocId entries from docs/api/UIKit/UICollectionView.xml. * Improve XML documentation comments: remove 'To be added.' placeholders, fix whitespace, add missing docs, add 'see cref' references. Contributes towards #17285.
There was a problem hiding this comment.
Pull request overview
Enables nullable reference types for UICollectionView and refreshes related API/documentation to reduce “nullable-disabled” surface area in UIKit.
Changes:
- Enabled
#nullableinsrc/UIKit/UICollectionView.csand updated signatures/docs (notablySourceand registration helpers). - Updated
ObjCRuntime.Class.GetHandleto accept nullableTypeand returnNativeHandle.Zerofor null. - Removed now-redundant XML DocId blocks from
docs/api/UIKit/UICollectionView.xmlafter inlining docs into source.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/UIKit/UICollectionView.cs | Enables nullability and updates helper APIs + XML docs for UICollectionView. |
| src/ObjCRuntime/Class.cs | Adjusts Class.GetHandle nullability/behavior to support nullable call sites. |
| docs/api/UIKit/UICollectionView.xml | Deletes DocId sections that are no longer referenced after doc inlining. |
src/UIKit/UICollectionView.cs
Outdated
| ArgumentNullException.ThrowIfNull (cellType); | ||
|
|
||
| RegisterClassForCell (Class.GetHandle (cellType), reuseIdentifier); |
There was a problem hiding this comment.
RegisterClassForCell (Type? cellType, NSString reuseIdentifier) declares cellType as nullable and the XML remarks explicitly say callers may pass null to un-register, but the method now throws via ArgumentNullException.ThrowIfNull (cellType). This makes the API contract inconsistent and prevents un-registration. Either allow null by removing the throw (and passing a zero handle), or make cellType non-nullable and update the remarks accordingly.
| ArgumentNullException.ThrowIfNull (cellType); | |
| RegisterClassForCell (Class.GetHandle (cellType), reuseIdentifier); | |
| var handle = cellType is null ? System.IntPtr.Zero : Class.GetHandle (cellType); | |
| RegisterClassForCell (handle, reuseIdentifier); |
…ility-uicollectionview-05
✅ [CI Build #b730897] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #b730897] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ 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 #b730897] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #b730897] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #b730897] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #b730897] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
💻 [CI Build #b730897] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #b730897] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #b730897] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 120 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
This is file 5 of 30 files with nullability disabled in UIKit.
Contributes towards #17285.