Repository navigation
TodoApp.Uno: trim analysis warnings (IL2026/IL2104/IL2121) on browserwasm/ios/maccatalyst heads #534
Description
Summary
Now that #525/#524 (PR #533) fix the EventTriggerBehavior/UXAML0001 build failure and let TodoApp.Uno actually build on the browserwasm, ios, and maccatalyst heads for the first time in CI, those heads surface IL trim-analysis warnings that were previously masked by the earlier build failure:
warning IL2026: Using member 'System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' ... [Database/TodoItem.cs]
warning IL2026: Using member 'Microsoft.EntityFrameworkCore.DbContext.DbContext(DbContextOptions)' which has 'RequiresUnreferencedCodeAttribute' ... [Database/AppDbContext.cs]
warning IL2026: Using member 'Uno.Extensions.Hosting.IApplicationBuilder.Build()' ... [App.xaml.cs]
warning IL2026: Using member 'Uno.Extensions.ApplicationBuilderExtensions.NavigateAsync<TShell>(...)' ... [App.xaml.cs]
warning IL2026: Using member 'Uno.Extensions.HostBuilderExtensions.UseNavigation(...)' ... [App.xaml.cs]
warning IL2026: Using member 'Microsoft.Xaml.Interactivity.{EventTriggerBehavior,DataTriggerBehavior,CallMethodAction,ChangePropertyAction}...' - Uno.UI.SourceGenerators-generated BindableMetadata.g.cs
warning IL2104: Assembly '<various>' produced trim warnings (maccatalyst only - roll-up notices for System.Private.Xml, System.Private.CoreLib, CommunityToolkit.Datasync.Client, CommunityToolkit.WinUI.*, EF Core assemblies, Microsoft.Spatial)
warning IL2121: Unused 'UnconditionalSuppressMessageAttribute' for warning 'IL2026'/'IL2111' in Uno.UI.SourceGenerators-generated TodoListPage/Shell code (maccatalyst only)
CI run: https://github.com/CommunityToolkit/Datasync/actions/runs/29093946725 (todoapp-uno / browserwasm, todoapp-uno / ios-maccatalyst jobs)
Root cause
This is the exact same class of finding as #521 (fixed for the Avalonia/MAUI samples via PR #531): net10.0-ios/net10.0-maccatalyst/net10.0-browserwasm mark the project trimmable by default, so the IL trim analyzer runs during dotnet build - not just dotnet publish -p:PublishTrimmed=true. None of the flagged APIs are bugs in the sample:
- EF Core's
DbContext(DbContextOptions)constructor is explicitly documented as not fully trim-compatible (https://aka.ms/efcore-docs-trimming). System.Text.Json.JsonSerializer.Serialize<TValue>without aJsonTypeInfo/JsonSerializerContextis inherently reflection-based by design.- The
Uno.Extensions.Hosting/NavigationAPIs andMicrosoft.Xaml.Interactivitybehaviors are Uno's own framework surface, flagged by Uno's own source-generated code (BindableMetadata.g.cs), not sample code. - IL2121 is emitted against Uno.UI.SourceGenerators' own generated file (
TodoListPage_....cs), not sample code, and only appears onmaccatalyst.
As established in #521/#531: this repo's CI only ever runs dotnet build for these samples, never dotnet publish -p:PublishTrimmed=true, so trim analysis here is purely diagnostic noise with no functional consequence.
Suggested fix
Mirror PR #531's approach: add <SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings> to samples/todoapp/TodoApp.Uno/TodoApp.Uno/TodoApp.Uno.csproj, scoped to the affected TFMs (net10.0-browserwasm, net10.0-ios, net10.0-maccatalyst) via the same GetTargetPlatformIdentifier-conditional pattern used in TodoApp.MAUI.csproj. Confirm whether android/desktop/windows need the same treatment (they didn't surface these warnings in the CI run linked above, but that may depend on the exact SDK/workload combination).
Related
- IL2026/IL2104 trim analysis warnings on TodoApp.Avalonia.iOS build #521 / fix: suppress IL2026/IL2104 trim analysis warnings on mobile TodoApp samples #531 - same finding, same fix pattern, applied to the Avalonia/MAUI samples.
- Major-version bump: Uno Platform 5 -> 6 (TodoApp.Uno sample) #524 / TodoApp.Uno fails to build on Skia heads: EventTriggerBehavior could not be found #525 / Investigate resolving NU1903 for System.Security.Cryptography.Xml in Uno browserwasm sample head #526 / fix: resolve TodoApp.Uno Skia build failures and bump Uno Platform 5 -> 6 #533 - fixed the build failures that were previously masking this on
TodoApp.Uno.
Activity
fix: suppress IL2026/IL2104/IL2121 trim analysis warnings on TodoApp.…
fix: suppress WASM0001 sqlite3_config/db_config varargs warnings on T…
fix: suppress WASM0001 sqlite3_config/db_config varargs warnings on T…