[introspection] Enable nullability.#25110
Conversation
And fix any errors/warnings. Contributes towards #17285.
There was a problem hiding this comment.
Pull request overview
Enables C# nullable reference types in the introspection test suite and updates signatures/usages to address resulting warnings, supporting the broader effort to improve nullability annotations across the repo (ref #17285).
Changes:
- Switch multiple introspection test files from
#nullable disableto#nullable enable. - Update override signatures and various reflection/type accesses to be null-aware (
Type?,string?, null-conditional access). - Adjust a few call sites and local variables to satisfy NRT analysis (including some added null-forgiving operators).
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/introspection/MacApiSelectorTest.cs | Updates override signature to accept nullable declaredType. |
| tests/introspection/MacApiPInvokeTest.cs | Updates override signature to accept nullable libraryName. |
| tests/introspection/MacApiFieldTest.cs | Updates override signature to accept nullable libraryName. |
| tests/introspection/iOSApiWeakPropertyTest.cs | Enables nullability; uses null-conditional access on DeclaringType. |
| tests/introspection/iOSApiSignatureTest.cs | Enables nullability; uses null-conditional access for CurrentType/DeclaringType. |
| tests/introspection/iOSApiSelectorTest.cs | Enables nullability; makes declaredType null-tolerant in selector exception logic. |
| tests/introspection/iOSApiFieldTest.cs | Enables nullability; makes reflection/type accesses null-tolerant; updates Skip signature. |
| tests/introspection/CoreSelectorTest.cs | Enables nullability; adjusts selector test logic and reflection ctor usage. |
| tests/introspection/ApiWeakPropertyTest.cs | Enables nullability; updates error out param nullability and reflection member access patterns. |
| tests/introspection/ApiTypoTest.cs | Enables nullability; updates helper signatures and locals for NRT. |
| tests/introspection/ApiTypeTest.cs | Enables nullability; adjusts list additions for nullable FullName. |
| tests/introspection/ApiSignatureTest.cs | Enables nullability; updates parsing helpers and multiple reflection/type checks for NRT. |
| tests/introspection/ApiSelectorTest.cs | Enables nullability; updates method-implementation detection and selector extraction for NRT. |
| tests/introspection/ApiPInvokeTest.cs | Enables nullability; updates P/Invoke validation logic and library-name handling for NRT. |
| tests/introspection/ApiFrameworkTest.cs | Enables nullability; updates namespace skip logic to accept nullable namespaces. |
| tests/introspection/ApiFieldTest.cs | Enables nullability; updates constant/library skip hooks and notification checks for nullable declaring types. |
| tests/introspection/ApiCtorInitTest.cs | Enables nullability; updates ctor testing logic and exception unwrapping for NRT. |
| tests/introspection/ApiCoreImageFiltersTest.cs | Enables nullability; updates filter binding generation code and null-handling. |
| tests/introspection/ApiClassPtrTest.cs | Enables nullability; updates [Register] handling and reflection reads for NRT. |
| tests/introspection/ApiBaseTest.cs | Enables nullability; updates params arrays and a few fields/properties to be nullable-aware. |
Comments suppressed due to low confidence (1)
tests/introspection/ApiPInvokeTest.cs:274
- If
dladdrreturns a nulldli_fname, passing an empty string intoResolveLibrarySymlinkswill produce a meaningless "resolved" path and may lead to confusing mismatch errors. Consider handling the null case explicitly (e.g., report/skip whenMarshal.PtrToStringAuto (info.dli_fname)is null) instead of using?? "".
var dllImportPath = ResolveLibrarySymlinks (path);
var foundLibrary = ResolveLibrarySymlinks (Marshal.PtrToStringAuto (info.dli_fname) ?? "");
if (Skip (name, ref dllImportPath, ref foundLibrary)) {
// Skipped
} else if (foundLibrary != dllImportPath) {
ReportError ($"Found the symbol '{name}' in the library '{foundLibrary}', but the P/Invoke {t.FullName}.{m.Name} in {a.GetName ().Name} claims it's in '{dllimport.Value}'.");
✅ [CI Build #b549927] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #b549927] 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 #b549927] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #b549927] 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 errors/warnings.
Contributes towards #17285.