Skip to content

[Foundation] Improve NSArray.FromIntPtrs slightly.#24501

Merged
rolfbjarne merged 2 commits intomainfrom
dev/rolf/foundation-nullability-44-nsarray-fromintptrs
Jan 14, 2026
Merged

[Foundation] Improve NSArray.FromIntPtrs slightly.#24501
rolfbjarne merged 2 commits intomainfrom
dev/rolf/foundation-nullability-44-nsarray-fromintptrs

Conversation

@rolfbjarne
Copy link
Member

@rolfbjarne rolfbjarne commented Jan 13, 2026

  • Enable nullability.
  • Simplify code, with both reduced memory footprint, and faster execution speed.
  • Add tests.
  • Add xml docs.

Contributes towards #17285.

* Enable nullability.
* Simplify code, with both reduced memory footprint, and faster execution speed.
* Add tests.
* Add xml docs.
Copy link
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.FromIntPtrs methods by enabling nullable reference types, optimizing performance through the use of fixed statements instead of manual memory marshaling, adding comprehensive tests, and providing XML documentation.

Changes:

  • Optimized memory management by replacing Marshal.AllocHGlobal/FreeHGlobal with fixed statements
  • Added XML documentation for both FromIntPtrs overloads
  • Added three comprehensive unit tests covering normal usage, null input, and empty arrays

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/monotouch-test/Foundation/NSArray1Test.cs Added three unit tests for FromIntPtrs(NativeHandle[]): normal case, null argument validation, and empty array handling
src/Foundation/NSArray.cs Refactored both FromIntPtrs methods to use fixed statements for better performance, added XML documentation, enabled nullable reference types, and improved null handling

/// <summary>Create an <see cref="NSArray" /> from the specified pointers.</summary>
/// <param name="vals">Array of pointers (to <see cref="NSObject" /> instances).</param>
/// <remarks>If the <paramref name="vals" /> array is null, an <see cref="ArgumentNullException" /> is thrown.</remarks>
public static NSArray FromIntPtrs (NativeHandle [] vals)
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

The modifier order was changed from static public to public static. According to the coding guidelines, diffs should be kept as small as possible and preserve existing code formatting. Since the original method used static public, it should remain that way.

Copilot generated this review using guidance from repository custom instructions.
@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 14, 2026 08:06
@rolfbjarne rolfbjarne disabled auto-merge January 14, 2026 08:49
@rolfbjarne rolfbjarne enabled auto-merge (squash) January 14, 2026 08:49
@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: bf6ce57a446a377270db273e88dd068f7e9e494c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: bf6ce57a446a377270db273e88dd068f7e9e494c [PR build]

@vs-mobiletools-engineering-service2
Copy link
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: bf6ce57a446a377270db273e88dd068f7e9e494c [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: bf6ce57a446a377270db273e88dd068f7e9e494c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: bf6ce57a446a377270db273e88dd068f7e9e494c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: bf6ce57a446a377270db273e88dd068f7e9e494c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: bf6ce57a446a377270db273e88dd068f7e9e494c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: bf6ce57a446a377270db273e88dd068f7e9e494c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: bf6ce57a446a377270db273e88dd068f7e9e494c [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
Collaborator

🚀 [CI Build #bf6ce57] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 119 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 11 tests passed. [attempt 4] 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. [attempt 2] Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: bf6ce57a446a377270db273e88dd068f7e9e494c [PR build]

@rolfbjarne rolfbjarne merged commit accb715 into main Jan 14, 2026
45 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