From c64cc02ec68d5d5bdecc64e9001d2c09691cc43b Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Wed, 28 Aug 2019 14:06:00 +0800 Subject: [PATCH 01/13] Move transitions initializer to setter. --- src/Avalonia.Animation/Animatable.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Animation/Animatable.cs b/src/Avalonia.Animation/Animatable.cs index 3a3d00b94a..89bcd2efa5 100644 --- a/src/Avalonia.Animation/Animatable.cs +++ b/src/Avalonia.Animation/Animatable.cs @@ -44,6 +44,10 @@ namespace Avalonia.Animation public Transitions Transitions { get + { + return _transitions; + } + set { if (_transitions == null) _transitions = new Transitions(); @@ -51,10 +55,6 @@ namespace Avalonia.Animation if (_previousTransitions == null) _previousTransitions = new Dictionary(); - return _transitions; - } - set - { SetAndRaise(TransitionsProperty, ref _transitions, value); } } From 87245c90b46684a01c0c9283a40af4180002eae4 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Wed, 28 Aug 2019 14:20:43 +0800 Subject: [PATCH 02/13] Fixes: part 2 of n. --- src/Avalonia.Animation/Animatable.cs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Avalonia.Animation/Animatable.cs b/src/Avalonia.Animation/Animatable.cs index 89bcd2efa5..09991a5990 100644 --- a/src/Avalonia.Animation/Animatable.cs +++ b/src/Avalonia.Animation/Animatable.cs @@ -49,10 +49,10 @@ namespace Avalonia.Animation } set { - if (_transitions == null) - _transitions = new Transitions(); + if (value is null) + return; - if (_previousTransitions == null) + if (_previousTransitions is null) _previousTransitions = new Dictionary(); SetAndRaise(TransitionsProperty, ref _transitions, value); @@ -66,19 +66,18 @@ namespace Avalonia.Animation /// The event args. protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs e) { - if (e.Priority != BindingPriority.Animation && Transitions != null && _previousTransitions != null) - { - var match = Transitions.FirstOrDefault(x => x.Property == e.Property); + if (Transitions is null || e.Priority == BindingPriority.Animation) return; + + var match = Transitions.FirstOrDefault(x => x.Property == e.Property); - if (match != null) - { - if (_previousTransitions.TryGetValue(e.Property, out var dispose)) - dispose.Dispose(); + if (match != null) + { + if (_previousTransitions.TryGetValue(e.Property, out var dispose)) + dispose.Dispose(); - var instance = match.Apply(this, Clock ?? Avalonia.Animation.Clock.GlobalClock, e.OldValue, e.NewValue); + var instance = match.Apply(this, Clock ?? Avalonia.Animation.Clock.GlobalClock, e.OldValue, e.NewValue); - _previousTransitions[e.Property] = instance; - } + _previousTransitions[e.Property] = instance; } } } From d176b1d7dc10e22137a21b7e2cf1836ec4cd2e27 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 29 Aug 2019 12:34:03 +0800 Subject: [PATCH 03/13] Fix unit tests. --- src/Avalonia.Animation/Animatable.cs | 4 ++-- tests/Avalonia.Animation.UnitTests/TransitionsTests.cs | 4 ++-- tests/Avalonia.LeakTests/TransitionTests.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Animation/Animatable.cs b/src/Avalonia.Animation/Animatable.cs index 09991a5990..5ff3b17fb5 100644 --- a/src/Avalonia.Animation/Animatable.cs +++ b/src/Avalonia.Animation/Animatable.cs @@ -35,7 +35,7 @@ namespace Avalonia.Animation (o, v) => o.Transitions = v); private Transitions _transitions; - + private bool _isTransitionsSet = false; private Dictionary _previousTransitions; /// @@ -66,7 +66,7 @@ namespace Avalonia.Animation /// The event args. protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs e) { - if (Transitions is null || e.Priority == BindingPriority.Animation) return; + if (_transitions is null || _previousTransitions is null || e.Priority == BindingPriority.Animation) return; var match = Transitions.FirstOrDefault(x => x.Property == e.Property); diff --git a/tests/Avalonia.Animation.UnitTests/TransitionsTests.cs b/tests/Avalonia.Animation.UnitTests/TransitionsTests.cs index f1b4b0d071..a8efc2c8ae 100644 --- a/tests/Avalonia.Animation.UnitTests/TransitionsTests.cs +++ b/tests/Avalonia.Animation.UnitTests/TransitionsTests.cs @@ -23,7 +23,7 @@ namespace Avalonia.Animation.UnitTests { var border = new Border { - Transitions = + Transitions = new Transitions { new DoubleTransition { @@ -51,7 +51,7 @@ namespace Avalonia.Animation.UnitTests { var border = new Border { - Transitions = + Transitions = new Transitions { new DoubleTransition { diff --git a/tests/Avalonia.LeakTests/TransitionTests.cs b/tests/Avalonia.LeakTests/TransitionTests.cs index c7add1fe11..699dec7229 100644 --- a/tests/Avalonia.LeakTests/TransitionTests.cs +++ b/tests/Avalonia.LeakTests/TransitionTests.cs @@ -27,7 +27,7 @@ namespace Avalonia.LeakTests { var border = new Border { - Transitions = + Transitions = new Transitions { new DoubleTransition { From 50a8fc3571d6d911ccbca80ec4bc504c2385e943 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Thu, 5 Sep 2019 23:28:33 +0200 Subject: [PATCH 04/13] Get rid of pointless allocations in PriorityBindingEntry. --- src/Avalonia.Base/PriorityBindingEntry.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Base/PriorityBindingEntry.cs b/src/Avalonia.Base/PriorityBindingEntry.cs index d4a47306a7..95add0dfac 100644 --- a/src/Avalonia.Base/PriorityBindingEntry.cs +++ b/src/Avalonia.Base/PriorityBindingEntry.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; +using System.Runtime.ExceptionServices; using Avalonia.Data; using Avalonia.Threading; @@ -10,9 +11,9 @@ namespace Avalonia /// /// A registered binding in a . /// - internal class PriorityBindingEntry : IDisposable + internal class PriorityBindingEntry : IDisposable, IObserver { - private PriorityLevel _owner; + private readonly PriorityLevel _owner; private IDisposable _subscription; /// @@ -85,7 +86,7 @@ namespace Avalonia Description = ((IDescription)binding).Description; } - _subscription = binding.Subscribe(ValueChanged, Completed); + _subscription = binding.Subscribe(this); } /// @@ -96,7 +97,7 @@ namespace Avalonia _subscription?.Dispose(); } - private void ValueChanged(object value) + void IObserver.OnNext(object value) { void Signal() { @@ -132,7 +133,7 @@ namespace Avalonia } } - private void Completed() + void IObserver.OnCompleted() { HasCompleted = true; @@ -145,5 +146,10 @@ namespace Avalonia Dispatcher.UIThread.Post(() => _owner.Completed(this)); } } + + void IObserver.OnError(Exception error) + { + ExceptionDispatchInfo.Capture(error).Throw(); + } } } From 04c2dfcc5484891761522764a8359e3b73638c9b Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 8 Sep 2019 14:26:35 +0200 Subject: [PATCH 05/13] Compiled expressions for RoutedEvent. --- .../EventSubscription.cs | 4 +++ src/Avalonia.Interactivity/Interactive.cs | 26 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Interactivity/EventSubscription.cs b/src/Avalonia.Interactivity/EventSubscription.cs index 9f763edcd3..ff2a28e570 100644 --- a/src/Avalonia.Interactivity/EventSubscription.cs +++ b/src/Avalonia.Interactivity/EventSubscription.cs @@ -5,8 +5,12 @@ using System; namespace Avalonia.Interactivity { + internal delegate void InvokeSignature(Delegate func, object sender, RoutedEventArgs args); + internal class EventSubscription { + public InvokeSignature RaiseHandler { get; set; } + public Delegate Handler { get; set; } public RoutingStrategies Routes { get; set; } diff --git a/src/Avalonia.Interactivity/Interactive.cs b/src/Avalonia.Interactivity/Interactive.cs index 911fc2130e..033686a8c8 100644 --- a/src/Avalonia.Interactivity/Interactive.cs +++ b/src/Avalonia.Interactivity/Interactive.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Reactive.Disposables; using System.Reactive.Linq; using Avalonia.Layout; @@ -28,6 +29,10 @@ namespace Avalonia.Interactivity get { return _eventHandlers ?? (_eventHandlers = new Dictionary>()); } } + + + private static Dictionary s_invokeCache = new Dictionary(); + /// /// Adds a handler for the specified routed event. /// @@ -53,8 +58,27 @@ namespace Avalonia.Interactivity EventHandlers.Add(routedEvent, subscriptions); } + if (!s_invokeCache.TryGetValue(routedEvent.EventArgsType, out InvokeSignature raiseFunc)) + { + ParameterExpression funcParameter = Expression.Parameter(typeof(Delegate), "func"); + ParameterExpression senderParameter = Expression.Parameter(typeof(object), "sender"); + ParameterExpression argsParameter = Expression.Parameter(typeof(RoutedEventArgs), "args"); + + UnaryExpression convertedFunc = Expression.Convert(funcParameter, typeof(EventHandler<>).MakeGenericType(routedEvent.EventArgsType)); + UnaryExpression convertedArgs = Expression.Convert(argsParameter, routedEvent.EventArgsType); + + InvocationExpression invokeDelegate = Expression.Invoke(convertedFunc, senderParameter, convertedArgs); + + raiseFunc = Expression + .Lambda(invokeDelegate, funcParameter, senderParameter, argsParameter) + .Compile(); + + s_invokeCache.Add(routedEvent.EventArgsType, raiseFunc); + } + var sub = new EventSubscription { + RaiseHandler = raiseFunc, Handler = handler, Routes = routes, AlsoIfHandled = handledEventsToo, @@ -196,7 +220,7 @@ namespace Avalonia.Interactivity if (correctRoute && notFinished) { - sub.Handler.DynamicInvoke(this, e); + sub.RaiseHandler(sub.Handler, this, e); } } } From 64fdb5828ee6943a5add0f2877bcb29a1de32361 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Mon, 9 Sep 2019 02:02:54 +0800 Subject: [PATCH 06/13] un-LINQ the Transition property matching codepath. --- src/Avalonia.Animation/Animatable.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Animation/Animatable.cs b/src/Avalonia.Animation/Animatable.cs index 5ff3b17fb5..3f548d207d 100644 --- a/src/Avalonia.Animation/Animatable.cs +++ b/src/Avalonia.Animation/Animatable.cs @@ -68,16 +68,19 @@ namespace Avalonia.Animation { if (_transitions is null || _previousTransitions is null || e.Priority == BindingPriority.Animation) return; - var match = Transitions.FirstOrDefault(x => x.Property == e.Property); - - if (match != null) + // PERF-SENSITIVE: Called on every property change. Don't use LINQ here (too many allocations). + foreach (var transition in Transitions) { - if (_previousTransitions.TryGetValue(e.Property, out var dispose)) - dispose.Dispose(); + if (transition.Property == e.Property) + { + if (_previousTransitions.TryGetValue(e.Property, out var dispose)) + dispose.Dispose(); - var instance = match.Apply(this, Clock ?? Avalonia.Animation.Clock.GlobalClock, e.OldValue, e.NewValue); + var instance = transition.Apply(this, Clock ?? Avalonia.Animation.Clock.GlobalClock, e.OldValue, e.NewValue); - _previousTransitions[e.Property] = instance; + _previousTransitions[e.Property] = instance; + return; + } } } } From b8e4909b104423cb7163b3fbb8ea75b8c466c997 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Mon, 9 Sep 2019 02:18:47 +0800 Subject: [PATCH 07/13] Restore Lazy Init to avoid API break. --- src/Avalonia.Animation/Animatable.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Animation/Animatable.cs b/src/Avalonia.Animation/Animatable.cs index 3f548d207d..68ca03f910 100644 --- a/src/Avalonia.Animation/Animatable.cs +++ b/src/Avalonia.Animation/Animatable.cs @@ -45,15 +45,16 @@ namespace Avalonia.Animation { get { + if (_transitions is null) + _transitions = new Transitions(); + + if (_previousTransitions is null) + _previousTransitions = new Dictionary(); + return _transitions; } set { - if (value is null) - return; - - if (_previousTransitions is null) - _previousTransitions = new Dictionary(); SetAndRaise(TransitionsProperty, ref _transitions, value); } From 3549f00fcba37fffe35c827fc20ded88743f8250 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Mon, 9 Sep 2019 02:19:25 +0800 Subject: [PATCH 08/13] Revert unit test changes. --- tests/Avalonia.Animation.UnitTests/TransitionsTests.cs | 4 ++-- tests/Avalonia.LeakTests/TransitionTests.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Avalonia.Animation.UnitTests/TransitionsTests.cs b/tests/Avalonia.Animation.UnitTests/TransitionsTests.cs index a8efc2c8ae..4ebe472125 100644 --- a/tests/Avalonia.Animation.UnitTests/TransitionsTests.cs +++ b/tests/Avalonia.Animation.UnitTests/TransitionsTests.cs @@ -23,7 +23,7 @@ namespace Avalonia.Animation.UnitTests { var border = new Border { - Transitions = new Transitions + Transitions = { new DoubleTransition { @@ -51,7 +51,7 @@ namespace Avalonia.Animation.UnitTests { var border = new Border { - Transitions = new Transitions + Transitions = { new DoubleTransition { diff --git a/tests/Avalonia.LeakTests/TransitionTests.cs b/tests/Avalonia.LeakTests/TransitionTests.cs index 699dec7229..5ab8c5c0dd 100644 --- a/tests/Avalonia.LeakTests/TransitionTests.cs +++ b/tests/Avalonia.LeakTests/TransitionTests.cs @@ -27,7 +27,7 @@ namespace Avalonia.LeakTests { var border = new Border { - Transitions = new Transitions + Transitions = { new DoubleTransition { From 4a7f370fc520413a4c59709c8c10ab25048722e9 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 8 Sep 2019 20:23:38 +0200 Subject: [PATCH 09/13] Cleanup. --- src/Avalonia.Interactivity/Interactive.cs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Avalonia.Interactivity/Interactive.cs b/src/Avalonia.Interactivity/Interactive.cs index 033686a8c8..59dfbcb8ab 100644 --- a/src/Avalonia.Interactivity/Interactive.cs +++ b/src/Avalonia.Interactivity/Interactive.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Reactive.Disposables; -using System.Reactive.Linq; using Avalonia.Layout; using Avalonia.VisualTree; @@ -19,19 +18,14 @@ namespace Avalonia.Interactivity { private Dictionary> _eventHandlers; + private static readonly Dictionary s_invokeCache = new Dictionary(); + /// /// Gets the interactive parent of the object for bubbling and tunneling events. /// IInteractive IInteractive.InteractiveParent => ((IVisual)this).VisualParent as IInteractive; - private Dictionary> EventHandlers - { - get { return _eventHandlers ?? (_eventHandlers = new Dictionary>()); } - } - - - - private static Dictionary s_invokeCache = new Dictionary(); + private Dictionary> EventHandlers => _eventHandlers ?? (_eventHandlers = new Dictionary>()); /// /// Adds a handler for the specified routed event. @@ -58,14 +52,16 @@ namespace Avalonia.Interactivity EventHandlers.Add(routedEvent, subscriptions); } - if (!s_invokeCache.TryGetValue(routedEvent.EventArgsType, out InvokeSignature raiseFunc)) + Type eventArgsType = routedEvent.EventArgsType; + + if (!s_invokeCache.TryGetValue(eventArgsType, out InvokeSignature raiseFunc)) { ParameterExpression funcParameter = Expression.Parameter(typeof(Delegate), "func"); ParameterExpression senderParameter = Expression.Parameter(typeof(object), "sender"); ParameterExpression argsParameter = Expression.Parameter(typeof(RoutedEventArgs), "args"); - UnaryExpression convertedFunc = Expression.Convert(funcParameter, typeof(EventHandler<>).MakeGenericType(routedEvent.EventArgsType)); - UnaryExpression convertedArgs = Expression.Convert(argsParameter, routedEvent.EventArgsType); + UnaryExpression convertedFunc = Expression.Convert(funcParameter, typeof(EventHandler<>).MakeGenericType(eventArgsType)); + UnaryExpression convertedArgs = Expression.Convert(argsParameter, eventArgsType); InvocationExpression invokeDelegate = Expression.Invoke(convertedFunc, senderParameter, convertedArgs); @@ -73,7 +69,7 @@ namespace Avalonia.Interactivity .Lambda(invokeDelegate, funcParameter, senderParameter, argsParameter) .Compile(); - s_invokeCache.Add(routedEvent.EventArgsType, raiseFunc); + s_invokeCache.Add(eventArgsType, raiseFunc); } var sub = new EventSubscription From 5cae6bee7b94253df022fe20ecf48bd4f3660780 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 8 Sep 2019 21:55:17 +0200 Subject: [PATCH 10/13] Simplify creation of invoke adapters. --- .../EventSubscription.cs | 2 +- src/Avalonia.Interactivity/Interactive.cs | 115 ++++++++++++------ 2 files changed, 79 insertions(+), 38 deletions(-) diff --git a/src/Avalonia.Interactivity/EventSubscription.cs b/src/Avalonia.Interactivity/EventSubscription.cs index ff2a28e570..b495142998 100644 --- a/src/Avalonia.Interactivity/EventSubscription.cs +++ b/src/Avalonia.Interactivity/EventSubscription.cs @@ -9,7 +9,7 @@ namespace Avalonia.Interactivity internal class EventSubscription { - public InvokeSignature RaiseHandler { get; set; } + public InvokeSignature InvokeAdapter { get; set; } public Delegate Handler { get; set; } diff --git a/src/Avalonia.Interactivity/Interactive.cs b/src/Avalonia.Interactivity/Interactive.cs index 59dfbcb8ab..0f607241ec 100644 --- a/src/Avalonia.Interactivity/Interactive.cs +++ b/src/Avalonia.Interactivity/Interactive.cs @@ -4,8 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; -using System.Reactive.Disposables; using Avalonia.Layout; using Avalonia.VisualTree; @@ -44,45 +42,14 @@ namespace Avalonia.Interactivity Contract.Requires(routedEvent != null); Contract.Requires(handler != null); - List subscriptions; - - if (!EventHandlers.TryGetValue(routedEvent, out subscriptions)) - { - subscriptions = new List(); - EventHandlers.Add(routedEvent, subscriptions); - } - - Type eventArgsType = routedEvent.EventArgsType; - - if (!s_invokeCache.TryGetValue(eventArgsType, out InvokeSignature raiseFunc)) - { - ParameterExpression funcParameter = Expression.Parameter(typeof(Delegate), "func"); - ParameterExpression senderParameter = Expression.Parameter(typeof(object), "sender"); - ParameterExpression argsParameter = Expression.Parameter(typeof(RoutedEventArgs), "args"); - - UnaryExpression convertedFunc = Expression.Convert(funcParameter, typeof(EventHandler<>).MakeGenericType(eventArgsType)); - UnaryExpression convertedArgs = Expression.Convert(argsParameter, eventArgsType); - - InvocationExpression invokeDelegate = Expression.Invoke(convertedFunc, senderParameter, convertedArgs); - - raiseFunc = Expression - .Lambda(invokeDelegate, funcParameter, senderParameter, argsParameter) - .Compile(); - - s_invokeCache.Add(eventArgsType, raiseFunc); - } - - var sub = new EventSubscription + var subscription = new EventSubscription { - RaiseHandler = raiseFunc, Handler = handler, Routes = routes, AlsoIfHandled = handledEventsToo, }; - subscriptions.Add(sub); - - return Disposable.Create(() => subscriptions.Remove(sub)); + return AddEventSubscription(routedEvent, subscription); } /// @@ -100,7 +67,37 @@ namespace Avalonia.Interactivity RoutingStrategies routes = RoutingStrategies.Direct | RoutingStrategies.Bubble, bool handledEventsToo = false) where TEventArgs : RoutedEventArgs { - return AddHandler(routedEvent, (Delegate)handler, routes, handledEventsToo); + Contract.Requires(routedEvent != null); + Contract.Requires(handler != null); + + // EventHandler delegate is not covariant, this forces us to create small wrapper + // that will cast our type erased instance and invoke it. + Type eventArgsType = routedEvent.EventArgsType; + + if (!s_invokeCache.TryGetValue(eventArgsType, out var invokeAdapter)) + { + void InvokeAdapter(Delegate func, object sender, RoutedEventArgs args) + { + var typedHandler = (EventHandler)func; + var typedArgs = (TEventArgs)args; + + typedHandler(sender, typedArgs); + } + + invokeAdapter = InvokeAdapter; + + s_invokeCache.Add(eventArgsType, invokeAdapter); + } + + var subscription = new EventSubscription + { + InvokeAdapter = invokeAdapter, + Handler = handler, + Routes = routes, + AlsoIfHandled = handledEventsToo, + }; + + return AddEventSubscription(routedEvent, subscription); } /// @@ -216,10 +213,54 @@ namespace Avalonia.Interactivity if (correctRoute && notFinished) { - sub.RaiseHandler(sub.Handler, this, e); + if (sub.InvokeAdapter != null) + { + sub.InvokeAdapter(sub.Handler, this, e); + } + else + { + sub.Handler.DynamicInvoke(this, e); + } } } } } + + private List GetEventSubscriptions(RoutedEvent routedEvent) + { + if (!EventHandlers.TryGetValue(routedEvent, out var subscriptions)) + { + subscriptions = new List(); + EventHandlers.Add(routedEvent, subscriptions); + } + + return subscriptions; + } + + private IDisposable AddEventSubscription(RoutedEvent routedEvent, EventSubscription subscription) + { + List subscriptions = GetEventSubscriptions(routedEvent); + + subscriptions.Add(subscription); + + return new UnsubscribeDisposable(subscriptions, subscription); + } + + private sealed class UnsubscribeDisposable : IDisposable + { + private readonly List _subscriptions; + private readonly EventSubscription _subscription; + + public UnsubscribeDisposable(List subscriptions, EventSubscription subscription) + { + _subscriptions = subscriptions; + _subscription = subscription; + } + + public void Dispose() + { + _subscriptions.Remove(_subscription); + } + } } } From f5b317decbf7bededba9d4746a09261d6e6c1aa4 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 8 Sep 2019 22:33:39 +0200 Subject: [PATCH 11/13] Naming. --- src/Avalonia.Interactivity/EventSubscription.cs | 4 ++-- src/Avalonia.Interactivity/Interactive.cs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Interactivity/EventSubscription.cs b/src/Avalonia.Interactivity/EventSubscription.cs index b495142998..e8fb1bfaf1 100644 --- a/src/Avalonia.Interactivity/EventSubscription.cs +++ b/src/Avalonia.Interactivity/EventSubscription.cs @@ -5,11 +5,11 @@ using System; namespace Avalonia.Interactivity { - internal delegate void InvokeSignature(Delegate func, object sender, RoutedEventArgs args); + internal delegate void HandlerInvokeSignature(Delegate baseHandler, object sender, RoutedEventArgs args); internal class EventSubscription { - public InvokeSignature InvokeAdapter { get; set; } + public HandlerInvokeSignature InvokeAdapter { get; set; } public Delegate Handler { get; set; } diff --git a/src/Avalonia.Interactivity/Interactive.cs b/src/Avalonia.Interactivity/Interactive.cs index 0f607241ec..f8d388ec89 100644 --- a/src/Avalonia.Interactivity/Interactive.cs +++ b/src/Avalonia.Interactivity/Interactive.cs @@ -16,7 +16,7 @@ namespace Avalonia.Interactivity { private Dictionary> _eventHandlers; - private static readonly Dictionary s_invokeCache = new Dictionary(); + private static readonly Dictionary s_invokeHandlerCache = new Dictionary(); /// /// Gets the interactive parent of the object for bubbling and tunneling events. @@ -74,11 +74,11 @@ namespace Avalonia.Interactivity // that will cast our type erased instance and invoke it. Type eventArgsType = routedEvent.EventArgsType; - if (!s_invokeCache.TryGetValue(eventArgsType, out var invokeAdapter)) + if (!s_invokeHandlerCache.TryGetValue(eventArgsType, out var invokeAdapter)) { - void InvokeAdapter(Delegate func, object sender, RoutedEventArgs args) + void InvokeAdapter(Delegate baseHandler, object sender, RoutedEventArgs args) { - var typedHandler = (EventHandler)func; + var typedHandler = (EventHandler)baseHandler; var typedArgs = (TEventArgs)args; typedHandler(sender, typedArgs); @@ -86,7 +86,7 @@ namespace Avalonia.Interactivity invokeAdapter = InvokeAdapter; - s_invokeCache.Add(eventArgsType, invokeAdapter); + s_invokeHandlerCache.Add(eventArgsType, invokeAdapter); } var subscription = new EventSubscription From d368d9675a17beb045e1e94dce880ee2f0b45042 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Mon, 9 Sep 2019 14:25:59 +0800 Subject: [PATCH 12/13] Address review. --- src/Avalonia.Animation/Animatable.cs | 2 +- tests/Avalonia.Animation.UnitTests/TransitionsTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Animation/Animatable.cs b/src/Avalonia.Animation/Animatable.cs index 68ca03f910..2c321b8b28 100644 --- a/src/Avalonia.Animation/Animatable.cs +++ b/src/Avalonia.Animation/Animatable.cs @@ -35,7 +35,7 @@ namespace Avalonia.Animation (o, v) => o.Transitions = v); private Transitions _transitions; - private bool _isTransitionsSet = false; + private Dictionary _previousTransitions; /// diff --git a/tests/Avalonia.Animation.UnitTests/TransitionsTests.cs b/tests/Avalonia.Animation.UnitTests/TransitionsTests.cs index 4ebe472125..f1b4b0d071 100644 --- a/tests/Avalonia.Animation.UnitTests/TransitionsTests.cs +++ b/tests/Avalonia.Animation.UnitTests/TransitionsTests.cs @@ -23,7 +23,7 @@ namespace Avalonia.Animation.UnitTests { var border = new Border { - Transitions = + Transitions = { new DoubleTransition { @@ -51,7 +51,7 @@ namespace Avalonia.Animation.UnitTests { var border = new Border { - Transitions = + Transitions = { new DoubleTransition { From 9970bf67223624c33d751f3aa7c9f8726aed7d0c Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Mon, 9 Sep 2019 14:38:53 +0800 Subject: [PATCH 13/13] Address review pt. 2 --- tests/Avalonia.LeakTests/TransitionTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Avalonia.LeakTests/TransitionTests.cs b/tests/Avalonia.LeakTests/TransitionTests.cs index 5ab8c5c0dd..c7add1fe11 100644 --- a/tests/Avalonia.LeakTests/TransitionTests.cs +++ b/tests/Avalonia.LeakTests/TransitionTests.cs @@ -27,7 +27,7 @@ namespace Avalonia.LeakTests { var border = new Border { - Transitions = + Transitions = { new DoubleTransition {