-
Notifications
You must be signed in to change notification settings - Fork 1.9k
MauiXamlInflator break communitytoolkit.mvvm's source generator in iOS release aot mode #33489
Description
Description
https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/generators/overview
Some background:
My app already used communitytoolkit.mvvm‘s source generator in .net9, then I update the app to .net10 and config MauiXamlInflator.
When I want to publish to app store, but the build show the warning and all the binding were gone after run the app:
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.
Steps to Reproduce
- Open the app using vscode
- Set the debug mode to "Release"
- Run to the device(my device is iphone12 ios 26.2)
Expect:
All text should be hidden.
Click the button should show the text.
Actual:
All text will be shown.
Click the button do not show/hide the text.
Link to public reproduction project repository
https://github.com/jingliancui/MauiXamlInflatorIssue
Version with bug
10.0.20
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
Did you find any workaround?
remove below config:
<PropertyGroup>
<MauiXamlInflator>SourceGen</MauiXamlInflator>
</PropertyGroup>
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.12.15-darwin-arm64/dist/resources/Custom.After.Microsoft.CSharp.targets -p:MauiVSCodeBuildOutputFile=/var/folders/81/70kf_yv12x1c7nrdnd3m6vrw0000gn/T/dotnet-maui/maui-vsc-5f8d2af3-e04b-4231-a219-a8c4c4c881c3.json -p:MauiTargetProject=/Users/ericcui/Desktop/releaseissue/SampleApp/SampleApp.csproj -p:XamlTools=/Users/ericcui/.vscode/extensions/ms-dotnettools.csharp-2.110.4-darwin-arm64/.xamlTools -p:EnableDiagnostics=True -p:EnableMauiXamlDiagnostics=True /Users/ericcui/Desktop/releaseissue/SampleApp/SampleApp.csproj
SampleApp net10.0-ios ios-arm64 succeeded with 2 warning(s) (151.2s) → bin/Release/net10.0-ios/ios-arm64/SampleApp.dll
/Users/ericcui/Desktop/releaseissue/SampleApp/obj/Release/net10.0-ios/ios-arm64/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.XamlGenerator/MainPage.xaml.xsg.cs(82,21): 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.
/Users/ericcui/Desktop/releaseissue/SampleApp/obj/Release/net10.0-ios/ios-arm64/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.XamlGenerator/MainPage.xaml.xsg.cs(109,22): 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 2 warning(s) in 151.3s
* Terminal will be reused by tasks, press any key to close it.