[UIKit] Enable nullability and clean up UIFont.#24637
Conversation
This is file 9 of 30 files with nullability disabled in UIKit. * Enable nullability (#nullable enable). * Add nullable return types (UIFont?) for methods that can return null. * Add nullable parameter types (UIFont?, object?) for equality operators and Equals. * Simplify null checks in equality operators (remove unnecessary casts). * Inline XML documentation from docs/api/UIKit/UIFont.xml include directive. * Remove inlined content from docs/api/UIKit/UIFont.xml. * Improve XML documentation comments: remove 'To be added.' placeholders, remove empty value/returns/remarks elements, fix formatting (remove extra whitespace), add proper descriptions for all parameters/returns, add 'see cref' references, add exception documentation. * Add XML documentation for UIFontWeightExtensions class and GetWeight method. Contributes towards #17285.
There was a problem hiding this comment.
Pull request overview
This PR enables nullable reference types in the UIFont class as part of a broader effort to add nullability to UIKit (file 9 of 30 files). The changes modernize the codebase by adding proper nullable annotations, improving XML documentation, and cleaning up code.
Changes:
- Enabled
#nullable enablefor UIFont.cs and added nullable annotations to method return types and parameters - Added comprehensive XML documentation for UIFontWeightExtensions class and UIFont class, including detailed examples for font customization
- Simplified equality operator implementations by removing unnecessary casts
- Inlined XML documentation from external file and improved documentation quality throughout
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/UIKit/UIFont.cs | Enabled nullability, added nullable return types for font factory methods, improved XML documentation with comprehensive examples, added documentation for UIFontWeightExtensions, simplified equality operators, and fixed a typo ("intiailization" → "initialization") |
| docs/api/UIKit/UIFont.xml | Removed file after inlining its content into the source code |
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 #74ce813] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #74ce813] 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 #74ce813] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #74ce813] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #74ce813] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #74ce813] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #74ce813] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
💻 [CI Build #74ce813] 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 #74ce813] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 126 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
The Xamarin.iOS SDK 26.2.11422-net11-p2 enabled #nullable on UIFont (dotnet/macios#24637), changing return types to UIFont? for factory methods like SystemFontOfSize, FromDescriptor, FromName, and WithSize. This caused CS8600-CS8604 errors in dotnet cake builds. - EmbeddedFontLoader.iOS.cs: null-check name before UIFont.FromName - FontManager.iOS.cs: use ?? DefaultFont fallbacks for SystemFontOfSize and FromDescriptor; null-check CleanseFontName result; single ! on DefaultFont property (unavoidable bootstrap for non-null UIFont seed) - PickerHandler.iOS.cs: safe cast UIPickerView.Model with as + null guard - MauiTextView.cs: fallback to existing _placeholderLabel.Font Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This is file 9 of 30 files with nullability disabled in UIKit.
Contributes towards #17285.