[Foundation] Improve nullability in NSArray.EnumsFromHandle.#24861
[Foundation] Improve nullability in NSArray.EnumsFromHandle.#24861rolfbjarne wants to merge 2 commits intomainfrom
Conversation
* Improve nullability annotations for EnumsFromHandle (return T[]? instead of T[]). * Add a NonNullEnumsFromHandle variant that guarantees a non-null return value. * Use Enum.ToObject instead of Convert.ChangeType, which doesn't support enum types. * Rewrite to use ArrayFromHandleDropNullElements/NonNullArrayFromHandleDropNullElements. * Update NEHotspotEapSettings.SupportedEapTypes to use NonNullEnumsFromHandle. * Add tests for NSArray.EnumsFromHandle and NEHotspotEapSettings.SupportedEapTypes. Contributes towards #17285. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR improves the nullability contract and implementation of Foundation.NSArray.EnumsFromHandle, adds a non-null-returning helper for internal consumers, updates NEHotspotEapSettings.SupportedEapTypes to use the non-null variant, and adds regression tests to cover the new behaviors (part of the ongoing Foundation nullability work in #17285).
Changes:
- Update
NSArray.EnumsFromHandle<T>to returnT[]?, useEnum.ToObject, and route through theArrayFromHandleDropNullElementshelpers. - Add
NSArray.NonNullEnumsFromHandle<T>and use it fromNEHotspotEapSettings.SupportedEapTypesto guarantee a non-null array. - Add/adjust tests for
NSArray.EnumsFromHandleandNEHotspotEapSettings.SupportedEapTypes, and remove a documentation known-failure entry.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/monotouch-test/NetworkExtension/NEHotspotEapSettingsTest.cs | Adds unit tests validating SupportedEapTypes default/roundtrip/null-guard behavior. |
| tests/monotouch-test/Foundation/NSArray1Test.cs | Adds unit tests for NSArray.EnumsFromHandle nullability and conversion behavior. |
| tests/cecil-tests/Documentation.KnownFailures.txt | Removes known-failure entry for NSArray.EnumsFromHandle<T> documentation/signature. |
| src/NetworkExtension/NEHotspotEapSettings.cs | Switches getter to NSArray.NonNullEnumsFromHandle to guarantee non-null return. |
| src/Foundation/NSArray.cs | Implements nullable-returning EnumsFromHandle + internal non-null variant, using drop-null-elements array helpers. |
You can also share your feedback on Copilot code review. Take the survey.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🔥 [CI Build #b2ad189] Test results 🔥Test results❌ Tests failed on VSTS: test results 5 tests crashed, 11 tests failed, 120 tests passed. Failures❌ linker tests11 tests failed, 33 tests passed.Failed tests
|
✅ [CI Build #f5bde22] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #f5bde22] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ [CI Build #f5bde22] Build passed (Build macOS tests) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🔥 [CI Build #f5bde22] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 1 tests failed, 155 tests passed. Failures❌ monotouch tests (tvOS) [attempt 2]1 tests failed, 10 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ cecil: 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 |
Contributes towards #17285.