From 57ff7b35f13a88d33657c1a91106413cb91db9a2 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sat, 9 Nov 2019 14:33:58 +0100 Subject: [PATCH 1/2] Remove reflection usage from Shape AffectsGeometry calls. --- src/Avalonia.Controls/Shapes/Shape.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Avalonia.Controls/Shapes/Shape.cs b/src/Avalonia.Controls/Shapes/Shape.cs index 499dfb5320..1e5cdc9744 100644 --- a/src/Avalonia.Controls/Shapes/Shape.cs +++ b/src/Avalonia.Controls/Shapes/Shape.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using System.Reflection; using Avalonia.Collections; using Avalonia.Media; @@ -166,10 +165,7 @@ namespace Avalonia.Controls.Shapes { property.Changed.Subscribe(e => { - var senderType = e.Sender.GetType().GetTypeInfo(); - var affectedType = typeof(TShape).GetTypeInfo(); - - if (affectedType.IsAssignableFrom(senderType)) + if (e.Sender is TShape) { AffectsGeometryInvalidate(e); } From 45168de0289f53cf46524e256fb9b4db71ff3d71 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sat, 9 Nov 2019 14:42:28 +0100 Subject: [PATCH 2/2] Remove not needed type check. --- src/Avalonia.Controls/Shapes/Shape.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Avalonia.Controls/Shapes/Shape.cs b/src/Avalonia.Controls/Shapes/Shape.cs index 1e5cdc9744..7728302aad 100644 --- a/src/Avalonia.Controls/Shapes/Shape.cs +++ b/src/Avalonia.Controls/Shapes/Shape.cs @@ -165,9 +165,9 @@ namespace Avalonia.Controls.Shapes { property.Changed.Subscribe(e => { - if (e.Sender is TShape) + if (e.Sender is TShape shape) { - AffectsGeometryInvalidate(e); + AffectsGeometryInvalidate(shape, e); } }); } @@ -318,13 +318,8 @@ namespace Avalonia.Controls.Shapes return (size, transform); } - private static void AffectsGeometryInvalidate(AvaloniaPropertyChangedEventArgs e) + private static void AffectsGeometryInvalidate(Shape control, AvaloniaPropertyChangedEventArgs e) { - if (!(e.Sender is Shape control)) - { - return; - } - // If the geometry is invalidated when Bounds changes, only invalidate when the Size // portion changes. if (e.Property == BoundsProperty)