[src] Add missing nullability to strongly-typed dictionary parameters - #26377
[src] Add missing nullability to strongly-typed dictionary parameters#26377rolfbjarne wants to merge 1 commit into
Conversation
Several public APIs bind a native optional NSDictionary as a strongly-typed dictionary parameter, but the parameter itself was missing the "?" nullability annotation even though the code already handled null (via `param?.Dictionary`) and the underlying native API is `_Nullable` / `[NullAllowed]`. Fixed: * CGContextPDF.BeginTag (CGPdfTagProperties) * CIContext ctor (CIContextOptions) * CIImage.FromProvider + CIImage ctor (CIImageProviderOptions) * UNNotificationAttachment.FromIdentifier (UNNotificationAttachmentOptions) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR tightens nullable reference annotations for several public APIs that accept optional native dictionaries, aligning the C# signatures with existing null-handling (options?.Dictionary) and the underlying native _Nullable/[NullAllowed] contracts. It also replaces placeholder XML docs for the affected APIs and removes now-documented members from the cecil documentation known-failures list.
Changes:
- Add
?nullability annotations to strongly-typed dictionary parameters in a few public API entry points. - Replace placeholder XML documentation with meaningful docs for the affected APIs (including
CGContextPDF.BeginTagoverloads). - Update cecil documentation known-failures by removing entries for
CGContextPDF.BeginTagnow that docs exist.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/cecil-tests/Documentation.KnownFailures.txt | Removes CGContextPDF.BeginTag entries now that the APIs are documented. |
| src/UserNotifications/UNNotificationAttachment.cs | Makes attachment options nullable and documents the convenience wrapper. |
| src/CoreImage/CIImage.cs | Makes provider options nullable for FromProvider/ctor and fills in XML docs. |
| src/CoreImage/CIContext.cs | Makes CIContextOptions parameter nullable in the public ctor and updates docs accordingly. |
| src/CoreGraphics/CGContextPDF.cs | Adds XML docs and makes CGPdfTagProperties overload nullable (but see review note about the NSDictionary overload). |
| /// <param name="tagProperties">A dictionary of properties for the tag, or <see langword="null" /> if there are none.</param> | ||
| /// <remarks>Every call to <c>BeginTag</c> must be balanced by a matching call to <see cref="EndTag" />.</remarks> |
✅ 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 #6078ae0] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 43 tests failed, 160 tests passed. Failures❌ dotnettests tests (iOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (macOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (tvOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (iOS)19 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (tvOS)19 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ msbuild tests1 tests failed, 1 tests passed.Failed tests
Html Report (VSDrops) Download ❌ windows tests1 tests failed, 2 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ assembly-processing: 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 |
Several public APIs bind a native optional NSDictionary as a strongly-typed dictionary parameter, but the C# parameter itself was missing the
?nullability annotation. In every case the code already handled null (viaparam?.Dictionary) and the underlying native API is_Nullable/[NullAllowed], so the missing annotation was simply an oversight that surfaced unnecessary nullable-context warnings for callers passingnull.Adding the annotation is not a breaking change: it only makes the parameter more permissive, so existing callers keep compiling.
Fixed parameters:
CGContextPDF.BeginTag(CGPdfTagProperties)CIContextconstructor (CIContextOptions)CIImage.FromProviderand theCIImageconstructor (CIImageProviderOptions)UNNotificationAttachment.FromIdentifier(UNNotificationAttachmentOptions)While here, the placeholder XML docs on these APIs were filled in (and the two
CGContextPDF.BeginTagoverloads, previously undocumented, were documented and dropped from the cecil-tests documentation known-failures list).I deliberately did not touch
CVPixelFormatDescription.Register: its native API is__nonnull(the siblingNSDictionaryoverload throws on null), so its parameter is correctly non-nullable.🤖 Pull request created by Copilot