[Foundation] Improve nullability in NSArray.ToArray.#24974
Conversation
* Enable #nullable enable file-wide in NSArray.cs. * Improve nullability annotations for ToArray<TKey> (return TKey?[]). * Improve nullability annotations for NSArray<TKey>.ToArray (return TKey?[]). * Add NonNullToArrayDropNullElements instance methods for callers needing non-null arrays. * Update CVPixelBufferAttributes.PixelFormatTypes to handle nullable ToArray elements. * Update NSPasteboard/NSPasteboardItem DetectValues Wrap attributes to use NonNullToArrayDropNullElements. * Update XML docs for all modified members. Contributes towards #17285. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR enables nullable reference types in Foundation.NSArray and adjusts ToArray APIs to correctly represent NSNull values as null in managed arrays, while adding drop-null helpers for callers that require non-null elements. It also updates a few call sites to account for the new nullable element types and removes related documentation known-failures.
Changes:
- Enable
#nullableinsrc/Foundation/NSArray.csand updateToArray/NSArray<TKey>.ToArrayto return nullable-element arrays. - Add
NonNullToArrayDropNullElementshelpers and update AppKit wrap code to use them. - Update CoreVideo pixel format conversion to compile with nullable
NSArray.ToArray()elements and adjust documentation known-failures.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/cecil-tests/Documentation.KnownFailures.txt | Removes known-failure entries for updated NSArray.ToArray XML docs. |
| src/appkit.cs | Updates DetectValues wrappers to drop null elements when converting NSArray values to managed arrays. |
| src/Foundation/NSArray_1.cs | Updates generic NSArray<TKey>.ToArray() signature/docs to return TKey?[]. |
| src/Foundation/NSArray.cs | Enables nullable and updates ToArray nullability; introduces non-null drop-null conversion helpers. |
| src/CoreVideo/CVPixelBufferAttributes.cs | Adjusts PixelFormatTypes conversion to handle nullable NSArray.ToArray() elements. |
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.
✅ [CI Build #fb0645b] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #fb0645b] 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 |
✅ [CI Build #fb0645b] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #fb0645b] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 156 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Contributes towards #17285.