close
Skip to content

[introspection] Enable nullability.#25110

Merged
rolfbjarne merged 1 commit into
mainfrom
dev/rolf/tests-introspection-nullability
Apr 8, 2026
Merged

[introspection] Enable nullability.#25110
rolfbjarne merged 1 commit into
mainfrom
dev/rolf/tests-introspection-nullability

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

And fix any errors/warnings.

Contributes towards #17285.

And fix any errors/warnings.

Contributes towards #17285.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 disable to #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 dladdr returns a null dli_fname, passing an empty string into ResolveLibrarySymlinks will produce a meaningless "resolved" path and may lead to confusing mismatch errors. Consider handling the null case explicitly (e.g., report/skip when Marshal.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}'.");

Comment thread tests/introspection/ApiClassPtrTest.cs
Comment thread tests/introspection/ApiCoreImageFiltersTest.cs
Comment thread tests/introspection/ApiCoreImageFiltersTest.cs
Comment thread tests/introspection/CoreSelectorTest.cs
Comment thread tests/introspection/ApiCtorInitTest.cs
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [CI Build #b549927] Build passed (Build packages) ✅

Pipeline on Agent
Hash: b549927568dc1b917000a689ee5e4bdbb697013c [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

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

Pipeline on Agent
Hash: b549927568dc1b917000a689ee5e4bdbb697013c [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
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: b549927568dc1b917000a689ee5e4bdbb697013c [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [CI Build #b549927] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: b549927568dc1b917000a689ee5e4bdbb697013c [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne enabled auto-merge (squash) April 8, 2026 14:13
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [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
✅ 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. Html Report (VSDrops) Download
✅ introspection: All 6 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 12 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 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

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: b549927568dc1b917000a689ee5e4bdbb697013c [PR build]

@rolfbjarne rolfbjarne merged commit 4793568 into main Apr 8, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants