[bgen] Enable nullability everywhere.#25023
Conversation
And fix any resulting issues. Also add a convenience make target to build bgen.
There was a problem hiding this comment.
Pull request overview
This PR enables nullable reference types across the bgen tool and adjusts the generator/tooling code to compile cleanly under #nullable enable, while also adding Makefile convenience targets to build/install bgen (part of the work toward #17285).
Changes:
- Enabled
#nullable enablein key bgen sources and updated signatures/annotations to reflect nullability. - Added/refactored helper APIs (e.g.,
TryCanRead/TryCanWrite/TryIsArray/...,GetOne*Attributehelpers) to reduce nullable warnings and tighten invariants. - Added
bgen/install-bgentargets and factoredDOTNET_BGEN_TARGETSinsrc/Makefile.generator.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/bgen/TypeManager.cs | Updated nullability of type-formatting helpers and related APIs. |
| src/bgen/Nomenclator.cs | Adjusted attribute lookup to nullable result. |
| src/bgen/Models/TrampolineInfo.cs | Made trampoline parameter names nullable to satisfy nullable flow. |
| src/bgen/Models/MemberInformation.cs | Nullability fixes in member metadata processing/casts. |
| src/bgen/Models/AsyncMethodInfo.cs | Allowed nullable category extension type in ctor signature. |
| src/bgen/Generator.cs | Broad nullability enablement + many flow tweaks and new “GetOne*” helpers. |
| src/bgen/Filters.cs | Added explicit null checks for required attributes; adjusted method signature. |
| src/bgen/Extensions/StringExtensions.cs | Made casing helpers null-safe + added nullability annotations. |
| src/bgen/Extensions/ExtensionMethods.cs | Added reflection/type helper Try* methods and nullability changes. |
| src/bgen/Enums.cs | Nullability enablement and safer dictionary lookups. |
| src/bgen/BindingTouch.cs | Null-forgiving for temp dir after initialization flow. |
| src/bgen/Attributes.cs | Enabled nullability and made multiple attribute properties nullable. |
| src/bgen/AttributeManager.cs | Enabled nullability and added GetOneCustomAttribute helper. |
| src/Makefile.generator | Added bgen/install-bgen targets and split bgen targets variable. |
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.
The nullability changes accidentally dropped the 'virtual' keyword from GetCustomAttribute<T>, which broke Moq-based tests that mock this method. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
✅ [PR Build #f0eb34f] 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 #f0eb34f] Build passed (Build packages) ✅Pipeline on Agent |
✅ [CI Build #f0eb34f] Build passed (Build macOS tests) ✅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 #f0eb34f] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 156 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
And fix any resulting issues.
Also add a convenience make target to build bgen.
Contributes towards #17285.