Skip to content

chore: Fix many trimmer warnings in src/Uno.UI - #21920

Merged
jonpryor merged 1 commit into
masterfrom
dev/jonpryor/jonp-Uno.UI-trimmer-warnings-1
Dec 3, 2025
Merged

jonpryor merged 1 commit into
masterfrom
dev/jonpryor/jonp-Uno.UI-trimmer-warnings-1

Conversation

@jonpryor

@jonpryor jonpryor commented Nov 21, 2025 •

Copy link
Copy Markdown
Contributor

Context: https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming
Context: https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot#aot-compatibility-analyzers
Context: https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options
Context: 10480ec
Context: 408e177
Context: dotnet/android#7473
Context: dotnet/android@6836818

Enable $(IsAotCompatible)=true for the following projects:

  • src/Uno.Foundation/Uno.Foundation.csproj
  • src/Uno.Foundation/Uno.Foundation.netcoremobile.csproj
  • src/Uno.Foundation/Uno.Foundation.Reference.csproj
  • src/Uno.Foundation/Uno.Foundation.Skia.csproj
  • src/Uno.Foundation/Uno.Foundation.Wasm.csproj
  • src/Uno.UI/Uno.UI.Skia.csproj

Address the following warnings:

src/Uno.UI/DataBinding/BindingPropertyHelper.MemberBinder.cs(13,60): error IL3050:
  Using member 'System.Dynamic.GetMemberBinder.GetMemberBinder(String, Boolean)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
  Creating a call site may require dynamic code generation.
src/Uno.UI/DataBinding/BindingPropertyHelper.MemberBinder.cs(22,60): error IL3050:
  Using member 'System.Dynamic.SetMemberBinder.SetMemberBinder(String, Boolean)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
  Creating a call site may require dynamic code generation.

Add [RequiresDynamicCodeAttribute] to the specified types.

Fix the following warnings:

src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2WebMessageReceivedEventArgs.cs(61,70): error IL2026:
  Using member 'System.Text.Json.Serialization.Metadata.JsonTypeInfo.CreateJsonTypeInfo<T>(JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code.
  JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation.
  Use System.Text.Json source generation for native AOT applications.
src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2WebMessageReceivedEventArgs.cs(61,70): error IL3050:
  Using member 'System.Text.Json.Serialization.Metadata.JsonTypeInfo.CreateJsonTypeInfo<T>(JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
  JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation.
  Use System.Text.Json source generation for native AOT applications.
src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2WebMessageReceivedEventArgs.cs(54,22): error IL2026:
  Using member 'System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.DefaultJsonTypeInfoResolver()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code.
  JSON serialization and deserialization might require types that cannot be statically analyzed.
  Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2WebMessageReceivedEventArgs.cs(54,22): error IL3050:
  Using member 'System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.DefaultJsonTypeInfoResolver()' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
  JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation.
  Use System.Text.Json source generation for native AOT applications.

@jonpryor was under the mistaken belief that commit 10480ec would be
sufficient to fix these warnings, and was wrong. Even though we
"only" need to turn JSON into a string, not a structure, do as
requested: use System.Text.Json source generation. (Which, again,
feels rather weird as only string is needed!)

[JsonSourceGenerationOptions]
[JsonSerializable(typeof(string))]
internal sealed partial class ExampleContext : JsonSerializerContext {}
// then use ExampleContext.Default.String to deserialize to string!

Fix the following warning:

src/Uno.UI/UI/Xaml/SpecializedResourceDictionary.cs(133,34): error IL3050:
  Using member 'System.Runtime.InteropServices.Marshal.SizeOf(Type)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
  Marshalling code for the object might not be available.
  Use the SizeOf<T> overload instead.

We could do as requested and use Marshal.SizeOf<IntPtr>(), but
the reason why Marshal.SizeOf() is used here is because of 408e177,
which was to workaround dotnet/android#7473. dotnet/android#7473 has
since been fixed in dotnet/android@68368189, meaning we don't actually
need to use Marshal.SizeOf() anymore. Use IntPtr.Size instead.

Suppress the following warning:

src/Uno.UI/UI/Xaml/Navigation/NavigationHistory.mux.cs(329,25): error IL2057:
  Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'.
  It's not possible to guarantee the availability of the target type.

TODO: investigate whether we can update PageStackEntry.m_descriptor
to have [DynamicallyAccessedMembers].

Suppress the following warnings:

src/Uno.UI/Extensions/ViewExtensions.visual-tree.cs(214,4): error IL2075:
  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'.
  The return value of method 'System.Object.GetType()' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI/UI/Xaml/FrameworkElementExtensions.cs(82,17): error IL2075:
  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Reflection.TypeInfo.GetDeclaredField(String)'.
  The return value of method 'System.Object.GetType()' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI/UI/Xaml/FrameworkElementExtensions.cs(82,17): error IL2075:
  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Reflection.TypeInfo.GetDeclaredField(String)'.
  The return value of method 'System.Type.BaseType.get' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI/UI/Xaml/FrameworkElementExtensions.cs(108,20): error IL2075:
  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.TypeInfo.GetDeclaredProperty(String)'.
  The return value of method 'System.Object.GetType()' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI/UI/Xaml/FrameworkElementExtensions.cs(108,20): error IL2075:
  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.TypeInfo.GetDeclaredProperty(String)'.
  The return value of method 'System.Type.BaseType.get' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI/UI/Xaml/FrameworkElementExtensions.cs(104,8): error IL2070:
  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Reflection.TypeInfo.GetDeclaredField(String)'.
  The parameter 'type' of method 'GetField(Type, String)' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI/UI/Xaml/FrameworkElementExtensions.cs(134,8): error IL2070:
  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.TypeInfo.GetDeclaredProperty(String)'.
  The parameter 'type' of method 'GetProperty(Type, String)' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI/DirectUI/PropertyPathStep.cs(502,16): error IL2072:
  'pSourceType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'DirectUI.ReflectionPropertyAccess.CreateInstance(IPropertyAccessHost, Object, Type, Boolean)'.
  The return value of method 'System.Object.GetType()' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI/UI/Xaml/Controls/Frame/Frame.legacy.cs(68,4): error IL2072:
  'value' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Microsoft.UI.Xaml.Navigation.PageStackEntry.SourcePageType.set'.
  The return value of method 'System.Object.GetType()' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI/UI/Xaml/Controls/NumberBox/NumberBoxParser.cs(93,20): error IL2072:
  'typeName' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.PublicEvents' in call to 'Windows.Foundation.Metadata.ApiInformation.IsTypePresent(String)'.
  The return value of method 'System.Object.GetType()' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.

As these callsites are all rooted in value.GetType().…, I can't
think of a way to appease NativeAOT here.

Suppress the following warnings:

C:\a\1\s\src\Uno.UI\obj\Uno.UI.netcoremobile\Release\net10.0-ios26.0\Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.DependencyObject.DependencyObjectGenerator\Microsoft.UI.Xaml.Navigation.PageStackEntry.cs(120,4): error IL2111:
  Method 'Microsoft.UI.Xaml.Navigation.PageStackEntry.PageStackEntry(Type, Object, NavigationTransitionInfo)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection.
  Trimmer can't guarantee availability of the requirements of the method.
C:\a\1\s\src\Uno.UI\obj\Uno.UI.netcoremobile\Release\net10.0-ios26.0\Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.DependencyObject.DependencyObjectGenerator\Microsoft.UI.Xaml.Navigation.PageStackEntry.cs(150,4): error IL2111:
  Method 'Microsoft.UI.Xaml.Navigation.PageStackEntry.PageStackEntry(Type, Object, NavigationTransitionInfo)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection.
  Trimmer can't guarantee availability of the requirements of the method.

These warnings appear to be unactionable: what are we supposed to do?
Like, okay then?

Update src/SourceGenerators so that the callsite suppressses these.

Address the following warnings:

src/Uno.UI/DirectUI/PropertyAccess.cs(1634,18): error IL2070:
  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'.
  The parameter 'pSourceType' of method 'DirectUI.ReflectionPropertyAccess.CreateInstance(IPropertyAccessHost, Object, Type, Boolean)' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI/DirectUI/MetadataAPI.cs(603,5): error IL2070:
  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'.
  The parameter 'type' of method 'DirectUI.MetadataAPI.TryGetDependencyPropertyByName(Type, String)' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI/UI/Xaml/Navigation/PageStackEntry.Properties.cs(32,10): error IL2073:
  'Microsoft.UI.Xaml.Navigation.PageStackEntry.SourcePageType.get' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' requirements.
  The return value of method 'Microsoft.UI.Xaml.Navigation.PageStackEntry.GetValue(DependencyProperty)' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Add the requested [DynamicallyAccessedMembers].

Suppress the following warning:

src/Uno.UI/UI/Xaml/Navigation/PageStackEntry.Properties.cs(41,3): error IL2111:
  Method 'Microsoft.UI.Xaml.Navigation.PageStackEntry.PageStackEntry(Type, Object, NavigationTransitionInfo)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection.
  Trimmer can't guarantee availability of the requirements of the method.

@jonpryor has no idea why this warning is appearing.

Address the following warning:

src/Uno.UI/Helpers/TypeMappings.cs(76,6): error IL2072:
  'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'System.Activator.CreateInstance(Type, params Object[])'.
  The return value of method 'Uno.UI.Helpers.TypeMappings.GetReplacementType(Type)' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Update the entire call hierarchy within this file so that Type
parameters and Type-returning methods all declare both
DynamicallyAccessedMemberTypes.PublicConstructors and
DynamicallyAccessedMemberTypes.PublicParameterlessConstructor.
The latter is needed for TypeMappings.CreateInstance<T>().

For the following warnings:

src/Uno.UI/UI/Xaml/Markup/Reader/XamlTypeResolver.cs(463,23): error IL2075:
  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperties()'.
  The return value of method 'System.Type.BaseType.get' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI/UI/Xaml/Markup/Reader/XamlTypeResolver.cs(474,23): error IL2075:
  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethods()'.
  The return value of method 'System.Type.BaseType.get' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Annotate the type parameter with [DynamicallyAccessedMembers].
(This doesn't touch Type.BaseType, but fixed the IL2075.)

Unfortunately, after addressing all of the above, non-trimmer
enabled builds start failing:

src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Common.cs(54,29): error IL2072:
  'mappedType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.UI.Helpers.TypeMappings.GetOriginalType(Type)'.
  The return value of method 'System.Object.GetType()' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Common.cs(85,30): error IL2072:
  'mappedType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.UI.Helpers.TypeMappings.GetOriginalType(Type)'.
  The return value of method 'System.Object.GetType()' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.MetadataUpdate.cs(526,6): error IL2072:
  'mappedType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.UI.Helpers.TypeMappings.RegisterMapping(Type, Type)'.
  The return value of method 'System.Collections.IEnumerator.Current.get' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.MetadataUpdate.cs(526,6): error IL2072:
  'originalType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.UI.Helpers.TypeMappings.RegisterMapping(Type, Type)'.
  The return value of method 'System.Reflection.CustomAttributeTypedArgument.Value.get' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.MetadataUpdate.cs(164,25): error IL2072:
  'mappedType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.UI.Helpers.TypeMappings.GetOriginalType(Type)'.
  The return value of method 'System.Object.GetType()' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.MetadataUpdate.cs(180,23): error IL2072:
  'originalType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.UI.Helpers.TypeMappings.GetMappedType(Type)'.
  The return value of method 'System.Object.GetType()' does not have matching annotations.
  The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Suppress these warnings.

Fix and suppress the following warning:

src/Uno.UI/ToolkitHelper.cs(12,20): error IL2057: Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'.
  It's not possible to guarantee the availability of the target type.

Fix this by updating all callsites to use an assembly-qualified name
instead of relying on ToolkitHelper.GetProperty() to do a string
concat before a Type.GetType() invocation. This along with
[DynamicallyAccessedMembers] on the typeName parameter should
allow NativeAOT to preserve the referenced types.

That doesn't actually remove the IL2057, though, so suppress it.

For compatibility, if the initial Type.GetType() fails, fallback
to appending ",Uno.UI.Toolkit" to the type name.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 184497 found UI Test snapshots differences: android-28-net9: 17, android-28-net9-Snap: 28, ios: 5, ios-Snap: 52, skia-linux-screenshots: 59, skia-windows-screenshots: 106, wasm: 93, wasm-automated-net10.0-WinUI-Benchmarks-automated: 0, wasm-automated-net10.0-WinUI-Default-automated: 13, wasm-automated-net10.0-WinUI-RuntimeTests-0: 1, wasm-automated-net10.0-WinUI-RuntimeTests-1: 0, wasm-automated-net10.0-WinUI-RuntimeTests-2: 0

Details
  • android-28-net9: 17 changed over 825

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Detereminate_ProgressRing_Validation50_[#FF0000_#008000_#008000_#FF0000]_Progress-Ring-Value-50
    • Detereminate_ProgressRing_Validation25_[#FF0000_#008000_#FF0000_#FF0000]_Progress-Ring-Value-25
    • FlyoutTest_When_NoOverlayInputPassThroughElement_Then_DontPassThrough_woOff_UITests_Shared_Windows_UI_Xaml_Controls_Flyout_Flyout_OverlayInputPassThroughElement
    • ListView_SelectedItems_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewSelectedItems
    • When_ExtendedSelectionWithoutItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • UpDownEnabledTest_UITests_Shared_Microsoft_UI_Xaml_Controls_NumberBoxTests_NumberBoxPage
    • When_Parent_PointerMoved_After_drag_on_non-scrolling_ScrollViewer
    • When_Parent_PointerMoved_After_drag_on_ScrollViewer_-_touch
    • When_NoSelectionWithItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • Detereminate_ProgressRing_Validation75_[#FF0000_#008000_#008000_#008000]_Progress-Ring-Value-75
    • NativeCommandBar_Size_Uno_UI_Samples_Content_UITests_CommandBar_CommandBar_Dynamic
    • When_SingleSelectionWithoutItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • When_SingleSelectionWithItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • ProgressRing_IsEnabled_Running_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • ProgressRing_Visibility_Collapsed_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • When_MultipleSelectionWithoutItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • DecimalFormatterTest_UITests_Shared_Microsoft_UI_Xaml_Controls_NumberBoxTests_NumberBoxPage
  • android-28-net9-Snap: 28 changed over 1077

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • TeachingTip_UITests_Microsoft_UI_Xaml_Controls_TeachingTipTests_TeachingTipPage_UITests_Microsoft_UI_Xaml_Controls_TeachingTipTests_TeachingTipPage
    • Scrolling_MUXControlsTestApp_ScrollViewWithScrollControllersPage_MUXControlsTestApp_ScrollViewWithScrollControllersPage
    • MUX_NumberBox_UITests_Shared_Microsoft_UI_Xaml_Controls_NumberBoxTests_NumberBoxPage
    • Scrolling_MUXControlsTestApp_ScrollViewDynamicPage_MUXControlsTestApp_ScrollViewDynamicPage
    • Scrolling_MUXControlsTestApp_ScrollViewKeyboardAndGamepadNavigationPage_MUXControlsTestApp_ScrollViewKeyboardAndGamepadNavigationPage
    • CommandBarFlyout_MUXControlsTestApp_CommandBarFlyoutPage_MUXControlsTestApp_CommandBarFlyoutPage
    • Gesture_Recognizer_Pointer_Events_test_bench_UITests_Shared_Windows_UI_Input_GestureRecognizer_PointersEvents
    • MUX_UITests_Microsoft_UI_Xaml_Controls_SplitButtonTests_SplitButtonTestsPage_UITests_Microsoft_UI_Xaml_Controls_SplitButtonTests_SplitButtonTestsPage
    • MUX_UITests_Shared_Microsoft_UI_Xaml_Controls_TreeViewTests_TreeViewPage_UITests_Shared_Microsoft_UI_Xaml_Controls_TreeViewTests_TreeViewPage
    • WebView_WebView_ChromeClient_Uno_UI_Samples_Content_UITests_WebView_WebView_ChromeClient
    • WebView_WebView_JavascriptInvoke_Uno_UI_Samples_Content_UITests_WebView_WebView_JavascriptInvoke
    • MediaPlayerElement_Mini_player_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Minimal
    • TabView_MUXControlsTestApp_TabViewPage_MUXControlsTestApp_TabViewPage
    • Windows_Media_MediaPlayer_UITests_Windows_Media_MediaPlayerTests
    • ListView_ListView_With_ListViews_Count_Measure_UITests_Shared_Windows_UI_Xaml_Controls_ListView_ListView_With_ListViews_Count_Measure
    • MediaPlayerElement_Using_3gp_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_3gp_Extension
    • MediaPlayerElement_Using_mp3_Audio_only_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Mp3_Extension
    • MediaPlayerElement_Using_ogg_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Ogg_Extension
    • WebView_UITests_Microsoft_UI_Xaml_Controls_WebView2Tests_WebView2_NavigationProperties_UITests_Microsoft_UI_Xaml_Controls_WebView2Tests_WebView2_NavigationProperties
    • WebView_UITests_Microsoft_UI_Xaml_Controls_WebViewTests_WebView_InvokeScriptAsync_UITests_Microsoft_UI_Xaml_Controls_WebViewTests_WebView_InvokeScriptAsync
  • ios: 5 changed over 255

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SequentialAnimations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
    • ProgressRing_Visibility_Collapsed_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • TextBox_UpdatedBinding_On_OneWay_Mode_UITests_Windows_UI_Xaml_Controls_TextBox_TextBox_Bindings
    • Check_ListView_Swallows_Measure_UITests_Shared_Windows_UI_Xaml_Controls_ListView_ListView_With_ListViews_Count_Measure
    • ProgressRing_IsEnabled_Running_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
  • ios-Snap: 52 changed over 994

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Brushes_RectangleStretchFill_Uno_UI_Samples_UITests_ImageBrushTestControl_RectangleStretchFill
    • Image_EmptyImageFixedWidth_Uno_UI_Samples_UITests_ImageTestsControl_EmptyImageFixedWidth
    • Image_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_FromMsAppData_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_FromMsAppData
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Equal_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Equal
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Smaller_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Smaller
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Taller_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Taller
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Wider_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Wider
    • Microsoft_UI_Composition_UITests_Windows_UI_Composition_Vector3KeyFrameAnimationSample_UITests_Windows_UI_Composition_Vector3KeyFrameAnimationSample
    • Microsoft_UI_Composition_UITests_Windows_UI_Composition_VisualRotationSample_UITests_Windows_UI_Composition_VisualRotationSample
    • Microsoft_UI_Composition_UITests_Windows_UI_Composition_VisualTranslationSample_UITests_Windows_UI_Composition_VisualTranslationSample
    • Microsoft_UI_Xaml_Media_CompositionTarget_Rendering_UITests_Shared_Windows_UI_Xaml_Media_CompositionTargetTests_CompositionTarget_Rendering
    • TextBox_TextBox_Disabled_State_Uno_UI_Samples_Content_UITests_TextBoxControl_TextBox_Disabled_State
    • Brushes_ImageBrushStretch_Uno_UI_Samples_UITests_ImageBrushTestControl_ImageBrushStretch
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Bigger_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Bigger
    • MenuBar_SimpleMenuBar_UITests_Shared_Windows_UI_Xaml_Controls_MenuBarTests_SimpleMenuBar
    • Microsoft_UI_Composition_UITests_Windows_UI_Composition_MixTransformCliPropertyAndClippedByParentWithBorders_Then_RenderingIsValid_UITests_Windows_UI_Composition_MixTransformCliPropertyAndClippedByParentWithBorders_Then_RenderingIsValid
    • NavigationView_NavigationViewSample_SamplesApp_Samples_NavigationViewSample_NavigationViewSample
    • SwipeControl_MUXControlsTestApp_SwipeControlPage2_MUXControlsTestApp_SwipeControlPage2
    • TextBox_Input_InputScope_Number_Uno_UI_Samples_Content_UITests_TextBoxControl_Input_InputScope_Number
    • WebView_UITests_Microsoft_UI_Xaml_Controls_WebView2Tests_WebView2_Title_UITests_Microsoft_UI_Xaml_Controls_WebView2Tests_WebView2_Title
  • skia-linux-screenshots: 59 changed over 2304

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • EllipsemaskingEllipseGrid.png-dark
    • EllipsemaskingEllipseGrid.png
    • CalendarView_Theming.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • ClipboardTests.png-dark
    • ImagesInlineInFlipView.png-dark
    • ImagesInlineInFlipView.png
    • ButtonClippingTestsControl.png-dark
    • Examples.png-dark
    • Examples.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • CalendarView_Theming.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • Buttons.png-dark
    • ImageBrushInList.png-dark
  • skia-windows-screenshots: 106 changed over 2304

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • EmptyImageFixedWidth.png-dark
    • EmptyImageFixedWidth.png
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • ElevatedView_CornerRadius.png-dark
    • ElevatedView_CornerRadius.png
    • Buttons.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • Examples.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • ImageInStackPanel.png-dark
    • ImageInStackPanel.png
    • ImageOpened.png-dark
  • wasm: 93 changed over 1058

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • SamplesApp.Windows_UI_Xaml_Controls.ToggleSwitchControl.ToggleSwitch_Default_Style
    • UITests.Shared.Windows_UI_Xaml_Controls.ListView.ListView_ChangeView
    • UITests.Shared.Windows_UI_Xaml_Controls.ListView.ListView_DataContext_Propagation
    • UITests.Shared.Windows_UI_Xaml_Controls.ListView.ListView_DataTemplateSelector
    • UITests.Windows_UI_Xaml.DragAndDrop.DragDrop_TestPage
    • Uno.UI.Samples.Content.UITests.ButtonTestsControl.RadioButton_Multiple_Unnamed_Groups
    • MUXControlsTestApp.CommandBarFlyoutMainPage
    • UITests.Shared.Windows_UI_Xaml_Controls.Slider.Slider_Features
    • UITests.Shared.Windows_UI_Xaml_Controls.TextBlockControl.Foreground_Brushes
    • UITests.Shared.Windows_UI_Xaml_Controls.TextBlockControl.SimpleText_MaxLines_Different_Font_Size
    • UITests.Windows_UI_ViewManagement.ApplicationViewSizing
    • UITests.Windows_UI_Xaml_Controls.TextBox.TextBox_Foreground_Changing
    • UITests.Windows_UI_Xaml_Controls.TextBox.TextBox_IsTabStop
    • Uno.UI.Samples.Content.UITests.ContentControlTestsControl.ContentControl_Inheritance
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ComboBox.ComboBox_Corners
    • UITests.Windows_ApplicationModel.ClipboardTests
    • UITests.Windows_UI_Xaml_Controls.TextBox.TextBox_CornerRadius
    • UITests.Windows_UI_Xaml_Controls.TextBox.TextBox_Description
    • UITests.Windows_UI_Xaml_Controls.TextBox.TextBox_Focus_Programmatic
  • wasm-automated-net10.0-WinUI-Benchmarks-automated: 0 changed over 1

  • wasm-automated-net10.0-WinUI-Default-automated: 13 changed over 877

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SequentialAnimations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
    • TestProgressRing_InitialState_UITests_Microsoft_UI_Xaml_Controls_ProgressRing_WinUIProgressRing_Features
    • When_HollowCircle2_UITests_Windows_UI_Input_PointersTests_HitTest_GeometryGroup
    • When_SingleSelectionWithoutItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • Default_StrokeThickness_MyEllipse
    • When_SingleSelectionWithItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • Default_StrokeThickness_MyRect
    • Default_StrokeThickness_MyLine
    • Default_StrokeThickness_MyPolygon
    • When_StretchAndAlignmentNone_ImageBrush-50-50-None-XLeft-YBottom
    • ListView_SelectedItems_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewSelectedItems
    • Default_StrokeThickness_MyPolyline
    • When_TransformToVisual_ScrollViewer_UITests_Shared_Windows_UI_Xaml_UIElementTests_TransformToVisual_ScrollViewer
  • wasm-automated-net10.0-WinUI-RuntimeTests-0: 1 changed over 1

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • RunRuntimeTests_SamplesApp_Samples_UnitTests_UnitTestsPage
  • wasm-automated-net10.0-WinUI-RuntimeTests-1: 0 changed over 1

  • wasm-automated-net10.0-WinUI-RuntimeTests-2: 0 changed over 1

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 184497 has failed on Uno.UI - CI.

@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-Uno.UI-trimmer-warnings-1 branch from e96113f to d0876bd Compare November 24, 2025 12:56
@github-actions github-actions Bot added the area/code-generation Categorizes an issue or PR as relevant to code generation label Nov 24, 2025
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-Uno.UI-trimmer-warnings-1 branch from d0876bd to 1d5ca99 Compare November 24, 2025 14:33
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-Uno.UI-trimmer-warnings-1 branch 2 times, most recently from 01f7aa1 to 6bff243 Compare November 24, 2025 17:56
@unodevops

Copy link
Copy Markdown
Contributor

@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-Uno.UI-trimmer-warnings-1 branch from 6bff243 to edd9340 Compare November 26, 2025 10:43
@github-actions github-actions Bot added platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform labels Nov 26, 2025
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 185093 has failed on Uno.UI - CI.

@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-Uno.UI-trimmer-warnings-1 branch from edd9340 to 7420f57 Compare November 26, 2025 19:42
@jonpryor
jonpryor marked this pull request as ready for review November 26, 2025 19:42
Comment thread src/Uno.UI/ToolkitHelper.cs Resolved
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 185234 has failed on Uno.UI - CI.

@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-Uno.UI-trimmer-warnings-1 branch from 7420f57 to de69bd8 Compare December 2, 2025 14:51
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 185967 has failed on Uno.UI - CI.

@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-Uno.UI-trimmer-warnings-1 branch from de69bd8 to edae26e Compare December 2, 2025 18:16
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

jonpryor added a commit that referenced this pull request Dec 2, 2025
Context: unoplatform/uno.chefs#1712
Context: #21920
Context: unoplatform/uno.extensions#2966
Context: unoplatform/uno.extensions#2969
Context: https://discord.com/channels/732297728826277939/732297837953679412/1444909702512119899

While running the uno.chefs app on macOS under NativeAOT:

	dotnet publish -c Release -r osx-x64 -f net10.0-desktop -p:TargetFrameworkOverride=net10.0-desktop -bl \
	  Chefs/Chefs.csproj \
	  -p:SelfContained=true -p:PublishAot=true -p:IsAotCompatible=true -p:UseSkiaRendering=true \
	  -p:IlcGenerateMapFile=true -p:IlcGenerateMstatFile=true -p:IlcGenerateDgmlFile=true \
	  -p:EmitCompilerGeneratedFiles=true -p:CompilerGeneratedFilesOutputPath=`pwd`/_gen
	Chefs/bin/Release/net10.0-desktop/osx-x64/publish/Chefs

(along with a change from unoplatform/uno.chefs#1712)

Console output would contain the following errors:

	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]
	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [Y] property getter does not exist on type [Windows.Foundation.Point]
	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [X] property getter does not exist on type [Windows.Foundation.Point]

At this point, a description of the relation between NativeAOT and
Reflection would be useful.

Parts of System.Reflection can be used.  Which parts *can* be used,
and how to use them, is oddly *not* well specified in the
[Native AOT deployment][0] documentation.

What doesn't work is outlined in the [limitations][1] section:

> * No dynamic loading, for example, `Assembly.LoadFile`.
> * No run-time code generation, for example, `System.Reflection.Emit`.

What *always* appears to work is:

  * `Type.GetType()` returns a `Type` instance.

What ***can*** work is:

  * `Type.GetType(string)`, *so long as* an assembly-qualified name
    is used as a *string constant*

        // bad
        string name = GetSomeTypeName();
        Type type = Type.GetType(name);

        // good
        Type type = Type.GetType("My.Example.TypeName, ExampleAssembly");

  * `Type.GetMethods()`, but see fine print below.
  * `Type.GetProperties()`, but see fine print below.
  * `MethodInfo.Invoke()`
  * …

**The Fine Print**: in order for many Reflection-based APIs such as
`Type.GetMethods()` to work, the program must contain
"reflection metadata."

We can now describe, briefly, what NativeAOT does:

 1. Accept IL/assemblies
 2. Internally trims the IL, optimizes them, etc.
 3. Generates a native binary containing two separate bits of data:

    * Native machine code for execution
    * "reflection metadata"

There is no facility to separately dump reflection metadata.

Programs can control what is contained within reflection metadata
by using string constants with Reflection APIs, for example:

	typeof(SomeKnownType).GetMethod("ConstantName")

will ensure that reflection metadata contains
`SomeKnownType.ConstantName()`, and `ConstantName()` will be returned
from `typeof(SomeKnownType).GetMethods()` and can be invoked with
`MethodInfo.Invoke()`.

If you *don't* use `typeof(SomeKnownType)` or string constants with
`Type.GetType(string)` or `type.GetMethod("constant")`, then you need
to "suggest" that some pieces of information be added to
reflection metadata.

The two predominant ways to do this are via the custom attributes:

  * [`DynamicallyAccessedMembersAttribute`][2]
  * [`DynamicDependencyAttribute`][3]

From the Uno perspective, enter `BindingPropertyHelper`: *everything*
is based on Reflection!

Fortunately NativeAOT "supports" Reflection!

*Unfortunately*, we now need to convince NativeAOT to store the
reflection metadata Uno requires in order to work!

Various other PRs have dealt with some of this, such as #21920.

Returning to the original failure messages, e.g.

	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]

During the app build, `src/SourceGenerators/Uno.UI.SourceGenerators`
generates a a `BindableMetadata.g.cs` file which will mention
`[Bindable]` types, e.g. for `Microsoft.UI.Xaml.Controls.FlipView`:

	/// <summary>
	/// Builder for Microsoft.UI.Xaml.Controls.FlipView
	/// </summary>
	[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute]
	static class MetadataBuilder_239
	{
	  internal static global::Uno.UI.DataBinding.IBindableType Build(global::Uno.UI.DataBinding.BindableType parent)
	  {
	    var bindableType = parent ?? new global::Uno.UI.DataBinding.BindableType(151, typeof(global::Microsoft.UI.Xaml.Controls.FlipView));
	    // …
	  }
	  private static object CreateInstance() => new global::Microsoft.UI.Xaml.Controls.FlipView();
	}

`BindableMetadata.g.cs` was needed in the ye olde Xamarin world order
to tell *its* linker to e.g. "preserve the `FlipView` default ctor!"

*Now*, we can build upon this infrastructure and update `BindableType`
to request that Reflection information regarding properties, fields,
and constructors be retained.  We can do this by updating the
`BindableType` constructor:

	partial class BindableType {
	  internal const DynamicallyAccessedMemberTypes TypeRequirements =
	    DynamicallyAccessedMemberTypes.PublicProperties | …;
	  public BindableType(int estimatedPropertySize, [DynamicallyAccessedMembers(TypeRequirements)] Type sourceType ) => …
	}

*Because* we have `BindableMetadata.g.cs` *and* because it provides
`typeof(FlipView)`, this directs NativeAOT to make property and other
reflection metadata available to the app, *fixing* the error messages.

Expand this addition of `[DynamicallyAccessedMembers]` to also include
`BindableProperty` and related types.

[0]: https://learn.microsoft.comdotnet/core/deploying/native-aot
[1]: https://learn.microsoft.comdotnet/core/deploying/native-aot/#limitations-of-native-aot-deployment
[2]: https://learn.microsoft.comdotnet/api/system.diagnostics.codeanalysis.dynamicallyaccessedmembersattribute?view=net-10.0
[3]: https://learn.microsoft.comdotnet/api/system.diagnostics.codeanalysis.dynamicdependencyattribute?view=net-10.0
@jonpryor
jonpryor enabled auto-merge December 2, 2025 21:11
@nventive-devops

Copy link
Copy Markdown
Contributor

The build 185991 found UI Test snapshots differences: android-28-net9: 14, android-28-net9-Snap: 37, ios: 6, ios-Snap: 55, skia-linux-screenshots: 66, skia-windows-screenshots: 87, wasm: 135, wasm-automated-net10.0-WinUI-Benchmarks-automated: 0, wasm-automated-net10.0-WinUI-Default-automated: 13, wasm-automated-net10.0-WinUI-RuntimeTests-0: 0, wasm-automated-net10.0-WinUI-RuntimeTests-1: 0, wasm-automated-net10.0-WinUI-RuntimeTests-2: 0

Details
  • android-28-net9: 14 changed over 825

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • DecimalFormatterTest_UITests_Shared_Microsoft_UI_Xaml_Controls_NumberBoxTests_NumberBoxPage
    • Detereminate_ProgressRing_Validation50_[#FF0000_#008000_#008000_#FF0000]_Progress-Ring-Value-50
    • NativeCommandBar_Size_Uno_UI_Samples_Content_UITests_CommandBar_CommandBar_Dynamic
    • SequentialAnimations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
    • UpDownEnabledTest_UITests_Shared_Microsoft_UI_Xaml_Controls_NumberBoxTests_NumberBoxPage
    • When_NoSelectionWithItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • When_NoSelection_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • When_Parent_PointerMoved_After_drag_on_ScrollViewer_-_touch
    • ListView_ListViewWithHeader_InitializesTest_SamplesApp_Windows_UI_Xaml_Controls_ListView_HorizontalListViewGrouped
    • When_Parent_PointerMoved_After_drag_on_non-scrolling_ScrollViewer
    • Detereminate_ProgressRing_Validation75_[#FF0000_#008000_#008000_#008000]_Progress-Ring-Value-75
    • ProgressRing_IsEnabled_Running_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • Detereminate_ProgressRing_Validation25_[#FF0000_#008000_#FF0000_#FF0000]_Progress-Ring-Value-25
    • ProgressRing_Visibility_Collapsed_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
  • android-28-net9-Snap: 37 changed over 1077

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Image_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_Basic_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_Basic
    • Image_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_FromMsAppData_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_FromMsAppData
    • Image_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_FromStream_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_FromStream
    • RatingControl_UITests_Microsoft_UI_Xaml_Controls_RatingControlTests_RatingControlPage_UITests_Microsoft_UI_Xaml_Controls_RatingControlTests_RatingControlPage
    • TabView_MUXControlsTestApp_TabViewPage_MUXControlsTestApp_TabViewPage
    • NavigationView_MUXControlsTestApp_NavigationViewRS4Page_MUXControlsTestApp_NavigationViewRS4Page
    • Pickers_UITests_Windows_UI_Xaml_Controls_CalendarView_CalendarView_Theming_UITests_Windows_UI_Xaml_Controls_CalendarView_CalendarView_Theming
    • Icons_UITests_Shared_Windows_UI_Xaml_Controls_BitmapIconTests_BitmapIcon_Foreground_UITests_Shared_Windows_UI_Xaml_Controls_BitmapIconTests_BitmapIcon_Foreground
    • ListView_ListViewSelectedItems_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewSelectedItems
    • Brushes_Uno_UI_Samples_UITests_ImageBrushTestControl_Ellipse_Uno_UI_Samples_UITests_ImageBrushTestControl_Ellipse
    • NavigationView_MUXControlsTestApp_NavigationViewTopNavOnlyPage_MUXControlsTestApp_NavigationViewTopNavOnlyPage
    • NavigationView_MUXControlsTestApp_NavigationViewTopNavPage_MUXControlsTestApp_NavigationViewTopNavPage
    • TextBlock_UITests_Shared_Windows_UI_Xaml_Controls_TextBlockControl_TextBlock_Layout_UITests_Shared_Windows_UI_Xaml_Controls_TextBlockControl_TextBlock_Layout
    • Scrolling_MUXControlsTestApp_ScrollViewWithScrollControllersPage_MUXControlsTestApp_ScrollViewWithScrollControllersPage
    • ListView_ListView_With_ListViews_Count_Measure_UITests_Shared_Windows_UI_Xaml_Controls_ListView_ListView_With_ListViews_Count_Measure
    • MUX_UITests_Shared_Microsoft_UI_Xaml_Controls_TreeViewTests_TreeViewPage_UITests_Shared_Microsoft_UI_Xaml_Controls_TreeViewTests_TreeViewPage
    • Scrolling_MUXControlsTestApp_ScrollViewDynamicPage_MUXControlsTestApp_ScrollViewDynamicPage
    • Buttons_UITests_Microsoft_UI_Xaml_Controls_RadioButtonsTests_RadioButtonsPage_UITests_Microsoft_UI_Xaml_Controls_RadioButtonsTests_RadioButtonsPage
    • CommandBarFlyout_MUXControlsTestApp_CommandBarFlyoutPage_MUXControlsTestApp_CommandBarFlyoutPage
    • Gesture_Recognizer_Pointer_Events_test_bench_UITests_Shared_Windows_UI_Input_GestureRecognizer_PointersEvents
  • ios: 6 changed over 255

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Check_ListView_Swallows_Measure_UITests_Shared_Windows_UI_Xaml_Controls_ListView_ListView_With_ListViews_Count_Measure
    • ProgressRing_IsEnabled_Running_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • TextBox_UpdatedBinding_On_OneWay_Mode_UITests_Windows_UI_Xaml_Controls_TextBox_TextBox_Bindings
    • ProgressRing_Visibility_Collapsed_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • SequentialAnimations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
    • When_SingleSelectionWithoutItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
  • ios-Snap: 55 changed over 994

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Brushes_ImageBrushWithCompositeTransform_Uno_UI_Samples_UITests_ImageBrushTestControl_ImageBrushWithCompositeTransform
    • Icons_UITests_Shared_Windows_UI_Xaml_Controls_BitmapIconTests_BitmapIcon_Foreground_UITests_Shared_Windows_UI_Xaml_Controls_BitmapIconTests_BitmapIcon_Foreground
    • SwipeControl_MUXControlsTestApp_SwipeControlPage2_MUXControlsTestApp_SwipeControlPage2
    • TabView_MUXControlsTestApp_TabViewPage_MUXControlsTestApp_TabViewPage
    • Clipping_UITests_Windows_UI_Xaml_Clipping_BorderVisualClipping_UITests_Windows_UI_Xaml_Clipping_BorderVisualClipping
    • Grid_CenteredGridinGridwiththreefixedsizechildren_Uno_UI_Samples_Content_UITests_GridTestsControl_CenteredGridinGridwiththreefixedsizechildren
    • Default_UITests_Windows_UI_Xaml_Controls_Canvas_Grid_ZIndex_UITests_Windows_UI_Xaml_Controls_Canvas_Grid_ZIndex
    • Image_UITests_Shared_Windows_UI_Xaml_Controls_ImageTests_Image_Stretch_Algmnt_Inf_Vertical_UITests_Shared_Windows_UI_Xaml_Controls_ImageTests_Image_Stretch_Algmnt_Inf_Vertical
    • Image_UITests_Shared_Windows_UI_Xaml_Controls_ImageTests_Image_Stretch_Alignment_SizeOnControl_UITests_Shared_Windows_UI_Xaml_Controls_ImageTests_Image_Stretch_Alignment_SizeOnControl
    • NavigationView_MUXControlsTestApp_NavigationViewMinimalPage_MUXControlsTestApp_NavigationViewMinimalPage
    • Performance_UITests_Windows_UI_Xaml_Performance_Performance_1000ButtonsContinuousRendering_UITests_Windows_UI_Xaml_Performance_Performance_1000ButtonsContinuousRendering
    • TextBlock_TextBlockMultilineInStarStackPanel_Uno_UI_Samples_Content_UITests_TextBlockControl_TextBlockMultilineInStarStackPanel
    • Brushes_PanelImageBrush_Uno_UI_Samples_UITests_ImageBrushTestControl_PanelImageBrush
    • ListView_ListView_KeyboardInterception_UITests_Windows_UI_Xaml_Controls_ListView_ListView_KeyboardInterception
    • Microsoft_UI_Xaml_Media_UITests_Windows_UI_Xaml_Media_ThemeShadowTests_ThemeShadow_Overlap_UITests_Windows_UI_Xaml_Media_ThemeShadowTests_ThemeShadow_Overlap
    • Pickers_UITests_Windows_UI_Xaml_Controls_CalendarView_CalendarView_Theming_UITests_Windows_UI_Xaml_Controls_CalendarView_CalendarView_Theming
    • TextBox_Input_InputScope_Number_Uno_UI_Samples_Content_UITests_TextBoxControl_Input_InputScope_Number
    • Brushes_Uno_UI_Samples_Samples_Shared_Content_UITests_ImageBrushInList_Uno_UI_Samples_Samples_Shared_Content_UITests_ImageBrushInList
    • Image_UITests_Shared_Windows_UI_Xaml_Controls_ImageTests_Image_Stretch_Algmnt_Inf_Horizontal_UITests_Shared_Windows_UI_Xaml_Controls_ImageTests_Image_Stretch_Algmnt_Inf_Horizontal
    • Brushes_BorderImageBrush_Uno_UI_Samples_UITests_ImageBrushTestControl_BorderImageBrush
  • skia-linux-screenshots: 66 changed over 2306

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • DropDownButtonPage.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Buttons.png-dark
    • ClipboardTests.png
    • Examples.png
    • ClipboardTests.png-dark
    • EllipsemaskingEllipseGrid.png-dark
    • EllipsemaskingEllipseGrid.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • CalendarView_Theming.png-dark
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • CalendarView_Theming.png
    • ImageIconPage.png-dark
  • skia-windows-screenshots: 87 changed over 2306

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Border_With_ScaleTransform.png-dark
    • Examples.png-dark
    • Examples.png
    • Border_With_ScaleTransform.png
    • BitmapIcon_Monochromatic.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • Buttons.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
  • wasm: 135 changed over 1058

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • MUXControlsTestApp.NavigationViewStretchPage
    • SamplesApp.Wasm.Windows_UI_Xaml_Media.Transform.TransformToVisual_Translate2d
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListView_Inside_ListView
    • SamplesApp.Windows_UI_Xaml_Shapes.PolylinePage
    • SamplesApp.Windows_UI_Xaml_Shapes.ShapeControlsPage
    • UITests.Shared.Windows_UI.Xaml_Automation.AutomationProperties_AutomationId
    • UITests.Shared.Windows_UI_Xaml_Controls.Button.Overlapped_Buttons
    • UITests.Shared.Windows_UI_Xaml_Controls.ListView.ListView_Weird_Measure
    • UITests.Windows_UI_Xaml_Controls.CommandBar.CommandBar_Native_With_TextBox
    • UITests.Windows_UI_Xaml_Controls.TextBox.TextBox_IsTabStop
    • Uno.UI.Samples.Content.UITests.Animations.VisualState_AdaptiveTrigger_UsingOneStateOnly
    • SamplesApp.Samples.NavigationViewSample.NavigationViewSample
    • UITests.Shared.Windows_ApplicationModel.Calls.PhoneCallHistoryEntryReaderTests
    • UITests.Shared.Windows_UI_Xaml_Controls.ListView.ListView_ObservableCollection_Unused_Space
    • UITests.Shared.Windows_UI_Xaml_Controls.ListView.ListView_ProportionalPanel
    • UITests.Windows_UI_Xaml_Controls.SwipeControlTests.SwipeControl_ListView_ItemClick
    • initial_state
    • MUXControlsTestApp.NavigationViewIsPaneOpenPage
    • MUXControlsTestApp.SelectorBarSamplePage
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
  • wasm-automated-net10.0-WinUI-Benchmarks-automated: 0 changed over 1

  • wasm-automated-net10.0-WinUI-Default-automated: 13 changed over 877

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ListView_SelectedItems_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewSelectedItems
    • SequentialAnimations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
    • Default_StrokeThickness_MyRect
    • Default_StrokeThickness_MyPath
    • Default_StrokeThickness_MyPolygon
    • TestProgressRing_InitialState_UITests_Microsoft_UI_Xaml_Controls_ProgressRing_WinUIProgressRing_Features
    • When_NoSelection_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • When_StretchAndAlignmentNone_ImageBrush-50-50-None-XLeft-YBottom
    • Default_StrokeThickness_MyPolyline
    • Default_StrokeThickness_MyLine
    • When_MultipleSelectionWithoutItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • When_Theme_Changed_No_Crash_UITests_Windows_UI_Xaml_Controls_CalendarView_CalendarView_Theming
    • Default_StrokeThickness_MyEllipse
  • wasm-automated-net10.0-WinUI-RuntimeTests-0: 0 changed over 1

  • wasm-automated-net10.0-WinUI-RuntimeTests-1: 0 changed over 1

  • wasm-automated-net10.0-WinUI-RuntimeTests-2: 0 changed over 1

Context: https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming
Context: https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot#aot-compatibility-analyzers
Context: https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options
Context: 10480ec
Context: 408e177
Context: dotnet/android#7473
Context: dotnet/android@6836818

Enable `$(IsAotCompatible)`=true for the following projects:

  * `src/Uno.Foundation/Uno.Foundation.csproj`
  * `src/Uno.Foundation/Uno.Foundation.netcoremobile.csproj`
  * `src/Uno.Foundation/Uno.Foundation.Reference.csproj`
  * `src/Uno.Foundation/Uno.Foundation.Skia.csproj`
  * `src/Uno.Foundation/Uno.Foundation.Wasm.csproj`
  * `src/Uno.UI/Uno.UI.netcoremobile.csproj`
  * `src/Uno.UI/Uno.UI.Reference.csproj`
  * `src/Uno.UI/Uno.UI.Skia.csproj`
  * `src/Uno.UI/Uno.UI.Wasm.csproj`

Address the following warnings:

	src/Uno.UI/DataBinding/BindingPropertyHelper.MemberBinder.cs(13,60): error IL3050:
	  Using member 'System.Dynamic.GetMemberBinder.GetMemberBinder(String, Boolean)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
	  Creating a call site may require dynamic code generation.
	src/Uno.UI/DataBinding/BindingPropertyHelper.MemberBinder.cs(22,60): error IL3050:
	  Using member 'System.Dynamic.SetMemberBinder.SetMemberBinder(String, Boolean)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
	  Creating a call site may require dynamic code generation.
	src/Uno.UI/FastInvokerBuilder.Android.cs(25,34): error IL3050:
	  Using member 'System.Reflection.Emit.DynamicMethod.DynamicMethod(String, Type, Type[], Module, Boolean)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
	  Creating a DynamicMethod requires dynamic code.

Add `[RequiresDynamicCodeAttribute]` to the specified types.

Fix the following warnings:

	src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2WebMessageReceivedEventArgs.cs(61,70): error IL2026:
	  Using member 'System.Text.Json.Serialization.Metadata.JsonTypeInfo.CreateJsonTypeInfo<T>(JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code.
	  JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation.
	  Use System.Text.Json source generation for native AOT applications.
	src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2WebMessageReceivedEventArgs.cs(61,70): error IL3050:
	  Using member 'System.Text.Json.Serialization.Metadata.JsonTypeInfo.CreateJsonTypeInfo<T>(JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
	  JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation.
	  Use System.Text.Json source generation for native AOT applications.
	src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2WebMessageReceivedEventArgs.cs(54,22): error IL2026:
	  Using member 'System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.DefaultJsonTypeInfoResolver()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code.
	  JSON serialization and deserialization might require types that cannot be statically analyzed.
	  Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
	src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2WebMessageReceivedEventArgs.cs(54,22): error IL3050:
	  Using member 'System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.DefaultJsonTypeInfoResolver()' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
	  JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation.
	  Use System.Text.Json source generation for native AOT applications.

@jonpryor was under the mistaken belief that commit 10480ec would be
sufficient to fix these warnings, and was wrong.  Even though we
"only" need to turn JSON into a *`string`*, not a structure, do as
requested: use System.Text.Json source generation.  (Which, again,
feels rather weird as only `string` is needed!)

	[JsonSourceGenerationOptions]
	[JsonSerializable(typeof(string))]
	internal sealed partial class ExampleContext : JsonSerializerContext {}
	// then use ExampleContext.Default.String to deserialize to string!

Fix the following warning:

	src/Uno.UI/UI/Xaml/SpecializedResourceDictionary.cs(133,34): error IL3050:
	  Using member 'System.Runtime.InteropServices.Marshal.SizeOf(Type)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
	  Marshalling code for the object might not be available.
	  Use the SizeOf<T> overload instead.

We *could* do as requested and use `Marshal.SizeOf<IntPtr>()`, but
the reason why `Marshal.SizeOf()` is used here is because of 408e177,
which was to workaround dotnet/android#7473.  dotnet/android#7473 has
since been fixed in dotnet/android@68368189, meaning we don't actually
need to use `Marshal.SizeOf()` anymore.  Use `IntPtr.Size` instead.

Suppress the following warning:

	src/Uno.UI/UI/Xaml/Navigation/NavigationHistory.mux.cs(329,25): error IL2057:
	  Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'.
	  It's not possible to guarantee the availability of the target type.

TODO: investigate whether we can update `PageStackEntry.m_descriptor`
to have `[DynamicallyAccessedMembers]`.

Suppress the following warnings:

	src/Uno.UI/Extensions/ViewExtensions.visual-tree.cs(214,4): error IL2075:
	  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'.
	  The return value of method 'System.Object.GetType()' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/UI/Xaml/FrameworkElementExtensions.cs(82,17): error IL2075:
	  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Reflection.TypeInfo.GetDeclaredField(String)'.
	  The return value of method 'System.Object.GetType()' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/UI/Xaml/FrameworkElementExtensions.cs(82,17): error IL2075:
	  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Reflection.TypeInfo.GetDeclaredField(String)'.
	  The return value of method 'System.Type.BaseType.get' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/UI/Xaml/FrameworkElementExtensions.cs(108,20): error IL2075:
	  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.TypeInfo.GetDeclaredProperty(String)'.
	  The return value of method 'System.Object.GetType()' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/UI/Xaml/FrameworkElementExtensions.cs(108,20): error IL2075:
	  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.TypeInfo.GetDeclaredProperty(String)'.
	  The return value of method 'System.Type.BaseType.get' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/UI/Xaml/FrameworkElementExtensions.cs(104,8): error IL2070:
	  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Reflection.TypeInfo.GetDeclaredField(String)'.
	  The parameter 'type' of method 'GetField(Type, String)' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/UI/Xaml/FrameworkElementExtensions.cs(134,8): error IL2070:
	  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.TypeInfo.GetDeclaredProperty(String)'.
	  The parameter 'type' of method 'GetProperty(Type, String)' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/DirectUI/PropertyPathStep.cs(502,16): error IL2072:
	  'pSourceType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'DirectUI.ReflectionPropertyAccess.CreateInstance(IPropertyAccessHost, Object, Type, Boolean)'.
	  The return value of method 'System.Object.GetType()' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/UI/Xaml/Controls/Frame/Frame.legacy.cs(68,4): error IL2072:
	  'value' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Microsoft.UI.Xaml.Navigation.PageStackEntry.SourcePageType.set'.
	  The return value of method 'System.Object.GetType()' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/UI/Xaml/Controls/NumberBox/NumberBoxParser.cs(93,20): error IL2072:
	  'typeName' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.PublicEvents' in call to 'Windows.Foundation.Metadata.ApiInformation.IsTypePresent(String)'.
	  The return value of method 'System.Object.GetType()' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.

As these callsites are all rooted in `value.GetType().…`, I can't
think of a way to appease NativeAOT here.

Suppress the following warnings:

	C:\a\1\s\src\Uno.UI\obj\Uno.UI.netcoremobile\Release\net10.0-ios26.0\Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.DependencyObject.DependencyObjectGenerator\Microsoft.UI.Xaml.Navigation.PageStackEntry.cs(120,4): error IL2111:
	  Method 'Microsoft.UI.Xaml.Navigation.PageStackEntry.PageStackEntry(Type, Object, NavigationTransitionInfo)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection.
	  Trimmer can't guarantee availability of the requirements of the method.
	C:\a\1\s\src\Uno.UI\obj\Uno.UI.netcoremobile\Release\net10.0-ios26.0\Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.DependencyObject.DependencyObjectGenerator\Microsoft.UI.Xaml.Navigation.PageStackEntry.cs(150,4): error IL2111:
	  Method 'Microsoft.UI.Xaml.Navigation.PageStackEntry.PageStackEntry(Type, Object, NavigationTransitionInfo)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection.
	  Trimmer can't guarantee availability of the requirements of the method.

These warnings appear to be unactionable: what are we supposed to *do*?
Like, okay then?

Update `src/SourceGenerators` so that the callsite suppressses these.

Address the following warnings:

	src/Uno.UI/Controls/BindableImageView.Android.cs(205,23): error IL2080:
	  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields' in call to 'System.Type.GetFields(BindingFlags)'.
	  The field 'Uno.UI.Controls.BindableImageView._drawables' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/DirectUI/PropertyAccess.cs(1634,18): error IL2070:
	  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'.
	  The parameter 'pSourceType' of method 'DirectUI.ReflectionPropertyAccess.CreateInstance(IPropertyAccessHost, Object, Type, Boolean)' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/DirectUI/MetadataAPI.cs(603,5): error IL2070:
	  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'.
	  The parameter 'type' of method 'DirectUI.MetadataAPI.TryGetDependencyPropertyByName(Type, String)' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/UI/Xaml/Internal/CustomEventManager.cs(33,66): error IL2091: 'TValue' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in 'System.Runtime.CompilerServices.ConditionalWeakTable<TKey, TValue>'.
	  The generic parameter 'TEventArgs' of 'Uno.UI.Xaml.Core.CustomKeepLastEventManager<T, TEventArgs>' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/UI/Xaml/Navigation/PageStackEntry.Properties.cs(32,10): error IL2073:
	  'Microsoft.UI.Xaml.Navigation.PageStackEntry.SourcePageType.get' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' requirements.
	  The return value of method 'Microsoft.UI.Xaml.Navigation.PageStackEntry.GetValue(DependencyProperty)' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Add the requested `[DynamicallyAccessedMembers]`.

Suppress the following warning:

	src/Uno.UI/UI/Xaml/Navigation/PageStackEntry.Properties.cs(41,3): error IL2111:
	  Method 'Microsoft.UI.Xaml.Navigation.PageStackEntry.PageStackEntry(Type, Object, NavigationTransitionInfo)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection.
	  Trimmer can't guarantee availability of the requirements of the method.

@jonpryor has no idea why this warning is appearing.

Address the following warning:

	src/Uno.UI/Helpers/TypeMappings.cs(76,6): error IL2072:
	  'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'System.Activator.CreateInstance(Type, params Object[])'.
	  The return value of method 'Uno.UI.Helpers.TypeMappings.GetReplacementType(Type)' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Update *the entire call hierarchy* within this file so that `Type`
parameters and `Type`-returning methods all declare *both*
`DynamicallyAccessedMemberTypes.PublicConstructors` and
`DynamicallyAccessedMemberTypes.PublicParameterlessConstructor`.
The latter is needed for `TypeMappings.CreateInstance<T>()`.

For the following warnings:

	src/Uno.UI/UI/Xaml/Markup/Reader/XamlTypeResolver.cs(463,23): error IL2075:
	  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperties()'.
	  The return value of method 'System.Type.BaseType.get' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI/UI/Xaml/Markup/Reader/XamlTypeResolver.cs(474,23): error IL2075:
	  'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethods()'.
	  The return value of method 'System.Type.BaseType.get' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Annotate the `type` parameter with `[DynamicallyAccessedMembers]`.
(This doesn't touch `Type.BaseType`, but fixed the IL2075.)

Unfortunately, after addressing all of the above, *non*-trimmer
enabled builds start failing:

	src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Common.cs(54,29): error IL2072:
	  'mappedType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.UI.Helpers.TypeMappings.GetOriginalType(Type)'.
	  The return value of method 'System.Object.GetType()' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Common.cs(85,30): error IL2072:
	  'mappedType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.UI.Helpers.TypeMappings.GetOriginalType(Type)'.
	  The return value of method 'System.Object.GetType()' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.MetadataUpdate.cs(526,6): error IL2072:
	  'mappedType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.UI.Helpers.TypeMappings.RegisterMapping(Type, Type)'.
	  The return value of method 'System.Collections.IEnumerator.Current.get' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.MetadataUpdate.cs(526,6): error IL2072:
	  'originalType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.UI.Helpers.TypeMappings.RegisterMapping(Type, Type)'.
	  The return value of method 'System.Reflection.CustomAttributeTypedArgument.Value.get' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.MetadataUpdate.cs(164,25): error IL2072:
	  'mappedType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.UI.Helpers.TypeMappings.GetOriginalType(Type)'.
	  The return value of method 'System.Object.GetType()' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.
	src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.MetadataUpdate.cs(180,23): error IL2072:
	  'originalType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.UI.Helpers.TypeMappings.GetMappedType(Type)'.
	  The return value of method 'System.Object.GetType()' does not have matching annotations.
	  The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Suppress these warnings.

Fix and suppress the following warning:

	src/Uno.UI/ToolkitHelper.cs(12,20): error IL2057: Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'.
	  It's not possible to guarantee the availability of the target type.

Fix this by updating all callsites to use an assembly-qualified name
instead of relying on `ToolkitHelper.GetProperty()` to do a string
concat before a `Type.GetType()` invocation.  This along with
`[DynamicallyAccessedMembers]` on the `typeName` parameter *should*
allow NativeAOT to preserve the referenced types.

That doesn't actually remove the IL2057, though, so suppress it.

For compatibility, if the initial `Type.GetType()` fails, fallback
to appending `",Uno.UI.Toolkit"` to the type name.
@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-Uno.UI-trimmer-warnings-1 branch from edae26e to 6e631b0 Compare December 3, 2025 13:36
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

jonpryor added a commit that referenced this pull request Dec 3, 2025
Context: unoplatform/uno.chefs#1712
Context: #21920
Context: unoplatform/uno.extensions#2966
Context: unoplatform/uno.extensions#2969
Context: https://discord.com/channels/732297728826277939/732297837953679412/1444909702512119899

While running the uno.chefs app on macOS under NativeAOT:

	dotnet publish -c Release -r osx-x64 -f net10.0-desktop -p:TargetFrameworkOverride=net10.0-desktop -bl \
	  Chefs/Chefs.csproj \
	  -p:SelfContained=true -p:PublishAot=true -p:IsAotCompatible=true -p:UseSkiaRendering=true \
	  -p:IlcGenerateMapFile=true -p:IlcGenerateMstatFile=true -p:IlcGenerateDgmlFile=true \
	  -p:EmitCompilerGeneratedFiles=true -p:CompilerGeneratedFilesOutputPath=`pwd`/_gen
	Chefs/bin/Release/net10.0-desktop/osx-x64/publish/Chefs

(along with a change from unoplatform/uno.chefs#1712)

Console output would contain the following errors:

	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]
	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [Y] property getter does not exist on type [Windows.Foundation.Point]
	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [X] property getter does not exist on type [Windows.Foundation.Point]

At this point, a description of the relation between NativeAOT and
Reflection would be useful.

Parts of System.Reflection can be used.  Which parts *can* be used,
and how to use them, is oddly *not* well specified in the
[Native AOT deployment][0] documentation.

What doesn't work is outlined in the [limitations][1] section:

> * No dynamic loading, for example, `Assembly.LoadFile`.
> * No run-time code generation, for example, `System.Reflection.Emit`.

What *always* appears to work is:

  * `Type.GetType()` returns a `Type` instance.

What ***can*** work is:

  * `Type.GetType(string)`, *so long as* an assembly-qualified name
    is used as a *string constant*

        // bad
        string name = GetSomeTypeName();
        Type type = Type.GetType(name);

        // good
        Type type = Type.GetType("My.Example.TypeName, ExampleAssembly");

  * `Type.GetMethods()`, but see fine print below.
  * `Type.GetProperties()`, but see fine print below.
  * `MethodInfo.Invoke()`
  * …

**The Fine Print**: in order for many Reflection-based APIs such as
`Type.GetMethods()` to work, the program must contain
"reflection metadata."

We can now describe, briefly, what NativeAOT does:

 1. Accept IL/assemblies
 2. Internally trims the IL, optimizes them, etc.
 3. Generates a native binary containing two separate bits of data:

    * Native machine code for execution
    * "reflection metadata"

There is no facility to separately dump reflection metadata.

Programs can control what is contained within reflection metadata
by using string constants with Reflection APIs, for example:

	typeof(SomeKnownType).GetMethod("ConstantName")

will ensure that reflection metadata contains
`SomeKnownType.ConstantName()`, and `ConstantName()` will be returned
from `typeof(SomeKnownType).GetMethods()` and can be invoked with
`MethodInfo.Invoke()`.

If you *don't* use `typeof(SomeKnownType)` or string constants with
`Type.GetType(string)` or `type.GetMethod("constant")`, then you need
to "suggest" that some pieces of information be added to
reflection metadata.

The two predominant ways to do this are via the custom attributes:

  * [`DynamicallyAccessedMembersAttribute`][2]
  * [`DynamicDependencyAttribute`][3]

From the Uno perspective, enter `BindingPropertyHelper`: *everything*
is based on Reflection!

Fortunately NativeAOT "supports" Reflection!

*Unfortunately*, we now need to convince NativeAOT to store the
reflection metadata Uno requires in order to work!

Various other PRs have dealt with some of this, such as #21920.

Returning to the original failure messages, e.g.

	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]

During the app build, `src/SourceGenerators/Uno.UI.SourceGenerators`
generates a a `BindableMetadata.g.cs` file which will mention
`[Bindable]` types, e.g. for `Microsoft.UI.Xaml.Controls.FlipView`:

	/// <summary>
	/// Builder for Microsoft.UI.Xaml.Controls.FlipView
	/// </summary>
	[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute]
	static class MetadataBuilder_239
	{
	  internal static global::Uno.UI.DataBinding.IBindableType Build(global::Uno.UI.DataBinding.BindableType parent)
	  {
	    var bindableType = parent ?? new global::Uno.UI.DataBinding.BindableType(151, typeof(global::Microsoft.UI.Xaml.Controls.FlipView));
	    // …
	  }
	  private static object CreateInstance() => new global::Microsoft.UI.Xaml.Controls.FlipView();
	}

`BindableMetadata.g.cs` was needed in the ye olde Xamarin world order
to tell *its* linker to e.g. "preserve the `FlipView` default ctor!"

*Now*, we can build upon this infrastructure and update `BindableType`
to request that Reflection information regarding properties, fields,
and constructors be retained.  We can do this by updating the
`BindableType` constructor:

	partial class BindableType {
	  internal const DynamicallyAccessedMemberTypes TypeRequirements =
	    DynamicallyAccessedMemberTypes.PublicProperties | …;
	  public BindableType(int estimatedPropertySize, [DynamicallyAccessedMembers(TypeRequirements)] Type sourceType ) => …
	}

*Because* we have `BindableMetadata.g.cs` *and* because it provides
`typeof(FlipView)`, this directs NativeAOT to make property and other
reflection metadata available to the app, *fixing* the error messages.

Expand this addition of `[DynamicallyAccessedMembers]` to also include
`BindableProperty` and related types.

[0]: https://learn.microsoft.comdotnet/core/deploying/native-aot
[1]: https://learn.microsoft.comdotnet/core/deploying/native-aot/#limitations-of-native-aot-deployment
[2]: https://learn.microsoft.comdotnet/api/system.diagnostics.codeanalysis.dynamicallyaccessedmembersattribute?view=net-10.0
[3]: https://learn.microsoft.comdotnet/api/system.diagnostics.codeanalysis.dynamicdependencyattribute?view=net-10.0
jonpryor added a commit that referenced this pull request Dec 3, 2025
Context: unoplatform/uno.chefs#1712
Context: #21920
Context: unoplatform/uno.extensions#2966
Context: unoplatform/uno.extensions#2969
Context: https://discord.com/channels/732297728826277939/732297837953679412/1444909702512119899

While running the uno.chefs app on macOS under NativeAOT:

	dotnet publish -c Release -r osx-x64 -f net10.0-desktop -p:TargetFrameworkOverride=net10.0-desktop -bl \
	  Chefs/Chefs.csproj \
	  -p:SelfContained=true -p:PublishAot=true -p:IsAotCompatible=true -p:UseSkiaRendering=true \
	  -p:IlcGenerateMapFile=true -p:IlcGenerateMstatFile=true -p:IlcGenerateDgmlFile=true \
	  -p:EmitCompilerGeneratedFiles=true -p:CompilerGeneratedFilesOutputPath=`pwd`/_gen
	Chefs/bin/Release/net10.0-desktop/osx-x64/publish/Chefs

(along with a change from unoplatform/uno.chefs#1712)

Console output would contain the following errors:

	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]
	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [Y] property getter does not exist on type [Windows.Foundation.Point]
	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [X] property getter does not exist on type [Windows.Foundation.Point]

At this point, a description of the relation between NativeAOT and
Reflection would be useful.

Parts of System.Reflection can be used.  Which parts *can* be used,
and how to use them, is oddly *not* well specified in the
[Native AOT deployment][0] documentation.

What doesn't work is outlined in the [limitations][1] section:

> * No dynamic loading, for example, `Assembly.LoadFile`.
> * No run-time code generation, for example, `System.Reflection.Emit`.

What *always* appears to work is:

  * `Type.GetType()` returns a `Type` instance.

What ***can*** work is:

  * `Type.GetType(string)`, *so long as* an assembly-qualified name
    is used as a *string constant*

        // bad
        string name = GetSomeTypeName();
        Type type = Type.GetType(name);

        // good
        Type type = Type.GetType("My.Example.TypeName, ExampleAssembly");

  * `Type.GetMethods()`, but see fine print below.
  * `Type.GetProperties()`, but see fine print below.
  * `MethodInfo.Invoke()`
  * …

**The Fine Print**: in order for many Reflection-based APIs such as
`Type.GetMethods()` to work, the program must contain
"reflection metadata."

We can now describe, briefly, what NativeAOT does:

 1. Accept IL/assemblies
 2. Internally trims the IL, optimizes them, etc.
 3. Generates a native binary containing two separate bits of data:

    * Native machine code for execution
    * "reflection metadata"

There is no facility to separately dump reflection metadata.

Programs can control what is contained within reflection metadata
by using string constants with Reflection APIs, for example:

	typeof(SomeKnownType).GetMethod("ConstantName")

will ensure that reflection metadata contains
`SomeKnownType.ConstantName()`, and `ConstantName()` will be returned
from `typeof(SomeKnownType).GetMethods()` and can be invoked with
`MethodInfo.Invoke()`.

If you *don't* use `typeof(SomeKnownType)` or string constants with
`Type.GetType(string)` or `type.GetMethod("constant")`, then you need
to "suggest" that some pieces of information be added to
reflection metadata.

The two predominant ways to do this are via the custom attributes:

  * [`DynamicallyAccessedMembersAttribute`][2]
  * [`DynamicDependencyAttribute`][3]

From the Uno perspective, enter `BindingPropertyHelper`: *everything*
is based on Reflection!

Fortunately NativeAOT "supports" Reflection!

*Unfortunately*, we now need to convince NativeAOT to store the
reflection metadata Uno requires in order to work!

Various other PRs have dealt with some of this, such as #21920.

Returning to the original failure messages, e.g.

	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]

During the app build, `src/SourceGenerators/Uno.UI.SourceGenerators`
generates a a `BindableMetadata.g.cs` file which will mention
`[Bindable]` types, e.g. for `Microsoft.UI.Xaml.Controls.FlipView`:

	/// <summary>
	/// Builder for Microsoft.UI.Xaml.Controls.FlipView
	/// </summary>
	[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute]
	static class MetadataBuilder_239
	{
	  internal static global::Uno.UI.DataBinding.IBindableType Build(global::Uno.UI.DataBinding.BindableType parent)
	  {
	    var bindableType = parent ?? new global::Uno.UI.DataBinding.BindableType(151, typeof(global::Microsoft.UI.Xaml.Controls.FlipView));
	    // …
	  }
	  private static object CreateInstance() => new global::Microsoft.UI.Xaml.Controls.FlipView();
	}

`BindableMetadata.g.cs` was needed in the ye olde Xamarin world order
to tell *its* linker to e.g. "preserve the `FlipView` default ctor!"

*Now*, we can build upon this infrastructure and update `BindableType`
to request that Reflection information regarding properties, fields,
and constructors be retained.  We can do this by updating the
`BindableType` constructor:

	partial class BindableType {
	  internal const DynamicallyAccessedMemberTypes TypeRequirements =
	    DynamicallyAccessedMemberTypes.PublicProperties | …;
	  public BindableType(int estimatedPropertySize, [DynamicallyAccessedMembers(TypeRequirements)] Type sourceType ) => …
	}

*Because* we have `BindableMetadata.g.cs` *and* because it provides
`typeof(FlipView)`, this directs NativeAOT to make property and other
reflection metadata available to the app, *fixing* the error messages.

Expand this addition of `[DynamicallyAccessedMembers]` to also include
`BindableProperty` and related types.

[0]: https://learn.microsoft.comdotnet/core/deploying/native-aot
[1]: https://learn.microsoft.comdotnet/core/deploying/native-aot/#limitations-of-native-aot-deployment
[2]: https://learn.microsoft.comdotnet/api/system.diagnostics.codeanalysis.dynamicallyaccessedmembersattribute?view=net-10.0
[3]: https://learn.microsoft.comdotnet/api/system.diagnostics.codeanalysis.dynamicdependencyattribute?view=net-10.0
@nventive-devops

Copy link
Copy Markdown
Contributor

The build 186137 found UI Test snapshots differences: android-28-net9: 18, android-28-net9-Snap: 32, ios: 6, ios-Snap: 56, skia-linux-screenshots: 76, skia-windows-screenshots: 256, wasm: 113, wasm-automated-net10.0-WinUI-Benchmarks-automated: 0, wasm-automated-net10.0-WinUI-Default-automated: 11, wasm-automated-net10.0-WinUI-RuntimeTests-0: 0, wasm-automated-net10.0-WinUI-RuntimeTests-1: 0, wasm-automated-net10.0-WinUI-RuntimeTests-2: 0

Details
  • android-28-net9: 18 changed over 825

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Detereminate_ProgressRing_Validation25_[#FF0000_#008000_#FF0000_#FF0000]_Progress-Ring-Value-25
    • Detereminate_ProgressRing_Validation50_[#FF0000_#008000_#008000_#FF0000]_Progress-Ring-Value-50
    • ListView_ListViewWithHeader_InitializesTest_SamplesApp_Windows_UI_Xaml_Controls_ListView_HorizontalListViewGrouped
    • NativeCommandBar_Size_Uno_UI_Samples_Content_UITests_CommandBar_CommandBar_Dynamic
    • UpDownEnabledTest_UITests_Shared_Microsoft_UI_Xaml_Controls_NumberBoxTests_NumberBoxPage
    • When_MultipleSelectionWithoutItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • When_SingleSelectionWithItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • ProgressRing_IsEnabled_Running_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • ProgressRing_Visibility_Collapsed_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • When_NoSelection_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • FlyoutTest_When_NoOverlayInputPassThroughElement_Then_DontPassThrough_woOff_UITests_Shared_Windows_UI_Xaml_Controls_Flyout_Flyout_OverlayInputPassThroughElement
    • When_Parent_PointerMoved_After_drag_on_non-scrolling_ScrollViewer
    • When_Parent_PointerMoved_After_drag_on_ScrollViewer_-_touch
    • Detereminate_ProgressRing_Validation75_[#FF0000_#008000_#008000_#008000]_Progress-Ring-Value-75
    • WebView_NavigateToAnchor_Initial
    • When_NoSelectionWithItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • DecimalFormatterTest_UITests_Shared_Microsoft_UI_Xaml_Controls_NumberBoxTests_NumberBoxPage
    • SequentialAnimations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
  • android-28-net9-Snap: 32 changed over 1077

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • NavigationView_MUXControlsTestApp_NavigationViewRS4Page_MUXControlsTestApp_NavigationViewRS4Page
    • NavigationView_MUXControlsTestApp_NavigationViewSelectedItemEdgeCasePage_MUXControlsTestApp_NavigationViewSelectedItemEdgeCasePage
    • Icons_UITests_Shared_Windows_UI_Xaml_Controls_BitmapIconTests_BitmapIcon_Foreground_UITests_Shared_Windows_UI_Xaml_Controls_BitmapIconTests_BitmapIcon_Foreground
    • RatingControl_UITests_Microsoft_UI_Xaml_Controls_RatingControlTests_RatingControlPage_UITests_Microsoft_UI_Xaml_Controls_RatingControlTests_RatingControlPage
    • Image_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_Basic_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_Basic
    • Image_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_FromMsAppData_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_FromMsAppData
    • ListView_ListView_With_ListViews_Count_Measure_UITests_Shared_Windows_UI_Xaml_Controls_ListView_ListView_With_ListViews_Count_Measure
    • SwipeControl_MUXControlsTestApp_SwipeControlPage2_MUXControlsTestApp_SwipeControlPage2
    • Image_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_Icons_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_Icons
    • ListView_HorizontalListView_Padding_SamplesApp_Windows_UI_Xaml_Controls_ListView_HorizontalListView_Padding
    • MUX_UITests_Shared_Microsoft_UI_Xaml_Controls_TreeViewTests_TreeViewPage_UITests_Shared_Microsoft_UI_Xaml_Controls_TreeViewTests_TreeViewPage
    • NavigationView_MUXControlsTestApp_NavigationViewTopNavPage_MUXControlsTestApp_NavigationViewTopNavPage
    • TabView_MUXControlsTestApp_TabViewPage_MUXControlsTestApp_TabViewPage
    • TeachingTip_UITests_Microsoft_UI_Xaml_Controls_TeachingTipTests_TeachingTipPage_UITests_Microsoft_UI_Xaml_Controls_TeachingTipTests_TeachingTipPage
    • Scrolling_MUXControlsTestApp_ScrollViewDynamicPage_MUXControlsTestApp_ScrollViewDynamicPage
    • Scrolling_MUXControlsTestApp_ScrollViewWithScrollControllersPage_MUXControlsTestApp_ScrollViewWithScrollControllersPage
    • UIElement_TransformToVisual_Simple_UITests_Shared_Windows_UI_Xaml_UIElementTests_TransformToVisual_Simple
    • CommandBar_Examples_Uno_UI_Samples_Content_UITests_CommandBar_CommandBar_Examples
    • Default_SamplesApp_Wasm_Windows_UI_Xaml_Controls_ListView_ListView_IsSelected_SamplesApp_Wasm_Windows_UI_Xaml_Controls_ListView_ListView_IsSelected
    • NavigationView_MUXControlsTestApp_NavigationViewCustomThemeResourcesPage_MUXControlsTestApp_NavigationViewCustomThemeResourcesPage
  • ios: 6 changed over 255

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • TextBox_UpdatedBinding_On_OneWay_Mode_UITests_Windows_UI_Xaml_Controls_TextBox_TextBox_Bindings
    • ImageStretch_None_Uno_UI_Samples_UITests_ImageTestsControl_Image_Stretch_None
    • Validate_Offscreen_Shapes_UITests_Windows_UI_Xaml_Shapes_Offscreen_Shapes
    • ProgressRing_IsEnabled_Running_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • ListView_SelectedItems_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewSelectedItems
    • ProgressRing_Visibility_Collapsed_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
  • ios-Snap: 56 changed over 994

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Brushes_UITests_Shared_Windows_UI_Xaml_Media_ImageBrushTests_ImageBrush_SameWithDelay_UITests_Shared_Windows_UI_Xaml_Media_ImageBrushTests_ImageBrush_SameWithDelay
    • Image_UITests_Shared_Windows_UI_Xaml_Controls_ImageTests_Image_Stretch_Algmnt_Inf_Vertical_UITests_Shared_Windows_UI_Xaml_Controls_ImageTests_Image_Stretch_Algmnt_Inf_Vertical
    • Image_UITests_Shared_Windows_UI_Xaml_Controls_ImageTests_Image_Stretch_Alignment_SizeOnControl_UITests_Shared_Windows_UI_Xaml_Controls_ImageTests_Image_Stretch_Alignment_SizeOnControl
    • Brushes_ImageBrushWithCompositeTransform_Uno_UI_Samples_UITests_ImageBrushTestControl_ImageBrushWithCompositeTransform
    • Brushes_RectangleStretchFill_Uno_UI_Samples_UITests_ImageBrushTestControl_RectangleStretchFill
    • Brushes_UITests_Windows_UI_Xaml_Media_BrushesTests_RevealBrush_Fallback_UITests_Windows_UI_Xaml_Media_BrushesTests_RevealBrush_Fallback
    • Icons_UITests_Microsoft_UI_Xaml_Controls_ImageIconTests_ImageIconPage_UITests_Microsoft_UI_Xaml_Controls_ImageIconTests_ImageIconPage
    • Icons_UITests_Shared_Windows_UI_Xaml_Controls_BitmapIconTests_BitmapIcon_Foreground_UITests_Shared_Windows_UI_Xaml_Controls_BitmapIconTests_BitmapIcon_Foreground
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Smaller_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Smaller
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Taller_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Taller
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Wider_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Wider
    • ContentControl_ContentControl_SelectorInheritance_Uno_UI_Samples_Content_UITests_ContentControlTestsControl_ContentControl_SelectorInheritance
    • NavigationView_NavigationViewSample_SamplesApp_Samples_NavigationViewSample_NavigationViewSample
    • Image_UITests_Shared_Windows_UI_Xaml_Controls_ImageTests_Image_Stretch_Algmnt_Inf_Horizontal_UITests_Shared_Windows_UI_Xaml_Controls_ImageTests_Image_Stretch_Algmnt_Inf_Horizontal
    • NavigationView_FluentStyle_NavigationViewSample_SamplesApp_Samples_Microsoft_UI_Xaml_Controls_NavigationViewTests_FluentStyle_FluentStyle_NavigationViewSample
    • SwipeControl_MUXControlsTestApp_SwipeControlClearPage_MUXControlsTestApp_SwipeControlClearPage
    • Brushes_PanelImageBrush_Uno_UI_Samples_UITests_ImageBrushTestControl_PanelImageBrush
    • Image_EmptyImageFixedWidth_Uno_UI_Samples_UITests_ImageTestsControl_EmptyImageFixedWidth
    • ItemsControl_UITests_Windows_UI_Xaml_Controls_ItemsControl_ItemsControl_ReplaceItem_UITests_Windows_UI_Xaml_Controls_ItemsControl_ItemsControl_ReplaceItem
    • MediaPlayerElement_Mini_player_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Minimal
  • skia-linux-screenshots: 76 changed over 2306

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Examples.png-dark
    • Examples.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • ColorPickerSample.png-dark
    • ColorPickerSample.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ImageSourceUrlMsAppDataScheme.png-dark
    • ImageSourceUrlMsAppDataScheme.png
    • ButtonClippingTestsControl.png-dark
    • EllipsemaskingEllipseGrid.png-dark
    • EllipsemaskingEllipseGrid.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • Buttons.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
  • skia-windows-screenshots: 256 changed over 2306

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AutoSizedPathCentered.png-dark
    • Border_With_ScaleTransform.png
    • Border_With_TranslateTransform.png-dark
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • AutoSizedPathCentered.png
    • Basics.png-dark
    • DoubleAnimation_Cumulative.png-dark
    • DoubleAnimation_Cumulative.png
    • DoubleAnimation_Opacity_TextBlock.png-dark
    • DoubleAnimation_Opacity_TextBlock.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • Border_With_CompositeTransform.png-dark
    • DoubleAnimationUsingKeyFrames_TranslateX.png-dark
    • DoubleAnimationUsingKeyFrames_TranslateX.png
    • DoubleAnimation_BeginTime.png-dark
    • DoubleAnimation_BeginTime.png
    • Grid_With_RotateTransform_And_Button.png-dark
    • Grid_With_RotateTransform_And_Button.png
  • wasm: 113 changed over 1058

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • UITests.Shared.Windows_System.LauncherTests
    • UITests.Shared.Windows_UI_Xaml_Controls.ListView.ListView_ObservableCollection_Unused_Space
    • UITests.Windows_UI_ViewManagement.ApplicationViewSizing
    • UITests.Windows_UI_Xaml_Controls.ComboBox.ComboBox_Disabled
    • UITests.Shared.Windows_UI_Xaml_Controls.TextBoxTests.TextBox_BeforeTextChanging
    • UITests.Toolkit.ElevatedView_Levels
    • UITests.Windows_UI_Xaml.DragAndDrop.DragDrop_TreeView
    • UITests.Windows_UI_Xaml_Controls.CommandBar.BackButtonImage.CommandBar_Frame
    • Uno.UI.Samples.Content.UITests.ButtonTestsControl.CheckBox_Button
    • UITests.Shared.Windows_UI_Xaml_Controls.Slider.Slider_Features
    • UITests.Shared.Windows_UI_Xaml_Controls.TextBlockControl.SimpleText_MaxLines_Different_Font_Size
    • UITests.Windows_UI_Xaml_Controls.AutoSuggestBoxTests.AutoSuggestBox_Description
    • UITests.Windows_UI_Xaml_Controls.Slider.Slider_Header
    • UITests.Windows_UI_Xaml_Controls.SplitView.SplitViewClip
    • Uno.UI.Samples.Content.UITests.CommandBar.CommandBar_Padding
    • UITests.Shared.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigateToString2
    • UITests.Shared.Windows_UI_Xaml_Controls.ListView.ListView_ChangeView
    • UITests.Shared.Windows_UI_Xaml_Controls.ListView.ListView_DataContext_Propagation
    • UITests.Shared.Windows_UI_Xaml_Controls.ToggleSwitchControl.ToggleSwitchUnloadReload
    • UITests.Windows_Gaming.GamepadReadingTest
  • wasm-automated-net10.0-WinUI-Benchmarks-automated: 0 changed over 1

  • wasm-automated-net10.0-WinUI-Default-automated: 11 changed over 877

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Default_StrokeThickness_MyLine
    • Default_StrokeThickness_MyEllipse
    • Default_StrokeThickness_MyPolygon
    • Default_StrokeThickness_MyPolyline
    • TestProgressRing_InitialState_UITests_Microsoft_UI_Xaml_Controls_ProgressRing_WinUIProgressRing_Features
    • When_TransformToVisual_ScrollViewer_UITests_Shared_Windows_UI_Xaml_UIElementTests_TransformToVisual_ScrollViewer
    • Default_StrokeThickness_MyPath
    • Default_StrokeThickness_MyRect
    • When_MultipleSelectionWithoutItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • SequentialAnimations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
    • ListView_SelectedItems_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewSelectedItems
  • wasm-automated-net10.0-WinUI-RuntimeTests-0: 0 changed over 1

  • wasm-automated-net10.0-WinUI-RuntimeTests-1: 0 changed over 1

  • wasm-automated-net10.0-WinUI-RuntimeTests-2: 0 changed over 1

@jonpryor
jonpryor merged commit c3a5b3f into master Dec 3, 2025
@jonpryor
jonpryor deleted the dev/jonpryor/jonp-Uno.UI-trimmer-warnings-1 branch December 3, 2025 16:32
jonpryor added a commit that referenced this pull request Dec 3, 2025
Context: unoplatform/uno.chefs#1712
Context: #21920
Context: unoplatform/uno.extensions#2966
Context: unoplatform/uno.extensions#2969
Context: https://discord.com/channels/732297728826277939/732297837953679412/1444909702512119899

While running the uno.chefs app on macOS under NativeAOT:

	dotnet publish -c Release -r osx-x64 -f net10.0-desktop -p:TargetFrameworkOverride=net10.0-desktop -bl \
	  Chefs/Chefs.csproj \
	  -p:SelfContained=true -p:PublishAot=true -p:IsAotCompatible=true -p:UseSkiaRendering=true \
	  -p:IlcGenerateMapFile=true -p:IlcGenerateMstatFile=true -p:IlcGenerateDgmlFile=true \
	  -p:EmitCompilerGeneratedFiles=true -p:CompilerGeneratedFilesOutputPath=`pwd`/_gen
	Chefs/bin/Release/net10.0-desktop/osx-x64/publish/Chefs

Console output would contain the following errors:

	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]
	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [Y] property getter does not exist on type [Windows.Foundation.Point]
	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [X] property getter does not exist on type [Windows.Foundation.Point]

At this point, a description of the relation between NativeAOT and
Reflection would be useful.

*Parts* of System.Reflection can be used.  Which parts *can* be used,
and how to use them, is oddly *not* well specified in the
[Native AOT deployment][0] documentation.

What doesn't work is outlined in the [limitations][1] section:

> * No dynamic loading, for example, `Assembly.LoadFile`.
> * No run-time code generation, for example, `System.Reflection.Emit`.

What *always* appears to work is:

  * `Type.GetType()` returns a `Type` instance.

What ***can*** work is:

  * `Type.GetType(string)`, *so long as* an assembly-qualified name
    is used as a *string constant*

        // bad
        string name = GetSomeTypeName();
        Type type = Type.GetType(name);

        // good
        Type type = Type.GetType("My.Example.TypeName, ExampleAssembly");

  * `Type.GetMethod(string)`, but see fine print below.
  * `Type.GetProperty(string)`, but see fine print below.
  * `MethodInfo.Invoke()`
  * …

**The Fine Print**: in order for many Reflection-based APIs such as
`Type.GetMethod(string)` to work, the program must contain
"reflection metadata."

We can now describe, briefly, what NativeAOT does:

 1. Accept IL/assemblies as input
 2. Internally trim the IL, optimizes them, etc.
 3. Generates a native binary containing two separate bits of data:

    * Native machine code for execution
    * "reflection metadata"

You can get an inkling of what methods survived trimming and become
native code by using `dotnet publish -p:IlcGenerateMapFile=true …`,
which will produce a `.mstat` file, a PE file which references every
type and member which is in the native binary, ***after*** inlining.
(Meaning if a member is inlined, it *won't* be present!)
Use e.g. `monodis --memberref App.mstat` to list post-trimmed members.

You can get an inkling of the "reflection metadata" that is present
by using `dotnet publish -p:IlcGenerateMetadataLog=true …`, which
produces a `.metadata.csv` file.  It's not particularly scrutible,
but can be used to verify observed behavior.  Consider one of the above
failure messages:

	The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]

An obvious question to ask: is the `TabNavigation` property in the
reflection metadata?  Search for `"TabNavigation"` (with quotes!),
and it's *not* in there.  Compare to when this commit is in use, and:

	66087019, Property, "TabNavigation", "3410be9a 6810bea8 5410beae 5410beb2"
	3410be9a, ConstantStringValue, "TabNavigation", ""

The 3rd column is the property name `TabNavigation`, while the 2nd
column is the type; for properties, we want `Property`.  The 4th
column is "Children", one of which is:

	5410beae, MethodSemantics, "Getter : [HasThis]  Microsoft.UI.Xaml.Input.KeyboardNavigationMode get_TabNavigation()", "50086c65"

which at least verifies that `TabNavigation` is in play.

Programs can control what is contained within reflection metadata
by using string constants with Reflection APIs, for example:

	typeof(SomeKnownType).GetMethod("ConstantName")

will ensure that reflection metadata contains
`SomeKnownType.ConstantName()`, and `ConstantName()` will be returned
from `typeof(SomeKnownType).GetMethods()` and can be invoked with
`MethodInfo.Invoke()`.

If you *don't* use `typeof(SomeKnownType)` or string constants with
`Type.GetType(string)` or `type.GetMethod("constant")`, then you need
to "suggest" that some pieces of information be added to
reflection metadata.

The two predominant ways to do this are via the custom attributes:

  * [`DynamicallyAccessedMembersAttribute`][2]
  * [`DynamicDependencyAttribute`][3]

From the Uno perspective, enter `BindingPropertyHelper`: *everything*
is based on Reflection!

Fortunately NativeAOT "supports" Reflection!  (See above.)

*Unfortunately*, we now need to convince NativeAOT to store the
reflection metadata Uno requires in order to work!

Various other PRs have dealt with some of this, such as #21920.

Returning to the original failure messages, e.g.

	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]

During the app build, `src/SourceGenerators/Uno.UI.SourceGenerators`
generates a `BindableMetadata.g.cs` file which will mention
`[Bindable]` types, e.g. for `Microsoft.UI.Xaml.Controls.FlipView`:

	/// <summary>
	/// Builder for Microsoft.UI.Xaml.Controls.FlipView
	/// </summary>
	[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute]
	static class MetadataBuilder_239
	{
	  internal static global::Uno.UI.DataBinding.IBindableType Build(global::Uno.UI.DataBinding.BindableType parent)
	  {
	    var bindableType = parent ?? new global::Uno.UI.DataBinding.BindableType(151, typeof(global::Microsoft.UI.Xaml.Controls.FlipView));
	    // …
	  }
	  private static object CreateInstance() => new global::Microsoft.UI.Xaml.Controls.FlipView();
	}

`BindableMetadata.g.cs` was needed in the ye olde Xamarin world order
to tell *its* linker to e.g. "preserve the `FlipView` default ctor!"

*Now*, we can build upon this infrastructure and update `BindableType`
to request that Reflection information regarding properties, fields,
and constructors be retained.  We can do this by updating the
`BindableType` constructor:

	partial class BindableType {
	  internal const DynamicallyAccessedMemberTypes TypeRequirements =
	    DynamicallyAccessedMemberTypes.PublicProperties | …;
	  public BindableType(int estimatedPropertySize, [DynamicallyAccessedMembers(TypeRequirements)] Type sourceType) => …
	}

*Because* we have `BindableMetadata.g.cs` *and* because it provides
`typeof(FlipView)`, this directs NativeAOT to make property and other
reflection metadata available to the app, *fixing* the error messages.

Expand this addition of `[DynamicallyAccessedMembers]` to also include
`BindableProperty` and related types.

Note: the IL2111 warning "Method 'System.Type.TypeInitializer.get' …"
is *caused by* `typeof(Type)` (?!), which is particularly odd given
that we don't use `Type.TypeInitializer`!
Thanks to Alexander Köplinger for [looking into this][4].

[0]: https://learn.microsoft.comdotnet/core/deploying/native-aot
[1]: https://learn.microsoft.comdotnet/core/deploying/native-aot/#limitations-of-native-aot-deployment
[2]: https://learn.microsoft.comdotnet/api/system.diagnostics.codeanalysis.dynamicallyaccessedmembersattribute?view=net-10.0
[3]: https://learn.microsoft.comdotnet/api/system.diagnostics.codeanalysis.dynamicdependencyattribute?view=net-10.0
[4]: https://discord.com/channels/732297728826277939/732297837953679412/1445773677152174150
jonpryor added a commit that referenced this pull request Dec 3, 2025
Context: unoplatform/uno.chefs#1712
Context: #21920
Context: unoplatform/uno.extensions#2966
Context: unoplatform/uno.extensions#2969
Context: https://discord.com/channels/732297728826277939/732297837953679412/1444909702512119899

While running the uno.chefs app on macOS under NativeAOT:

	dotnet publish -c Release -r osx-x64 -f net10.0-desktop -p:TargetFrameworkOverride=net10.0-desktop -bl \
	  Chefs/Chefs.csproj \
	  -p:SelfContained=true -p:PublishAot=true -p:IsAotCompatible=true -p:UseSkiaRendering=true \
	  -p:IlcGenerateMapFile=true -p:IlcGenerateMstatFile=true -p:IlcGenerateDgmlFile=true \
	  -p:EmitCompilerGeneratedFiles=true -p:CompilerGeneratedFilesOutputPath=`pwd`/_gen
	Chefs/bin/Release/net10.0-desktop/osx-x64/publish/Chefs

Console output would contain the following errors:

	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]
	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [Y] property getter does not exist on type [Windows.Foundation.Point]
	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [X] property getter does not exist on type [Windows.Foundation.Point]

At this point, a description of the relation between NativeAOT and
Reflection would be useful.

*Parts* of System.Reflection can be used.  Which parts *can* be used,
and how to use them, is oddly *not* well specified in the
[Native AOT deployment][0] documentation.

What doesn't work is outlined in the [limitations][1] section:

> * No dynamic loading, for example, `Assembly.LoadFile`.
> * No run-time code generation, for example, `System.Reflection.Emit`.

What *always* appears to work is:

  * `Type.GetType()` returns a `Type` instance.

What ***can*** work is:

  * `Type.GetType(string)`, *so long as* an assembly-qualified name
    is used as a *string constant*

        // bad
        string name = GetSomeTypeName();
        Type type = Type.GetType(name);

        // good
        Type type = Type.GetType("My.Example.TypeName, ExampleAssembly");

  * `Type.GetMethod(string)`, but see fine print below.
  * `Type.GetProperty(string)`, but see fine print below.
  * `MethodInfo.Invoke()`
  * …

**The Fine Print**: in order for many Reflection-based APIs such as
`Type.GetMethod(string)` to work, the program must contain
"reflection metadata."

We can now describe, briefly, what NativeAOT does:

 1. Accept IL/assemblies as input
 2. Internally trim the IL, optimizes them, etc.
 3. Generates a native binary containing two separate bits of data:

    * Native machine code for execution
    * "reflection metadata"

You can get an inkling of what methods survived trimming and become
native code by using `dotnet publish -p:IlcGenerateMapFile=true …`,
which will produce a `.mstat` file, a PE file which references every
type and member which is in the native binary, ***after*** inlining.
(Meaning if a member is inlined, it *won't* be present!)
Use e.g. `monodis --memberref App.mstat` to list post-trimmed members.

You can get an inkling of the "reflection metadata" that is present
by using `dotnet publish -p:IlcGenerateMetadataLog=true …`, which
produces a `.metadata.csv` file.  It's not particularly scrutible,
but can be used to verify observed behavior.  Consider one of the above
failure messages:

	The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]

An obvious question to ask: is the `TabNavigation` property in the
reflection metadata?  Search for `"TabNavigation"` (with quotes!),
and it's *not* in there.  Compare to when this commit is in use, and:

	66087019, Property, "TabNavigation", "3410be9a 6810bea8 5410beae 5410beb2"
	3410be9a, ConstantStringValue, "TabNavigation", ""

The 3rd column is the property name `TabNavigation`, while the 2nd
column is the type; for properties, we want `Property`.  The 4th
column is "Children", one of which is:

	5410beae, MethodSemantics, "Getter : [HasThis]  Microsoft.UI.Xaml.Input.KeyboardNavigationMode get_TabNavigation()", "50086c65"

which at least verifies that `TabNavigation` is in play.

Programs can control what is contained within reflection metadata
by using string constants with Reflection APIs, for example:

	typeof(SomeKnownType).GetMethod("ConstantName")

will ensure that reflection metadata contains
`SomeKnownType.ConstantName()`, and `ConstantName()` will be returned
from `typeof(SomeKnownType).GetMethods()` and can be invoked with
`MethodInfo.Invoke()`.

If you *don't* use `typeof(SomeKnownType)` or string constants with
`Type.GetType(string)` or `type.GetMethod("constant")`, then you need
to "suggest" that some pieces of information be added to
reflection metadata.

The two predominant ways to do this are via the custom attributes:

  * [`DynamicallyAccessedMembersAttribute`][2]
  * [`DynamicDependencyAttribute`][3]

From the Uno perspective, enter `BindingPropertyHelper`: *everything*
is based on Reflection!

Fortunately NativeAOT "supports" Reflection!  (See above.)

*Unfortunately*, we now need to convince NativeAOT to store the
reflection metadata Uno requires in order to work!

Various other PRs have dealt with some of this, such as #21920.

Returning to the original failure messages, e.g.

	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]

During the app build, `src/SourceGenerators/Uno.UI.SourceGenerators`
generates a `BindableMetadata.g.cs` file which will mention
`[Bindable]` types, e.g. for `Microsoft.UI.Xaml.Controls.FlipView`:

	/// <summary>
	/// Builder for Microsoft.UI.Xaml.Controls.FlipView
	/// </summary>
	[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute]
	static class MetadataBuilder_239
	{
	  internal static global::Uno.UI.DataBinding.IBindableType Build(global::Uno.UI.DataBinding.BindableType parent)
	  {
	    var bindableType = parent ?? new global::Uno.UI.DataBinding.BindableType(151, typeof(global::Microsoft.UI.Xaml.Controls.FlipView));
	    // …
	  }
	  private static object CreateInstance() => new global::Microsoft.UI.Xaml.Controls.FlipView();
	}

`BindableMetadata.g.cs` was needed in the ye olde Xamarin world order
to tell *its* linker to e.g. "preserve the `FlipView` default ctor!"

*Now*, we can build upon this infrastructure and update `BindableType`
to request that Reflection information regarding properties, fields,
and constructors be retained.  We can do this by updating the
`BindableType` constructor:

	partial class BindableType {
	  internal const DynamicallyAccessedMemberTypes TypeRequirements =
	    DynamicallyAccessedMemberTypes.PublicProperties | …;
	  public BindableType(int estimatedPropertySize, [DynamicallyAccessedMembers(TypeRequirements)] Type sourceType) => …
	}

*Because* we have `BindableMetadata.g.cs` *and* because it provides
`typeof(FlipView)`, this directs NativeAOT to make property and other
reflection metadata available to the app, *fixing* the error messages.

Expand this addition of `[DynamicallyAccessedMembers]` to also include
`BindableProperty` and related types.

Note: the IL2111 warning "Method 'System.Type.TypeInitializer.get' …"
is *caused by* `typeof(Type)` (?!), which is particularly odd given
that we don't use `Type.TypeInitializer`!
Thanks to Alexander Köplinger for [looking into this][4].

[0]: https://learn.microsoft.comdotnet/core/deploying/native-aot
[1]: https://learn.microsoft.comdotnet/core/deploying/native-aot/#limitations-of-native-aot-deployment
[2]: https://learn.microsoft.comdotnet/api/system.diagnostics.codeanalysis.dynamicallyaccessedmembersattribute?view=net-10.0
[3]: https://learn.microsoft.comdotnet/api/system.diagnostics.codeanalysis.dynamicdependencyattribute?view=net-10.0
[4]: https://discord.com/channels/732297728826277939/732297837953679412/1445773677152174150
jonpryor added a commit that referenced this pull request Dec 4, 2025
Context: unoplatform/uno.chefs#1712
Context: #21920
Context: unoplatform/uno.extensions#2966
Context: unoplatform/uno.extensions#2969
Context: https://discord.com/channels/732297728826277939/732297837953679412/1444909702512119899

While running the uno.chefs app on macOS under NativeAOT:

	dotnet publish -c Release -r osx-x64 -f net10.0-desktop -p:TargetFrameworkOverride=net10.0-desktop -bl \
	  Chefs/Chefs.csproj \
	  -p:SelfContained=true -p:PublishAot=true -p:IsAotCompatible=true -p:UseSkiaRendering=true \
	  -p:IlcGenerateMapFile=true -p:IlcGenerateMstatFile=true -p:IlcGenerateDgmlFile=true \
	  -p:EmitCompilerGeneratedFiles=true -p:CompilerGeneratedFilesOutputPath=`pwd`/_gen
	Chefs/bin/Release/net10.0-desktop/osx-x64/publish/Chefs

Console output would contain the following errors:

	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]
	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [Y] property getter does not exist on type [Windows.Foundation.Point]
	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [X] property getter does not exist on type [Windows.Foundation.Point]

At this point, a description of the relation between NativeAOT and
Reflection would be useful.

*Parts* of System.Reflection can be used.  Which parts *can* be used,
and how to use them, is oddly *not* well specified in the
[Native AOT deployment][0] documentation.

What doesn't work is outlined in the [limitations][1] section:

> * No dynamic loading, for example, `Assembly.LoadFile`.
> * No run-time code generation, for example, `System.Reflection.Emit`.

What *always* appears to work is:

  * `Type.GetType()` returns a `Type` instance.

What ***can*** work is:

  * `Type.GetType(string)`, *so long as* an assembly-qualified name
    is used as a *string constant*

        // bad
        string name = GetSomeTypeName();
        Type type = Type.GetType(name);

        // good
        Type type = Type.GetType("My.Example.TypeName, ExampleAssembly");

  * `Type.GetMethod(string)`, but see fine print below.
  * `Type.GetProperty(string)`, but see fine print below.
  * `MethodInfo.Invoke()`
  * …

**The Fine Print**: in order for many Reflection-based APIs such as
`Type.GetMethod(string)` to work, the program must contain
"reflection metadata."

We can now describe, briefly, what NativeAOT does:

 1. Accept IL/assemblies as input
 2. Internally trim the IL, optimizes them, etc.
 3. Generates a native binary containing two separate bits of data:

    * Native machine code for execution
    * "reflection metadata"

You can get an inkling of what methods survived trimming and become
native code by using `dotnet publish -p:IlcGenerateMstatFile=true …`,
which will produce a `.mstat` file, a PE file which references every
type and member which is in the native binary, ***after*** inlining.
(Meaning if a member is inlined, it *won't* be present!)
Use e.g. `monodis --memberref App.mstat` to list post-trimmed members.

You can get an inkling of the "reflection metadata" that is present
by using `dotnet publish -p:IlcGenerateMetadataLog=true …`, which
produces a `.metadata.csv` file.  It's not particularly scrutible,
but can be used to verify observed behavior.  Consider one of the above
failure messages:

	The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]

An obvious question to ask: is the `TabNavigation` property in the
reflection metadata?  Search for `"TabNavigation"` (with quotes!),
and it's *not* in there.  Compare to when this commit is in use, and:

	66087019, Property, "TabNavigation", "3410be9a 6810bea8 5410beae 5410beb2"
	3410be9a, ConstantStringValue, "TabNavigation", ""

The 3rd column is the property name `TabNavigation`, while the 2nd
column is the type; for properties, we want `Property`.  The 4th
column is "Children", one of which is:

	5410beae, MethodSemantics, "Getter : [HasThis]  Microsoft.UI.Xaml.Input.KeyboardNavigationMode get_TabNavigation()", "50086c65"

which at least verifies that `TabNavigation` is in play.

Programs can control what is contained within reflection metadata
by using string constants with Reflection APIs, for example:

	typeof(SomeKnownType).GetMethod("ConstantName")

will ensure that reflection metadata contains
`SomeKnownType.ConstantName()`, and `ConstantName()` will be returned
from `typeof(SomeKnownType).GetMethods()` and can be invoked with
`MethodInfo.Invoke()`.

If you *don't* use `typeof(SomeKnownType)` or string constants with
`Type.GetType(string)` or `type.GetMethod("constant")`, then you need
to "suggest" that some pieces of information be added to
reflection metadata.

The two predominant ways to do this are via the custom attributes:

  * [`DynamicallyAccessedMembersAttribute`][2]
  * [`DynamicDependencyAttribute`][3]

From the Uno perspective, enter `BindingPropertyHelper`: *everything*
is based on Reflection!

Fortunately NativeAOT "supports" Reflection!  (See above.)

*Unfortunately*, we now need to convince NativeAOT to store the
reflection metadata Uno requires in order to work!

Various other PRs have dealt with some of this, such as #21920.

Returning to the original failure messages, e.g.

	fail: Uno.UI.Dispatching.NativeDispatcher[0]
	      The [TabNavigation] property getter does not exist on type [Microsoft.UI.Xaml.Controls.FlipView]

During the app build, `src/SourceGenerators/Uno.UI.SourceGenerators`
generates a `BindableMetadata.g.cs` file which will mention
`[Bindable]` types, e.g. for `Microsoft.UI.Xaml.Controls.FlipView`:

	/// <summary>
	/// Builder for Microsoft.UI.Xaml.Controls.FlipView
	/// </summary>
	[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute]
	static class MetadataBuilder_239
	{
	  internal static global::Uno.UI.DataBinding.IBindableType Build(global::Uno.UI.DataBinding.BindableType parent)
	  {
	    var bindableType = parent ?? new global::Uno.UI.DataBinding.BindableType(151, typeof(global::Microsoft.UI.Xaml.Controls.FlipView));
	    // …
	  }
	  private static object CreateInstance() => new global::Microsoft.UI.Xaml.Controls.FlipView();
	}

`BindableMetadata.g.cs` was needed in the ye olde Xamarin world order
to tell *its* linker to e.g. "preserve the `FlipView` default ctor!"

*Now*, we can build upon this infrastructure and update `BindableType`
to request that Reflection information regarding properties, fields,
and constructors be retained.  We can do this by updating the
`BindableType` constructor:

	partial class BindableType {
	  internal const DynamicallyAccessedMemberTypes TypeRequirements =
	    DynamicallyAccessedMemberTypes.PublicProperties | …;
	  public BindableType(int estimatedPropertySize, [DynamicallyAccessedMembers(TypeRequirements)] Type sourceType) => …
	}

*Because* we have `BindableMetadata.g.cs` *and* because it provides
`typeof(FlipView)`, this directs NativeAOT to make property and other
reflection metadata available to the app, *fixing* the error messages.

Expand this addition of `[DynamicallyAccessedMembers]` to also include
`BindableProperty` and related types.

Note: the IL2111 warning "Method 'System.Type.TypeInitializer.get' …"
is *caused by* `typeof(Type)` (?!), which is particularly odd given
that we don't use `Type.TypeInitializer`!
Thanks to Alexander Köplinger for [looking into this][4].

[0]: https://learn.microsoft.comdotnet/core/deploying/native-aot
[1]: https://learn.microsoft.comdotnet/core/deploying/native-aot/#limitations-of-native-aot-deployment
[2]: https://learn.microsoft.comdotnet/api/system.diagnostics.codeanalysis.dynamicallyaccessedmembersattribute?view=net-10.0
[3]: https://learn.microsoft.comdotnet/api/system.diagnostics.codeanalysis.dynamicdependencyattribute?view=net-10.0
[4]: https://discord.com/channels/732297728826277939/732297837953679412/1445773677152174150
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area/code-generation Categorizes an issue or PR as relevant to code generation platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants