Description
Dotnet 10 introduce MauiXamlInflator for performance improvement.
But it will break the Relative bindings under AOT in release mode.
https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/data-binding/relative-bindings?view=net-maui-10.0#bind-to-an-ancestor
Steps to Reproduce
- Open the sampleapp using vscode
- Set the debugging mode to release
- Run the app in device (my device is iPhone12 iOS 26.2.1)
- Click any button in the app
Expect:
Popup will be shown
Actual:
Nothing happen
Other info:
- add config MauiXamlInflator and AOT will build with this warning
/Users/ericcui/Desktop/issue/SampleApp/obj/Release/net10.0-ios/ios-arm64/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.XamlGenerator/MainPage.xaml.xsg.cs(93,23): warning IL2026: Using member 'Microsoft.Maui.Controls.Binding.Binding(String, BindingMode, IValueConverter, Object, String, Object)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Using bindings with string paths is not trim safe. Use expression-based binding instead.
2.remove config MauiXamlInflator in csproj will run fine in release mode.
3.nothing build warning will be shown in debug mode, which will cause issue in release stage, so suggest show something in debug stage.
4.Not sure if this issue will help for those issues or not:
#26509
#22368
#24949
Link to public reproduction project repository
https://github.com/jingliancui/MauiXamlInflatorAOTIssue
Version with bug
10.0.40
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 26.2.1
Did you find any workaround?
Remove config MauiXamlInflator in csproj
Relevant log output
* Executing task: dotnet build -t:Build -p:Configuration=Release -f net10.0-ios -r ios-arm64 -p:CustomAfterMicrosoftCSharpTargets=/Users/ericcui/.vscode/extensions/ms-dotnettools.dotnet-maui-1.13.20-darwin-arm64/dist/resources/Custom.After.Microsoft.CSharp.targets -p:MauiVSCodeBuildOutputFile=/var/folders/81/70kf_yv12x1c7nrdnd3m6vrw0000gn/T/dotnet-maui/maui-vsc-eefb5af8-8e34-49c5-a142-120be62048c3.json -p:MauiTargetProject=/Users/ericcui/Desktop/issue/SampleApp/SampleApp.csproj -p:XamlTools=/Users/ericcui/.vscode/extensions/ms-dotnettools.csharp-2.120.3-darwin-arm64/.xamlTools -p:EnableDiagnostics=True -p:EnableMauiXamlDiagnostics=True /Users/ericcui/Desktop/issue/SampleApp/SampleApp.csproj
SampleApp net10.0-ios ios-arm64 succeeded with 1 warning(s) (140.7s) → bin/Release/net10.0-ios/ios-arm64/SampleApp.dll
/Users/ericcui/Desktop/issue/SampleApp/obj/Release/net10.0-ios/ios-arm64/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.XamlGenerator/MainPage.xaml.xsg.cs(93,23): warning IL2026: Using member 'Microsoft.Maui.Controls.Binding.Binding(String, BindingMode, IValueConverter, Object, String, Object)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Using bindings with string paths is not trim safe. Use expression-based binding instead.
Build succeeded with 1 warning(s) in 140.8s
* Terminal will be reused by tasks, press any key to close it.
Description
Dotnet 10 introduce
MauiXamlInflatorfor performance improvement.But it will break the Relative bindings under AOT in release mode.
https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/data-binding/relative-bindings?view=net-maui-10.0#bind-to-an-ancestor
Steps to Reproduce
Expect:
Popup will be shown
Actual:
Nothing happen
Other info:
/Users/ericcui/Desktop/issue/SampleApp/obj/Release/net10.0-ios/ios-arm64/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.XamlGenerator/MainPage.xaml.xsg.cs(93,23): warning IL2026: Using member 'Microsoft.Maui.Controls.Binding.Binding(String, BindingMode, IValueConverter, Object, String, Object)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Using bindings with string paths is not trim safe. Use expression-based binding instead.2.remove config MauiXamlInflator in csproj will run fine in release mode.
3.nothing build warning will be shown in debug mode, which will cause issue in release stage, so suggest show something in debug stage.
4.Not sure if this issue will help for those issues or not:
#26509
#22368
#24949
Link to public reproduction project repository
https://github.com/jingliancui/MauiXamlInflatorAOTIssue
Version with bug
10.0.40
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 26.2.1
Did you find any workaround?
Remove config MauiXamlInflator in csproj
Relevant log output