Repository navigation
Description
Description
[FeatureGuard(typeof(RequiresDynamicCodeAttribute))] + [FeatureSwitchDefinition] on a feature switch property correctly suppresses IL3050 warnings on all NativeAOT platforms except Android. The regression appeared between SDK builds 26166.111 and 26203.107.
Bisect
| SDK | dotnet/runtime SHA | Android AOT |
|---|---|---|
11.0.100-preview.3.26166.111 |
c38f37a3a1c3 |
✅ No IL3050 |
11.0.100-preview.3.26203.107 |
d23e53a91dcd |
❌ IL3050 emitted |
No MAUI code changed between these builds — only the SDK version bump (dotnet/maui#34852).
Root Cause: PR #124801
"Decouple ILC from ManagedAssemblyToLink" (15da4216aef1) landed between these two runtime SHAs. This PR:
- Removed
_ComputeManagedAssemblyForILLinkfromMicrosoft.NETCore.Native.targets - Changed
@(ManagedAssemblyToLink)construction from@(ManagedBinary)to@(IntermediateAssembly) - Was specifically made for Android NativeAOT where
RunILLink=true
The Android SDK (36.99.0-preview.3.10) already has a partial workaround referencing this PR (clearing _IlcManagedInputAssemblies), confirming it disrupted the Android NativeAOT pipeline. The IL3050 regression appears to be a residual effect.
Why Android-Only
| Platform | RunILLink |
Feature switch processing |
|---|---|---|
| iOS/macCatalyst/macOS | false |
ILC is the sole trimmer — applies --feature substitution directly ✅ |
| Android | true |
ILLink runs first, then ILC gets linked output. PR #124801 changed this flow ❌ |
On non-Android platforms, ILC reads all original assemblies and applies feature switches internally via --feature:Microsoft.Maui.RuntimeFeature.IsHybridWebViewSupported=false. This works correctly.
On Android (RunILLink=true), the decoupling in PR #124801 appears to have disrupted how RuntimeHostConfigurationOption items flow to ILC's --feature arguments, or ILC is now receiving a mix of linked/unlinked assemblies where the feature switch hasn't been substituted.
Reproduction
In dotnet/maui, RuntimeFeature.IsHybridWebViewSupported is configured with:
[FeatureSwitchDefinition]+[FeatureGuard(typeof(RequiresDynamicCodeAttribute))]- MSBuild:
MauiHybridWebViewSupported=falsewhenPublishAot=true, mapped toRuntimeHostConfigurationOptionwithTrim="true"
The guarded call site:
if (RuntimeFeature.IsHybridWebViewSupported)
{
AddHybridWebViewHandler(handlersCollection); // [RequiresDynamicCode]
}dotnet publish -r osx-arm64 -p:PublishAot=true → no IL3050 ✅
dotnet publish -r android-arm64 -p:PublishAot=true → IL3050 emitted ❌
Suggested Investigation
A binlog comparison between the two SDK versions would confirm the exact failure point:
- Are
--feature:flags present forIsHybridWebViewSupportedin ILC's command line on Android? - Does
@(ManagedAssemblyToLink)contain linked or unlinked Microsoft.Maui assemblies when ILC runs? - Did the
_IlcManagedInputAssembliesclearing workaround in the Android SDK affect ILC's analysis scope?
MAUI Workaround
Applied [UnconditionalSuppressMessage] on the helper method (dotnet/maui#34986), matching the pattern used by ServiceProvider in dotnet/runtime per dotnet/linker#2715.
Context
- AOT integration tests fail: unexpected IL3050 warnings for HybridWebViewHandler maui#34867 — original issue report
- Fix HybridWebView NativeAOT warning path maui#34958 — first fix attempt
- Move HybridWebView AOT helper from local function to private static method maui#34986 — current fix with
[UnconditionalSuppressMessage]workaround - ComputeIlcCompileInputs should not need to run before PrepareForILLink #124800 — issue that motivated PR Decouple ILC from ManagedAssemblyToLink #124801
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
dotnet-policy-service commentedon Apr 16, 2026
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.
[-][ILC] FeatureGuard does not suppress IL3050 for Android NativeAOT but works for other platforms[/-][+][ILC/Android NativeAOT] FeatureGuard does not suppress IL3050 after PR #124801 decoupled ILC from ManagedAssemblyToLink[/+]Revert HybridWebView AOT helper method changes
agocke commentedon Apr 21, 2026
@sbomer
AustinWise commentedon Apr 21, 2026
@PureWeen I see you @'ed me on this, but I am not sure what you want from me. I checked all the linked PRs, but I am not the author of them nor do I have any expertise on the IL linker area. Please let me know if there something specific I can do to help on this issue.
PureWeen commentedon Apr 21, 2026
No, sorry about that. Was trying to extract the right people out to help with this one and you got hallucinated into it.
Hook _PrepareTrimConfiguration to fix IL3050 on Android NativeAOT
Make PrepareTrimConfiguration a public extension point
Move feature switch defaults and RHCO items to static evaluation
[net11.0][NativeAOT] Hook _PrepareTrimConfiguration to fix IL3050 on …
sbomer commentedon Apr 27, 2026
Fixed in dotnet/maui#35094. But note that maui is relying on implementation details - setting RuntimeHostConfigurationOptions in targets is fragile: dotnet/maui#35163.