-
Notifications
You must be signed in to change notification settings - Fork 554
[Foundation] Fix nullability in NSMutableAttributedString. #24431
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 NSMutableAttributedString. #24431
Conversation
- Enabled nullable reference types - Made attribute parameters nullable where appropriate - Updated null checks to use proper null handling patterns - Improved XML documentation: - Removed 'To be added.' placeholders - Added comprehensive descriptions for all public members - Added see cref attributes for related types - Fixed formatting and consistency - Fixed potential null reference in Append method's ToString() call This is file 35 of 47 files with nullability disabled in Foundation. 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 in NSMutableAttributedString as part of a broader effort to add nullability annotations to the Foundation namespace (file 35 of 47). The changes improve type safety by making attributes non-nullable in method parameters where Apple's API doesn't permit null, while allowing nullable attributes in constructors where appropriate. Additionally, comprehensive XML documentation replaces placeholder comments throughout both files.
Key changes:
- Enabled
#nullable enableand removed nullable disable pragma - Updated method parameters: made UIKit/CoreText attribute parameters non-nullable in
SetAttributesandAddAttributesmethods, nullable in constructors - Replaced conditional null checks (
attrs is null ? null : attrs.Dictionary) withArgumentNullException.ThrowIfNullpattern - Enhanced XML documentation with detailed parameter descriptions and cross-references
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Foundation/NSMutableAttributedString.iOS.cs | Enabled nullable reference types for UIKit-specific overloads; made UIStringAttributes parameters non-nullable in SetAttributes and AddAttributes methods; improved documentation |
| src/Foundation/NSMutableAttributedString.cs | Enabled nullable reference types; made CTStringAttributes non-nullable in methods, nullable in constructors; added null-coalescing operator in Append method; made UIKit styling constructor parameters nullable; improved documentation |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #6c787ab] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ [CI Build #6c787ab] 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 #6c787ab] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #6c787ab] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #6c787ab] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
💻 [CI Build #6c787ab] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #6c787ab] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #6c787ab] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
🚀 [CI Build #6c787ab] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 119 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
This is file 35 of 47 files with nullability disabled in Foundation.
Contributes towards #17285.