Skip to content

[Foundation] Improve nullability in NSArray.ToArray.#24974

Merged
rolfbjarne merged 3 commits intomainfrom
dev/rolf/foundation-nullability-44-nsarray-toarray
Mar 24, 2026
Merged

[Foundation] Improve nullability in NSArray.ToArray.#24974
rolfbjarne merged 3 commits intomainfrom
dev/rolf/foundation-nullability-44-nsarray-toarray

Conversation

@rolfbjarne
Copy link
Copy Markdown
Member

  • Enable #nullable enable file-wide in NSArray.cs.
  • Improve nullability annotations for ToArray (return TKey?[]).
  • Improve nullability annotations for NSArray.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.

* 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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 #nullable in src/Foundation/NSArray.cs and update ToArray/NSArray<TKey>.ToArray to return nullable-element arrays.
  • Add NonNullToArrayDropNullElements helpers 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.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [CI Build #fb0645b] Build passed (Build packages) ✅

Pipeline on Agent
Hash: fb0645b56f8afa7a2ff7564ce9743809f673be8c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

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

Pipeline on Agent
Hash: fb0645b56f8afa7a2ff7564ce9743809f673be8c [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@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: fb0645b56f8afa7a2ff7564ce9743809f673be8c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

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

Pipeline on Agent
Hash: fb0645b56f8afa7a2ff7564ce9743809f673be8c [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne enabled auto-merge (squash) March 24, 2026 06:07
@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

🚀 [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
✅ 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. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 11 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: fb0645b56f8afa7a2ff7564ce9743809f673be8c [PR build]

@rolfbjarne rolfbjarne merged commit d59a2a3 into main Mar 24, 2026
48 checks passed
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.

4 participants