Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ protected override void DisconnectHandler(WKWebView platformView)
#if !NETSTANDARD
[RequiresDynamicCode(DynamicFeatures)]
#endif
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The iOS Managed Registrar references this NSObject subclass in <Module>..cctor(). The RequiresUnreferencedCode is for callers instantiating this type, not for the registrar's type registration.")]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🟡 MODERATE — Type-level suppression scope is broader than necessary (3/3 reviewers)

[UnconditionalSuppressMessage] on a type suppresses ALL IL2026 warnings from within that type — not just the managed registrar's <Module>..cctor() reference. While harmless today (the existing [RequiresUnreferencedCode] on these types already covers member-level warnings), this creates a silent-failure trap: if someone later adds a new trim-unsafe call inside SchemeHandler that does not flow through the existing annotated paths, the real IL2026 would be hidden.

Consider adding a clarifying comment:

// Suppresses IL2026 from the iOS Managed Registrar's <Module>..cctor() which
// references this NSObject subclass for ObjC type registration but never invokes
// the dynamic serialization code paths. Note: this also suppresses any IL2026
// from within this type's methods — [RequiresUnreferencedCode] on the type
// already propagates to all members, so this is safe for existing code.

Flagged by: 3/3 reviewers

private sealed class WebViewScriptMessageHandler : NSObject, IWKScriptMessageHandler
{
private readonly WeakReference<HybridWebViewHandler?> _webViewHandler;
Expand All @@ -149,6 +150,7 @@ public void DidReceiveScriptMessage(WKUserContentController userContentControlle
#if !NETSTANDARD
[RequiresDynamicCode(DynamicFeatures)]
#endif
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The iOS Managed Registrar references this NSObject subclass in <Module>..cctor(). The RequiresUnreferencedCode is for callers instantiating this type, not for the registrar's type registration.")]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🟢 MINOR — Justification text is technically inaccurate (2/3 reviewers)

The justification says: "The RequiresUnreferencedCode is for callers instantiating this type"

[RequiresUnreferencedCode] on a type propagates to all members (constructors, methods, properties), not just instantiation. A more precise justification would be:

"The iOS Managed Registrar references this NSObject subclass in <Module>..cctor() for ObjC type registration only. The [RequiresUnreferencedCode] covers the dynamic JSON serialization code paths (System.Text.Json), which the registrar does not invoke."

Flagged by: 2/3 reviewers

private class SchemeHandler : NSObject, IWKUrlSchemeHandler
{
private readonly WeakReference<HybridWebViewHandler?> _webViewHandler;
Expand Down
Loading