-
Couldn't load subscription status.
- Fork 773
Description
Describe the bug
When NativeAOT is enabled, accessing NonClientRegionsChangedEventArgs.ChangedRegions in my InputNonClientPointerSource.RegionsChanged event handler, it throws System.NotSupportedException with message "Cannot handle array marshalling for non blittable type 'Microsoft.UI.Input.NonClientRegionKind'.". But it works properly without NativeAOT.
Why is this important?
- Non-client regions set by
InputNonClientPointerSource.SetRegionRectswill become 0×0 rects unexpectedly, for example, when the title bar area set byWindow.SetTitleBarandInputNonClientPointerSource.SetRegionRectswithNonClientKind.Captiondragged and clicked. It is also mentioned at Setting the maximize region of a win32 window using InputNonClientPointerSource secretly reverts back to default #10379 . HandlingInputNonClientPointerSource.RegionsChangedevent is a feasible way to remedy this issue. - NativeAOT is a good feature.
Steps to reproduce the bug
- Create a new C# WinUI 3 project.
- Enable "Publish Native AOT" in the project property settings.
- Handle
InputNonClientPointerSource.RegionsChangedevent and accessNonClientRegionsChangedEventArgs.ChangedRegions.
public sealed partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
ExtendsContentIntoTitleBar = true;
_inputNonClientPointerSource = InputNonClientPointerSource.GetForWindowId(AppWindow.Id);
_inputNonClientPointerSource.RegionsChanged += OnNonClientRegionsChanged;
}
private void OnNonClientRegionsChanged(InputNonClientPointerSource sender, NonClientRegionsChangedEventArgs args)
{
NonClientRegionKind[] changedRegions = args.ChangedRegions;
}
private readonly InputNonClientPointerSource _inputNonClientPointerSource;
}Actual behavior
System.NotSupportedException is thrown at NonClientRegionKind[] changedRegions = args.ChangedRegions with message: "Cannot handle array marshalling for non blittable type 'Microsoft.UI.Input.NonClientRegionKind'".
Expected behavior
Cause no exceptions.
Screenshots
NuGet package version
WinUI 3 - Windows App SDK 1.8.1: 1.8.250916003
Windows version
Windows 11 (24H2): Build 26100
Additional context
No response