-
Notifications
You must be signed in to change notification settings - Fork 555
[Foundation] Improve NSArray.FromStrings a bit. #24583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Foundation] Improve NSArray.FromStrings a bit. #24583
Conversation
* 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. * Adjust CFArray.Create|FromStrings methods to match NSArray's equivalent methods. Contributes towards #17285.
There was a problem hiding this 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.FromStrings methods and related CFArray methods by enabling nullability, adding better XML documentation, improving the implementation to reuse existing code, and adding comprehensive tests.
Changes:
- Enabled nullability in NSArray.FromStrings and added a new FromNullableStrings method for nullable array inputs
- Refactored NSArray.FromStrings to reuse CFArray.Create, eliminating duplicated marshaling logic
- Updated CFArray.Create and FromStrings to accept nullable strings with proper documentation
- Updated consumers (NSSet, NSOrderedSet, NSMutableSet) to accept nullable string arrays
- Added comprehensive tests for both NSArray and CFArray with null items
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Foundation/NSArray.cs | Refactored FromStrings to delegate to CFArray.Create, added FromNullableStrings method, improved XML docs, enabled nullability |
| src/CoreFoundation/CFArray.cs | Enhanced Create method with IReadOnlyList overload, updated FromStrings signature, added XML documentation |
| tests/monotouch-test/Foundation/ArrayTest.cs | Added tests for FromStrings with null items, IReadOnlyList, and FromNullableStrings |
| tests/monotouch-test/CoreFoundation/ArrayTest.cs | Added tests for Create and FromStrings with null items and IReadOnlyList |
| src/bgen/Generator.cs | Updated generator to use FromNullableStrings for nullable string arrays |
| src/Foundation/NSSet.cs | Updated constructor to accept nullable string arrays |
| src/Foundation/NSOrderedSet.cs | Updated constructors to accept nullable string arrays |
| src/Foundation/NSMutableSet.cs | Updated constructor to accept nullable string arrays |
| src/CoreText/CTFont.cs | Updated GetDefaultCascadeList to use FromNullableStrings |
| src/CoreServices/FSEvents.cs | Fixed logic to properly check for null before checking Count |
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.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…ullability-44-nsarray-fromstrings
✅ [PR Build #2ee33b6] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ [CI Build #2ee33b6] Build passed (Build packages) ✅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 |
✅ [CI Build #2ee33b6] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #2ee33b6] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #2ee33b6] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #2ee33b6] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
💻 [CI Build #2ee33b6] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
💻 [CI Build #2ee33b6] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
🔥 [CI Build #2ee33b6] Test results 🔥Test results❌ Tests failed on VSTS: test results 4 tests crashed, 5 tests failed, 113 tests passed. Failures❌ dotnettests tests (iOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (tvOS)🔥 Failed catastrophically on VSTS: test results - dotnettests_tvos (no summary found). Html Report (VSDrops) Download ❌ framework tests🔥 Failed catastrophically on VSTS: test results - framework (no summary found). Html Report (VSDrops) Download ❌ fsharp tests1 tests failed, 3 tests passed.Failed tests
Html Report (VSDrops) Download ❌ generator tests🔥 Failed catastrophically on VSTS: test results - generator (no summary found). Html Report (VSDrops) Download ❌ interdependent-binding-projects tests🔥 Failed catastrophically on VSTS: test results - interdependent-binding-projects (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (iOS)1 tests failed, 10 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (macOS)1 tests failed, 11 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (tvOS)1 tests failed, 10 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Contributes towards #17285.