Skip to content

[Foundation] Improve NSArray.From[NS]Objects slightly.#24569

Merged
rolfbjarne merged 4 commits intomainfrom
dev/rolf/foundation-nullability-44-nsarray-fromnsobjects
Jan 29, 2026
Merged

[Foundation] Improve NSArray.From[NS]Objects slightly.#24569
rolfbjarne merged 4 commits intomainfrom
dev/rolf/foundation-nullability-44-nsarray-fromnsobjects

Conversation

@rolfbjarne
Copy link
Copy Markdown
Member

  • Enable nullability.
  • Reuse existing code to create the native array.
  • Add tests.
  • Add xml docs.
  • Update nullability in some of the consumers of these methods whenever it makes sense.
  • Add a 'nint count' overload to a few methods that takes 'int count', so that we use 'nint' for 'count' everywhere, and deprecated the 'int count' overloads.

Contributes towards #17285.

* Enable nullability.
* Reuse existing code to create the native array.
* Add tests.
* Add xml docs.
* Update nullability in some of the consumers of these methods whenever it makes sense.
* Add a 'nint count' overload to a few methods that takes 'int count', so that  we use 'nint' for 'count' everywhere, and deprecated the 'int count' overloads.

Contributes towards #17285.
@vs-mobiletools-engineering-service2

This comment has been minimized.

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 improves the NSArray.FromNSObjects and FromObjects methods by enabling nullability, adding comprehensive XML documentation, refactoring to reuse existing code, adding nint count overloads, and wrapping the old int count overloads in conditional compilation for removal in XAMCORE 5.0.

Changes:

  • Enabled nullability for NSArray factory methods and updated parameter/return types to properly indicate nullable elements
  • Added comprehensive XML documentation for all public NSArray factory methods
  • Refactored internal implementation to reuse FromIntPtrs and consolidated logic into FromNativeObjectsImpl
  • Added nint count overloads for consistency across the API surface
  • Wrapped deprecated int count overloads in #if !XAMCORE_5_0 for future removal
  • Updated consumers (NSOrderedSet, NSMutableSet, NSDictionary, etc.) to use nullable types
  • Added comprehensive test coverage for new and existing functionality

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Foundation/NSArray.cs Main implementation changes: enabled nullability, added XML docs, refactored to reuse code, added nint count overloads, deprecated int count overloads
src/Foundation/NSOrderedSet.cs Updated constructor and MakeNSOrderedSet to use nullable parameters
src/Foundation/NSMutableSet.cs Updated constructors to use nullable parameters
src/Foundation/NSMutableSet_1.cs Refactored to use FromNonNullNativeObjects instead of manual null checks
src/Foundation/NSDictionary.cs Updated constructors and helper methods to use nullable parameters
src/Foundation/NSDictionary_2.cs Updated constructors and methods to use nullable parameters, changed From to FromNativeObjects
src/Foundation/NSMutableDictionary.cs Updated FromObjectsAndKeys methods to use nullable parameters
src/Foundation/NSMutableDictionary_2.cs Updated constructors and methods to use nullable parameters
src/AudioUnit/AudioComponent.cs Updated lambda to handle nullable Dictionary property
tests/monotouch-test/Foundation/NSArray1Test.cs Added comprehensive tests for new functionality and edge cases
tests/monotouch-test/Foundation/NSOrderedSetTest.cs Added tests for nullable constructors and methods
tests/monotouch-test/Foundation/NSMutableSetTest.cs Added tests for nullable constructors
tests/monotouch-test/Foundation/NSMutableOrderedSetTest.cs Added tests for nullable constructors
tests/cecil-tests/HandleSafety.KnownFailures.cs Updated method signature reference from FromNativeObjects to FromNativeObjectsImpl
tests/cecil-tests/Documentation.KnownFailures.txt Removed entries for methods that now have documentation

Comment thread src/Foundation/NSArray.cs
Comment thread src/Foundation/NSArray.cs
Comment thread src/Foundation/NSArray.cs
@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

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.

@rolfbjarne rolfbjarne enabled auto-merge (squash) January 28, 2026 09:11
@vs-mobiletools-engineering-service2

This comment has been minimized.

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

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

Pipeline on Agent
Hash: 03934743c65ef3d35b99b82d5bc01708bb31fd25 [PR build]

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

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

Pipeline on Agent
Hash: 03934743c65ef3d35b99b82d5bc01708bb31fd25 [PR build]

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

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

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

Pipeline on Agent
Hash: 03934743c65ef3d35b99b82d5bc01708bb31fd25 [PR build]

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

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

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

Pipeline on Agent
Hash: 03934743c65ef3d35b99b82d5bc01708bb31fd25 [PR build]

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

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

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

Pipeline on Agent
Hash: 03934743c65ef3d35b99b82d5bc01708bb31fd25 [PR build]

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

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

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

Pipeline on Agent
Hash: 03934743c65ef3d35b99b82d5bc01708bb31fd25 [PR build]

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

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

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

Pipeline on Agent
Hash: 03934743c65ef3d35b99b82d5bc01708bb31fd25 [PR build]

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

💻 [CI Build #0393474] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: 03934743c65ef3d35b99b82d5bc01708bb31fd25 [PR build]

@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 #0393474] 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 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 9 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 9 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. [attempt 4] Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 03934743c65ef3d35b99b82d5bc01708bb31fd25 [PR build]

@rolfbjarne rolfbjarne merged commit 427f5d1 into main Jan 29, 2026
46 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