[tools] Enable nullability in the registrars.#24589
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request enables nullable reference types (#nullable enable) across the registrar codebase for .NET for iOS, macOS, tvOS, and Mac Catalyst. The PR is marked as "WIP WIP WIP" indicating it's a work in progress.
Changes:
- Enables nullability in registrar files (StaticRegistrar.cs, Registrar.cs, DynamicRegistrar.cs)
- Adds nullable annotations to method signatures and return types throughout the codebase
- Introduces explicit null checks and error handling where nullability was previously implicit
- Refactors constructors for ObjCType, ObjCField, ObjCProperty, and related classes to require non-null parameters
- Adds TryGetEnumUnderlyingType pattern alongside GetEnumUnderlyingType to handle null cases more explicitly
- Unifies DerivedLinkContext constructor signature across LEGACY_TOOLS and non-LEGACY_TOOLS builds
- Adds LinkerConfiguration parameter to Application constructor
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tools/mtouch/LinkerConfiguration.cs | New empty LinkerConfiguration class for LEGACY_TOOLS compatibility |
| tools/mtouch/mtouch.cs | Updated to pass LinkerConfiguration to Application constructor |
| tools/mtouch/mtouch.csproj | Added LinkerConfiguration.cs to compilation |
| tools/dotnet-linker/LinkerConfiguration.cs | Removed Application(LinkerConfiguration) constructor, moved to Application.cs |
| tools/dotnet-linker/Compat.cs | Removed duplicate Application constructor |
| tools/dotnet-linker/Steps/ManagedRegistrarStep.cs | Added null checks for BindAsAttribute.OriginalType and constrained types |
| tools/linker/MobileExtensions.cs | Added nullable annotations to DerivedLinkContext parameters |
| tools/common/Target.cs | Made LinkContext non-nullable for non-LEGACY_TOOLS, simplified GetLinkContext() |
| tools/common/Application.cs | Updated constructor to take LinkerConfiguration and initialize LinkContext for non-LEGACY_TOOLS |
| tools/common/DerivedLinkContext.cs | Unified constructor to always take LinkerConfiguration parameter |
| tools/common/StaticRegistrar.cs | Major nullability enablement with comprehensive nullable annotations and null checks |
| tools/common/ErrorHelper.tools.cs | Added nullable annotations to all error creation methods |
| src/ObjCRuntime/Registrar.cs | Core registrar with full nullable annotations, new TryGetEnumUnderlyingType method, updated constructors |
| src/ObjCRuntime/Registrar.core.cs | Added NotNullIfNotNull attributes and null-safety checks to helper methods |
| src/ObjCRuntime/DynamicRegistrar.cs | Full nullable annotations, TryGetEnumUnderlyingType implementation |
| src/ObjCRuntime/Class.cs | Added null-forgiving operator for Marshal.PtrToStringAuto |
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.
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 #18c16b0] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #18c16b0] 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 #18c16b0] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #18c16b0] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #18c16b0] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #18c16b0] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
💻 [CI Build #18c16b0] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #18c16b0] 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.
🚀 [CI Build #18c16b0] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 124 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
No description provided.