-
Notifications
You must be signed in to change notification settings - Fork 554
[Foundation] Fix nullability in NSDictionary<TKey,TValue>. #24457
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
[Foundation] Fix nullability in NSDictionary<TKey,TValue>. #24457
Conversation
This is file 41 of 47 files with nullability disabled in Foundation. * Removes SupportedOSPlatform attributes without version numbers. * Enables nullability and adds nullability attributes where appropriate. * Replaces 'To be added' XML comments with proper documentation. * Adds missing XML documentation for all public members. * Uses ArgumentNullException.ThrowIfNull consistently. * Uses modern C# array syntax ([]) for empty arrays. * Improves IDictionary interface implementation to properly handle missing keys. * Adds some tests. 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 enables nullable reference types for NSDictionary<TKey, TValue> in the Foundation namespace, part of an ongoing effort to enable nullability across 47 files (this is file 41). The changes improve code safety through nullability annotations, modernize the code with C# best practices, and enhance documentation quality by replacing placeholder XML comments with detailed descriptions.
Key changes:
- Enables
#nullableand adds appropriate nullability annotations throughout the class - Replaces
ArgumentNullExceptionnull checks withArgumentNullException.ThrowIfNullfor consistency - Uses modern C# empty array syntax
[]instead ofnew TValue[] {} - Adds comprehensive XML documentation for all public members
- Adds tests for missing key access scenarios to verify IDictionary interface behavior
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Foundation/NSDictionary_2.cs |
Enables nullability, adds proper XML documentation, uses modern C# syntax, and improves IDictionary implementation with correct nullability annotations |
tests/monotouch-test/Foundation/NSDictionary2Test.cs |
Adds comprehensive tests for missing key scenarios, validating that both class and IDictionary interface return null instead of throwing exceptions |
tests/cecil-tests/Documentation.KnownFailures.txt |
Removes entries for methods and properties that now have proper documentation |
src/NaturalLanguage/NLLanguage.cs |
Refactors enumeration pattern to use KeyValuePair iteration for improved efficiency |
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.
✅ [CI Build #398a8b4] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #398a8b4] Build passed (Detect API changes) ✅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 #398a8b4] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #398a8b4] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #398a8b4] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #398a8b4] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #398a8b4] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
💻 [CI Build #398a8b4] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #398a8b4] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 117 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
This is file 41 of 47 files with nullability disabled in Foundation.
Contributes towards #17285.