Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue18420.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 18420, "[Windows] ViewExtensions RotateYTo and RotateXTo with length 0 crashes on Windows", PlatformAffected.UWP)]
public class Issue18420 : ContentPage
{
int count = 0;
Button rotateButton;
public Issue18420()
{
var layout = new VerticalStackLayout
{
Spacing = 25,
Padding = new Thickness(30, 0),
VerticalOptions = LayoutOptions.Center
};

rotateButton = new Button
{
Text = "Click me to rotate",
BackgroundColor= Colors.Red,
HorizontalOptions = LayoutOptions.Center,
AutomationId= "RotateButton"
};

rotateButton.Clicked += OnRotateButtonClicked;
layout.Children.Add(rotateButton);
this.Content = layout;
}

private void OnRotateButtonClicked(object sender, EventArgs e)
{
count++;
rotateButton.RotateYTo(10 + count, 0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue18420 : _IssuesUITest
{
public Issue18420(TestDevice device) : base(device) { }

public override string Issue => "[Windows] ViewExtensions RotateYTo and RotateXTo with length 0 crashes on Windows";

[Test]
[Category(UITestCategories.ViewBaseTests)]
public void ApplyingRotationWithZeroDurationShouldNotCrash()
{
App.WaitForElement("RotateButton");
App.Tap("RotateButton");
App.Tap("RotateButton");
App.Tap("RotateButton");
App.WaitForElement("RotateButton");
}
}
6 changes: 5 additions & 1 deletion src/Core/src/Platform/Windows/TransformationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ public static void UpdateTransformation(this FrameworkElement frameworkElement,
// (i.e. their absolute value is 0), a CompositeTransform is instead used to allow for
// rotation of the control on a 2D plane, and the other values are set. Otherwise, the
// rotation values are set, but the aforementioned functionality will be lost.
if (Math.Abs(view.RotationX) != 0 || Math.Abs(view.RotationY) != 0)
if (Math.Abs(rotationX) != 0 || Math.Abs(rotationY) != 0)
{
if (double.IsNaN(rotationX) || double.IsNaN(rotationY) || double.IsNaN(rotation))
{
return;
}
frameworkElement.Projection = new PlaneProjection
{
CenterOfRotationX = anchorX,
Expand Down
Loading