You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AOT integration tests fail: unexpected IL3050 warnings for HybridWebViewHandlerΒ #34867
The PublishNativeAOTRootAllMauiAssemblies and PublishNativeAOT integration tests fail on Android (net11.0-android) because the expected warnings baseline doesn't include new IL3050 warnings from HybridWebViewHandler.
Error
Unexpected warning messages detected for the expected warnings file path 'ILC' and warning code 'IL3050'!
Unexpected warning messages are:
Microsoft.Maui.Controls.Hosting.AppHostBuilderExtensions.AddControlsHandlers(IMauiHandlersCollection):
Using member 'Microsoft.Maui.Handlers.HybridWebViewHandler.HybridWebViewHandler()' which has
'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
HybridWebView uses dynamic System.Text.Json serialization features.
Microsoft.Maui.Controls.Hosting.AppHostBuilderExtensions.AddControlsHandlers(IMauiHandlersCollection):
Using member 'Microsoft.Maui.Handlers.HybridWebViewHandler.HybridWebViewHandler(IPropertyMapper,CommandMapper)'
which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
HybridWebView uses dynamic System.Text.Json serialization features.
Fails on both Windows and macOS AOT integration test jobs.
Repro
Observed on release/11.0.1xx-preview3 and net11.0 branches with Android SDK 36.99.0-preview.3.10.
Expected Fix
Update the expected warnings baseline in the AOT integration tests to include these IL3050 warnings for HybridWebViewHandler, or suppress the warning on the HybridWebViewHandler constructors.
The HybridWebViewHandler class is already annotated with [RequiresDynamicCode] and its registration in AddControlsHandlers is guarded by a [FeatureSwitchDefinition] feature switch:
// src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs:123if(RuntimeFeature.IsHybridWebViewSupported){// NOTE: not registered under NativeAOT or TrimMode=Full scenarioshandlersCollection.AddHandler<HybridWebView,HybridWebViewHandler>();}
The ILC linker will trim this code path when IsHybridWebViewSupported is false (which it is under NativeAOT/full trim). However, ILC still reports the IL3050 warning during analysis before applying the trim β so the warning is effectively a false positive for the trimmed output.
Fix Options
Option 1: Suppress at the call site (preferred)
Add [UnconditionalSuppressMessage] to AddControlsHandlers since the feature switch already guards the call:
[UnconditionalSuppressMessage("AOT","IL3050:RequiresDynamicCode",Justification="HybridWebViewHandler registration is guarded by RuntimeFeature.IsHybridWebViewSupported feature switch, which is disabled under NativeAOT/TrimMode=Full.")]
This addresses the warning at its source rather than accepting it.
Option 2: Update expected warnings baseline
Add the two HybridWebViewHandler messages to ExpectedNativeAOTWarningsAndroid in BuildWarningsUtilities.cs. This just accepts the warning without fixing it.
Recommendation
Option 1 is the proper fix β the feature switch already ensures the code is trimmed, so suppressing the warning is correct and documenting why.
Suppressing the error is definitely not the right answer. Is it possible we enabled the RuntimeFeature.IsHybridWebViewSupported feature switch in a NativeAOT-enabled test? HWV won't work with Native AOT the way it is currently implemented (arbitrary JSON serialization/deserialization)
Closed by #34958 (merged to net11.0). GitHub only auto-closes for PRs merged to the default branch; this issue was fixed by a PR merged to a non-default branch.
Activity
PureWeen commentedon Apr 9, 2026
Analysis
The
HybridWebViewHandlerclass is already annotated with[RequiresDynamicCode]and its registration inAddControlsHandlersis guarded by a[FeatureSwitchDefinition]feature switch:The ILC linker will trim this code path when
IsHybridWebViewSupportedisfalse(which it is under NativeAOT/full trim). However, ILC still reports theIL3050warning during analysis before applying the trim β so the warning is effectively a false positive for the trimmed output.Fix Options
Option 1: Suppress at the call site (preferred)
Add
[UnconditionalSuppressMessage]toAddControlsHandlerssince the feature switch already guards the call:This addresses the warning at its source rather than accepting it.
Option 2: Update expected warnings baseline
Add the two
HybridWebViewHandlermessages toExpectedNativeAOTWarningsAndroidinBuildWarningsUtilities.cs. This just accepts the warning without fixing it.Recommendation
Option 1 is the proper fix β the feature switch already ensures the code is trimmed, so suppressing the warning is correct and documenting why.
simonrozsival commentedon Apr 10, 2026
Suppressing the error is definitely not the right answer. Is it possible we enabled the
RuntimeFeature.IsHybridWebViewSupportedfeature switch in a NativeAOT-enabled test? HWV won't work with Native AOT the way it is currently implemented (arbitrary JSON serialization/deserialization)Add Trim/NativeAOT safety rules to code review skill
Fix HybridWebView NativeAOT warning path (#34958)
PureWeen commentedon Jun 10, 2026
Closed by #34958 (merged to
net11.0). GitHub only auto-closes for PRs merged to the default branch; this issue was fixed by a PR merged to a non-default branch.[AOT] Make HybridWebView AOT safe using source generator (#35626)
Add Trim/NativeAOT safety rules to code review skill
Add Trim/NativeAOT safety rules to code review skill
Add Trim/NativeAOT safety rules to code review skill
Add Trim/NativeAOT safety rules to code review skill