[Foundation] Add helper methods to NSArray to create managed arrays of strongly typed dictionaries.#24759
[Foundation] Add helper methods to NSArray to create managed arrays of strongly typed dictionaries.#24759rolfbjarne wants to merge 1 commit intomainfrom
Conversation
…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>
There was a problem hiding this comment.
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
DictionaryArrayFromHandleDropNullElementsandNonNullDictionaryArrayFromHandleDropNullElementstoNSArray. - 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. |
✅ [CI Build #7128d45] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #7128d45] Build passed (Detect API changes) ✅Pipeline on Agent |
|
🔥 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 |
✅ [CI Build #7128d45] Build passed (Build macOS tests) ✅Pipeline on Agent |
🔥 [CI Build #7128d45] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 1 tests failed, 155 tests passed. Failures❌ cecil tests1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Add two internal convencience methods to NSArray:
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.