Skip to content

[UIKit] Enable nullability and clean up UIFont.#24637

Merged
rolfbjarne merged 3 commits intomainfrom
dev/rolf/uikit-nullability-uifont-09
Feb 9, 2026
Merged

[UIKit] Enable nullability and clean up UIFont.#24637
rolfbjarne merged 3 commits intomainfrom
dev/rolf/uikit-nullability-uifont-09

Conversation

@rolfbjarne
Copy link
Member

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.

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.
Copy link
Contributor

Copilot AI left a 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 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 enable for 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

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne enabled auto-merge (squash) February 6, 2026 08:00
@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #74ce813] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 74ce813cb44bd0b56b975e307ff9257ad315b4f0 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #74ce813] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 74ce813cb44bd0b56b975e307ff9257ad315b4f0 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 74ce813cb44bd0b56b975e307ff9257ad315b4f0 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #74ce813] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 74ce813cb44bd0b56b975e307ff9257ad315b4f0 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #74ce813] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: 74ce813cb44bd0b56b975e307ff9257ad315b4f0 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #74ce813] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 74ce813cb44bd0b56b975e307ff9257ad315b4f0 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #74ce813] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 74ce813cb44bd0b56b975e307ff9257ad315b4f0 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #74ce813] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 74ce813cb44bd0b56b975e307ff9257ad315b4f0 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #74ce813] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: 74ce813cb44bd0b56b975e307ff9257ad315b4f0 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [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
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. [attempt 4] Html Report (VSDrops) Download
✅ linker: All 44 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (iOS): All 9 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 74ce813cb44bd0b56b975e307ff9257ad315b4f0 [PR build]

@rolfbjarne rolfbjarne merged commit 4eaa3b7 into main Feb 9, 2026
47 checks passed
PureWeen added a commit to dotnet/maui that referenced this pull request Feb 24, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants