Repository navigation
[iOS] Suppress IL2026 trim warnings on HybridWebViewHandler nested classes #35262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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.")] | ||
| private sealed class WebViewScriptMessageHandler : NSObject, IWKScriptMessageHandler | ||
| { | ||
| private readonly WeakReference<HybridWebViewHandler?> _webViewHandler; | ||
|
|
@@ -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.")] | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"
Flagged by: 2/3 reviewers |
||
| private class SchemeHandler : NSObject, IWKUrlSchemeHandler | ||
| { | ||
| private readonly WeakReference<HybridWebViewHandler?> _webViewHandler; | ||
|
|
||
There was a problem hiding this comment.
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 insideSchemeHandlerthat does not flow through the existing annotated paths, the real IL2026 would be hidden.Consider adding a clarifying comment:
Flagged by: 3/3 reviewers