Repository navigation
[src] Add missing nullability to strongly-typed dictionary parameters - #26377
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). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Address PR review feedback: the CGContextPDF.BeginTag(CGPdfTagType,NSDictionary) overload's tagProperties parameter was still non-nullable even though its docs say null is allowed and the native CGPDFContextBeginTag parameter is _Nullable. GetHandle() already returns NativeHandle.Zero for null, so passing null is safe. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
✅ 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 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #16a5fef] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 203 tests passed 🎉 Tests counts✅ 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