Skip to content

Comments

[Foundation] Add helper methods to NSArray to create managed arrays of strongly typed dictionaries.#24759

Open
rolfbjarne wants to merge 1 commit intomainfrom
dev/rolf/dictionary-array-from-handle
Open

[Foundation] Add helper methods to NSArray to create managed arrays of strongly typed dictionaries.#24759
rolfbjarne wants to merge 1 commit intomainfrom
dev/rolf/dictionary-array-from-handle

Conversation

@rolfbjarne
Copy link
Member

Add two internal convencience methods to NSArray:

  • DictionaryArrayFromHandleDropNullElements
  • NonNullDictionaryArrayFromHandleDropNullElements

And update code in a few other classes to take advantage of these new methods.

Also add a test for CTFont.GetVariationAxes, since I updated that method, and
it didn't already have a test.

Contributes towards #17285.

…f strongly typed dictionaries.

Add two internal convencience methods to NSArray:

* DictionaryArrayFromHandleDropNullElements
* NonNullDictionaryArrayFromHandleDropNullElements

And update code in AudioToolbox, CFProxySupport, and CTFont to take advantage of these new methods.

Also add a test for CTFont.GetVariationAxes.

Contributes towards #17285.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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

Adds internal NSArray helpers to materialize managed arrays from native NSArray<NSDictionary> handles while skipping null/NSNull, and updates multiple call sites to use these helpers to improve null-handling and reduce boilerplate. Also adds a CoreText test covering CTFont.GetVariationAxes.

Changes:

  • Add DictionaryArrayFromHandleDropNullElements and NonNullDictionaryArrayFromHandleDropNullElements to NSArray.
  • Refactor several APIs (CoreText/CFNetwork/VideoToolbox/AudioUnit/AudioToolbox) to use the new helpers.
  • Add a unit test for CTFont.GetVariationAxes.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/monotouch-test/CoreText/FontTest.cs Adds a test for CTFont.GetVariationAxes.
src/VideoToolbox/VTVideoEncoder.cs Refactors encoder list materialization to use new NSArray helper (with handle release).
src/Foundation/NSArray.cs Introduces new internal helper methods to build typed arrays from NSArray<NSDictionary> while dropping null/NSNull entries.
src/CoreText/CTFont.cs Uses the new non-null helper for variation axes/features/feature settings arrays.
src/CoreFoundation/CFProxySupport.cs Avoids wrapping returned CFArray in NSArray (extra retain) and uses new helper with releaseHandle: true.
src/AudioUnit/AudioComponent.cs Uses new helper for ComponentList materialization.
src/AudioToolbox/AudioToolbox.cs Refactors GetInstrumentInfo to use new helper and adds an early-return on error.

@rolfbjarne rolfbjarne enabled auto-merge (squash) February 20, 2026 21:07
@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #7128d45] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 7128d452fcc0d50c18f529367833ebc2bb8eda5b [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: 7128d452fcc0d50c18f529367833ebc2bb8eda5b [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 Unable to find the contents for the comment: D:\a\1\s\change-detection\results\gh-comment.md does not exist :fire

Pipeline on Agent
Hash: 7128d452fcc0d50c18f529367833ebc2bb8eda5b [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #7128d45] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 7128d452fcc0d50c18f529367833ebc2bb8eda5b [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build #7128d45] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 1 tests failed, 155 tests passed.

Failures

❌ cecil tests

1 tests failed, 0 tests passed.

Failed tests

  • Cecil-based tests: Failed (Execution failed with exit code 1)
    • Cecil.Tests.HandleSafetyTest.Check: Foundation.NSArray.DictionaryArrayFromHandleDropNullElements: Fetched the handle of an object, but a reference to the object was...

Html Report (VSDrops) Download

Successes

✅ 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. 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

Pipeline on Agent
Hash: 7128d452fcc0d50c18f529367833ebc2bb8eda5b [PR build]

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.

3 participants