From f9dbbb3da1d42b6450ac10b6485d118fcc5fa0aa Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 20 Apr 2022 16:35:53 +0200 Subject: [PATCH 1/5] Make UpdateDataValidation non-generic. --- src/Avalonia.Base/AvaloniaObject.cs | 12 ++++---- src/Avalonia.Controls/AutoCompleteBox.cs | 10 +++++-- src/Avalonia.Controls/Button.cs | 9 ++++-- .../Calendar/CalendarDatePicker.cs | 4 +-- src/Avalonia.Controls/MenuItem.cs | 9 ++++-- .../NumericUpDown/NumericUpDown.cs | 10 +++++-- .../Primitives/SelectingItemsControl.cs | 10 +++++-- src/Avalonia.Controls/Slider.cs | 7 +++-- src/Avalonia.Controls/TextBox.cs | 7 +++-- .../AvaloniaObjectTests_DataValidation.cs | 28 +++++++++---------- 10 files changed, 66 insertions(+), 40 deletions(-) diff --git a/src/Avalonia.Base/AvaloniaObject.cs b/src/Avalonia.Base/AvaloniaObject.cs index bc1e95805fc..1f14ddede41 100644 --- a/src/Avalonia.Base/AvaloniaObject.cs +++ b/src/Avalonia.Base/AvaloniaObject.cs @@ -646,10 +646,12 @@ protected internal virtual void LogBindingError(AvaloniaProperty property, Excep /// enabled. /// /// The property. - /// The new binding value for the property. - protected virtual void UpdateDataValidation( - AvaloniaProperty property, - BindingValue value) + /// The current data binding state. + /// The current data binding error, if any. + protected virtual void UpdateDataValidation( + AvaloniaProperty property, + BindingValueType state, + Exception? error) { } @@ -860,7 +862,7 @@ private void SetDirectValueUnchecked(DirectPropertyBase property, BindingV if (metadata.EnableDataValidation == true) { - UpdateDataValidation(property, value); + UpdateDataValidation(property, value.Type, value.Error); } } diff --git a/src/Avalonia.Controls/AutoCompleteBox.cs b/src/Avalonia.Controls/AutoCompleteBox.cs index 3316c06bf52..5c95932c1f9 100644 --- a/src/Avalonia.Controls/AutoCompleteBox.cs +++ b/src/Avalonia.Controls/AutoCompleteBox.cs @@ -1346,12 +1346,16 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e) /// enabled. /// /// The property. - /// The new binding value for the property. - protected override void UpdateDataValidation(AvaloniaProperty property, BindingValue value) + /// The current data binding state. + /// The current data binding error, if any. + protected override void UpdateDataValidation( + AvaloniaProperty property, + BindingValueType state, + Exception? error) { if (property == TextProperty || property == SelectedItemProperty) { - DataValidationErrors.SetError(this, value.Error); + DataValidationErrors.SetError(this, error); } } diff --git a/src/Avalonia.Controls/Button.cs b/src/Avalonia.Controls/Button.cs index a4a147e0f32..0ef1ba4c8cd 100644 --- a/src/Avalonia.Controls/Button.cs +++ b/src/Avalonia.Controls/Button.cs @@ -498,12 +498,15 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang protected override AutomationPeer OnCreateAutomationPeer() => new ButtonAutomationPeer(this); /// - protected override void UpdateDataValidation(AvaloniaProperty property, BindingValue value) + protected override void UpdateDataValidation( + AvaloniaProperty property, + BindingValueType state, + Exception? error) { - base.UpdateDataValidation(property, value); + base.UpdateDataValidation(property, state, error); if (property == CommandProperty) { - if (value.Type == BindingValueType.BindingError) + if (state == BindingValueType.BindingError) { if (_commandCanExecute) { diff --git a/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs b/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs index 0ac2056ed1b..0409eb30aaf 100644 --- a/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs +++ b/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs @@ -540,11 +540,11 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e) } } - protected override void UpdateDataValidation(AvaloniaProperty property, BindingValue value) + protected override void UpdateDataValidation(AvaloniaProperty property, BindingValueType state, Exception? error) { if (property == SelectedDateProperty) { - DataValidationErrors.SetError(this, value.Error); + DataValidationErrors.SetError(this, error); } } diff --git a/src/Avalonia.Controls/MenuItem.cs b/src/Avalonia.Controls/MenuItem.cs index 955af8888be..619eafb71b8 100644 --- a/src/Avalonia.Controls/MenuItem.cs +++ b/src/Avalonia.Controls/MenuItem.cs @@ -501,12 +501,15 @@ protected override AutomationPeer OnCreateAutomationPeer() return new MenuItemAutomationPeer(this); } - protected override void UpdateDataValidation(AvaloniaProperty property, BindingValue value) + protected override void UpdateDataValidation( + AvaloniaProperty property, + BindingValueType state, + Exception? error) { - base.UpdateDataValidation(property, value); + base.UpdateDataValidation(property, state, error); if (property == CommandProperty) { - _commandBindingError = value.Type == BindingValueType.BindingError; + _commandBindingError = state == BindingValueType.BindingError; if (_commandBindingError && _commandCanExecute) { _commandCanExecute = false; diff --git a/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs b/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs index fbbaab61824..4d86a0f17c1 100644 --- a/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs +++ b/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs @@ -403,12 +403,16 @@ protected override void OnKeyDown(KeyEventArgs e) /// enabled. /// /// The property. - /// The new binding value for the property. - protected override void UpdateDataValidation(AvaloniaProperty property, BindingValue value) + /// The current data binding state. + /// The current data binding error, if any. + protected override void UpdateDataValidation( + AvaloniaProperty property, + BindingValueType state, + Exception? error) { if (property == TextProperty || property == ValueProperty) { - DataValidationErrors.SetError(this, value.Error); + DataValidationErrors.SetError(this, error); } } diff --git a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs index 6f2554bef37..bff67997924 100644 --- a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs +++ b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs @@ -501,12 +501,16 @@ protected override void OnDataContextEndUpdate() /// enabled. /// /// The property. - /// The new binding value for the property. - protected override void UpdateDataValidation(AvaloniaProperty property, BindingValue value) + /// The current data binding state. + /// The current data binding error, if any. + protected override void UpdateDataValidation( + AvaloniaProperty property, + BindingValueType state, + Exception? error) { if (property == SelectedItemProperty) { - DataValidationErrors.SetError(this, value.Error); + DataValidationErrors.SetError(this, error); } } diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs index f0a0fba1af2..64dfce22d48 100644 --- a/src/Avalonia.Controls/Slider.cs +++ b/src/Avalonia.Controls/Slider.cs @@ -361,11 +361,14 @@ private void MoveToPoint(PointerPoint posOnTrack) Value = IsSnapToTickEnabled ? SnapToTick(finalValue) : finalValue; } - protected override void UpdateDataValidation(AvaloniaProperty property, BindingValue value) + protected override void UpdateDataValidation( + AvaloniaProperty property, + BindingValueType state, + Exception? error) { if (property == ValueProperty) { - DataValidationErrors.SetError(this, value.Error); + DataValidationErrors.SetError(this, error); } } diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 1f3dbc87db8..0be58e7fcc9 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -1262,11 +1262,14 @@ protected override AutomationPeer OnCreateAutomationPeer() return new TextBoxAutomationPeer(this); } - protected override void UpdateDataValidation(AvaloniaProperty property, BindingValue value) + protected override void UpdateDataValidation( + AvaloniaProperty property, + BindingValueType state, + Exception? error) { if (property == TextProperty) { - DataValidationErrors.SetError(this, value.Error); + DataValidationErrors.SetError(this, error); } } diff --git a/tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_DataValidation.cs b/tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_DataValidation.cs index 65f03b3ecae..d48e58136a7 100644 --- a/tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_DataValidation.cs +++ b/tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_DataValidation.cs @@ -52,14 +52,14 @@ public void Binding_Validated_Direct_Property_Calls_UpdateDataValidation() source.OnNext(BindingValue.DataValidationError(new Exception())); source.OnNext(7); - var result = target.Notifications.Cast>().ToList(); + var result = target.Notifications; Assert.Equal(4, result.Count); - Assert.Equal(BindingValueType.Value, result[0].Type); - Assert.Equal(6, result[0].Value); - Assert.Equal(BindingValueType.BindingError, result[1].Type); - Assert.Equal(BindingValueType.DataValidationError, result[2].Type); - Assert.Equal(BindingValueType.Value, result[3].Type); - Assert.Equal(7, result[3].Value); + Assert.Equal(BindingValueType.Value, result[0].type); + Assert.Equal(6, result[0].value); + Assert.Equal(BindingValueType.BindingError, result[1].type); + Assert.Equal(BindingValueType.DataValidationError, result[2].type); + Assert.Equal(BindingValueType.Value, result[3].type); + Assert.Equal(7, result[3].value); } [Fact] @@ -72,8 +72,7 @@ public void Binding_Overridden_Validated_Direct_Property_Calls_UpdateDataValidat target.Bind(Class1.NonValidatedDirectProperty, source); source.OnNext(1); - var result = target.Notifications.Cast>().ToList(); - Assert.Equal(1, result.Count); + Assert.Equal(1, target.Notifications.Count); } [Fact] @@ -154,13 +153,14 @@ public string ValidatedDirectString set { SetAndRaise(ValidatedDirectStringProperty, ref _directString, value); } } - public IList Notifications { get; } = new List(); + public List<(BindingValueType type, object value)> Notifications { get; } = new(); - protected override void UpdateDataValidation( - AvaloniaProperty property, - BindingValue value) + protected override void UpdateDataValidation( + AvaloniaProperty property, + BindingValueType state, + Exception error) { - Notifications.Add(value); + Notifications.Add((state, GetValue(property))); } } From 7f469752d55097d4dcf014e23fd2f0798f199e68 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 20 Apr 2022 16:43:20 +0200 Subject: [PATCH 2/5] Remove generic methods from IInteractive. --- .../Interactivity/IInteractive.cs | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/Avalonia.Base/Interactivity/IInteractive.cs b/src/Avalonia.Base/Interactivity/IInteractive.cs index afda29e329a..6d7dcd64f49 100644 --- a/src/Avalonia.Base/Interactivity/IInteractive.cs +++ b/src/Avalonia.Base/Interactivity/IInteractive.cs @@ -28,21 +28,6 @@ void AddHandler( RoutingStrategies routes = RoutingStrategies.Direct | RoutingStrategies.Bubble, bool handledEventsToo = false); - /// - /// Adds a handler for the specified routed event. - /// - /// The type of the event's args. - /// The routed event. - /// The handler. - /// The routing strategies to listen to. - /// Whether handled events should also be listened for. - /// A disposable that terminates the event subscription. - void AddHandler( - RoutedEvent routedEvent, - EventHandler handler, - RoutingStrategies routes = RoutingStrategies.Direct | RoutingStrategies.Bubble, - bool handledEventsToo = false) where TEventArgs : RoutedEventArgs; - /// /// Removes a handler for the specified routed event. /// @@ -50,15 +35,6 @@ void AddHandler( /// The handler. void RemoveHandler(RoutedEvent routedEvent, Delegate handler); - /// - /// Removes a handler for the specified routed event. - /// - /// The type of the event's args. - /// The routed event. - /// The handler. - void RemoveHandler(RoutedEvent routedEvent, EventHandler handler) - where TEventArgs : RoutedEventArgs; - /// /// Adds the object's handlers for a routed event to an event route. /// From 4ec36c97e2810c8e1bb48f85339d76e96e502b78 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 20 Apr 2022 16:47:54 +0200 Subject: [PATCH 3/5] Remove generic methods from IDispatcher. --- src/Avalonia.Base/Threading/IDispatcher.cs | 26 ---------------------- 1 file changed, 26 deletions(-) diff --git a/src/Avalonia.Base/Threading/IDispatcher.cs b/src/Avalonia.Base/Threading/IDispatcher.cs index eccd42bd4e2..713a7ac4d70 100644 --- a/src/Avalonia.Base/Threading/IDispatcher.cs +++ b/src/Avalonia.Base/Threading/IDispatcher.cs @@ -26,15 +26,6 @@ public interface IDispatcher /// The priority with which to invoke the method. void Post(Action action, DispatcherPriority priority = default); - /// - /// Posts an action that will be invoked on the dispatcher thread. - /// - /// type of argument - /// The method to call. - /// The argument of method to call. - /// The priority with which to invoke the method. - void Post(Action action, T arg, DispatcherPriority priority = default); - /// /// Invokes a action on the dispatcher thread. /// @@ -43,14 +34,6 @@ public interface IDispatcher /// A task that can be used to track the method's execution. Task InvokeAsync(Action action, DispatcherPriority priority = default); - /// - /// Invokes a method on the dispatcher thread. - /// - /// The method. - /// The priority with which to invoke the method. - /// A task that can be used to track the method's execution. - Task InvokeAsync(Func function, DispatcherPriority priority = default); - /// /// Queues the specified work to run on the dispatcher thread and returns a proxy for the /// task returned by . @@ -59,14 +42,5 @@ public interface IDispatcher /// The priority with which to invoke the method. /// A task that represents a proxy for the task returned by . Task InvokeAsync(Func function, DispatcherPriority priority = default); - - /// - /// Queues the specified work to run on the dispatcher thread and returns a proxy for the - /// task returned by . - /// - /// The work to execute asynchronously. - /// The priority with which to invoke the method. - /// A task that represents a proxy for the task returned by . - Task InvokeAsync(Func> function, DispatcherPriority priority = default); } } From fa44075d26873d80b6fba5df8492d774fadec589 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 20 Apr 2022 17:19:02 +0200 Subject: [PATCH 4/5] Make utility methods non-virtual. Not sure why these method were virtual anyway: any customization should be done by overriding the non-generic `CreateItemContainerGenerator` method. --- src/Avalonia.Controls/TreeView.cs | 2 +- src/Avalonia.Controls/TreeViewItem.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index 1d806913dd2..b2a188a2ea1 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -401,7 +401,7 @@ protected override IItemContainerGenerator CreateItemContainerGenerator() protected virtual ITreeItemContainerGenerator CreateTreeItemContainerGenerator() => CreateTreeItemContainerGenerator(); - protected virtual ITreeItemContainerGenerator CreateTreeItemContainerGenerator() where TVItem: TreeViewItem, new() + protected ITreeItemContainerGenerator CreateTreeItemContainerGenerator() where TVItem: TreeViewItem, new() { return new TreeItemContainerGenerator( this, diff --git a/src/Avalonia.Controls/TreeViewItem.cs b/src/Avalonia.Controls/TreeViewItem.cs index a0a3c09942c..490b0b3ce36 100644 --- a/src/Avalonia.Controls/TreeViewItem.cs +++ b/src/Avalonia.Controls/TreeViewItem.cs @@ -96,7 +96,7 @@ public int Level protected override IItemContainerGenerator CreateItemContainerGenerator() => CreateTreeItemContainerGenerator(); /// - protected virtual ITreeItemContainerGenerator CreateTreeItemContainerGenerator() + protected ITreeItemContainerGenerator CreateTreeItemContainerGenerator() where TVItem: TreeViewItem, new() { return new TreeItemContainerGenerator( From 6df672e4c078bae8dd0259825032af68824f3f08 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 20 Apr 2022 22:30:45 +0200 Subject: [PATCH 5/5] Remove IAvaloniaPropertyVisitor. It was only used internally in creating `ISetterInstance`s so add a virtual method to `AvaloniaProperty` to do this explicitly without generic virtual methods. --- src/Avalonia.Base/AvaloniaProperty.cs | 11 +--- src/Avalonia.Base/DirectPropertyBase.cs | 32 +++++++-- src/Avalonia.Base/StyledPropertyBase.cs | 32 +++++++-- src/Avalonia.Base/Styling/Setter.cs | 65 +------------------ .../Utilities/IAvaloniaPropertyVisitor.cs | 32 --------- .../AvaloniaPropertyTests.cs | 11 ++-- 6 files changed, 62 insertions(+), 121 deletions(-) delete mode 100644 src/Avalonia.Base/Utilities/IAvaloniaPropertyVisitor.cs diff --git a/src/Avalonia.Base/AvaloniaProperty.cs b/src/Avalonia.Base/AvaloniaProperty.cs index 62ca971412e..fd43ced1965 100644 --- a/src/Avalonia.Base/AvaloniaProperty.cs +++ b/src/Avalonia.Base/AvaloniaProperty.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Avalonia.Data; using Avalonia.Data.Core; +using Avalonia.Styling; using Avalonia.Utilities; namespace Avalonia @@ -454,15 +455,6 @@ public override string ToString() return Name; } - /// - /// Uses the visitor pattern to resolve an untyped property to a typed property. - /// - /// The type of user data passed. - /// The visitor which will accept the typed property. - /// The user data to pass. - public abstract void Accept(IAvaloniaPropertyVisitor visitor, ref TData data) - where TData : struct; - /// /// Routes an untyped ClearValue call to a typed call. /// @@ -508,6 +500,7 @@ internal abstract IDisposable RouteBind( BindingPriority priority); internal abstract void RouteInheritanceParentChanged(AvaloniaObject o, AvaloniaObject? oldParent); + internal abstract ISetterInstance CreateSetterInstance(IStyleable target, object? value); /// /// Overrides the metadata for the property on the specified type. diff --git a/src/Avalonia.Base/DirectPropertyBase.cs b/src/Avalonia.Base/DirectPropertyBase.cs index 6e3baea99b7..9c1ffce24cc 100644 --- a/src/Avalonia.Base/DirectPropertyBase.cs +++ b/src/Avalonia.Base/DirectPropertyBase.cs @@ -1,6 +1,7 @@ using System; using Avalonia.Data; using Avalonia.Reactive; +using Avalonia.Styling; using Avalonia.Utilities; namespace Avalonia @@ -120,12 +121,6 @@ public void OverrideMetadata(Type type, DirectPropertyMetadata metadata) base.OverrideMetadata(type, metadata); } - /// - public override void Accept(IAvaloniaPropertyVisitor visitor, ref TData data) - { - visitor.Visit(this, ref data); - } - /// internal override void RouteClearValue(AvaloniaObject o) { @@ -181,5 +176,30 @@ internal override void RouteInheritanceParentChanged(AvaloniaObject o, AvaloniaO { throw new NotSupportedException("Direct properties do not support inheritance."); } + + internal override ISetterInstance CreateSetterInstance(IStyleable target, object? value) + { + if (value is IBinding binding) + { + return new PropertySetterBindingInstance( + target, + this, + binding); + } + else if (value is ITemplate template && !typeof(ITemplate).IsAssignableFrom(PropertyType)) + { + return new PropertySetterLazyInstance( + target, + this, + () => (TValue)template.Build()); + } + else + { + return new PropertySetterInstance( + target, + this, + (TValue)value!); + } + } } } diff --git a/src/Avalonia.Base/StyledPropertyBase.cs b/src/Avalonia.Base/StyledPropertyBase.cs index f94723866a7..dd5eb703ea9 100644 --- a/src/Avalonia.Base/StyledPropertyBase.cs +++ b/src/Avalonia.Base/StyledPropertyBase.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using Avalonia.Data; using Avalonia.Reactive; +using Avalonia.Styling; using Avalonia.Utilities; namespace Avalonia @@ -158,12 +159,6 @@ public void OverrideMetadata(Type type, StyledPropertyMetadata metadata) base.OverrideMetadata(type, metadata); } - /// - public override void Accept(IAvaloniaPropertyVisitor visitor, ref TData data) - { - visitor.Visit(this, ref data); - } - /// /// Gets the string representation of the property. /// @@ -237,6 +232,31 @@ internal override void RouteInheritanceParentChanged( o.InheritanceParentChanged(this, oldParent); } + internal override ISetterInstance CreateSetterInstance(IStyleable target, object? value) + { + if (value is IBinding binding) + { + return new PropertySetterBindingInstance( + target, + this, + binding); + } + else if (value is ITemplate template && !typeof(ITemplate).IsAssignableFrom(PropertyType)) + { + return new PropertySetterLazyInstance( + target, + this, + () => (TValue)template.Build()); + } + else + { + return new PropertySetterInstance( + target, + this, + (TValue)value!); + } + } + private object? GetDefaultBoxedValue(Type type) { _ = type ?? throw new ArgumentNullException(nameof(type)); diff --git a/src/Avalonia.Base/Styling/Setter.cs b/src/Avalonia.Base/Styling/Setter.cs index 168a8824994..b4b3399022e 100644 --- a/src/Avalonia.Base/Styling/Setter.cs +++ b/src/Avalonia.Base/Styling/Setter.cs @@ -16,7 +16,7 @@ namespace Avalonia.Styling /// A is used to set a value on a /// depending on a condition. /// - public class Setter : ISetter, IAnimationSetter, IAvaloniaPropertyVisitor + public class Setter : ISetter, IAnimationSetter { private object? _value; @@ -68,68 +68,7 @@ public ISetterInstance Instance(IStyleable target) throw new InvalidOperationException("Setter.Property must be set."); } - var data = new SetterVisitorData - { - target = target, - value = Value, - }; - - Property.Accept(this, ref data); - return data.result!; - } - - void IAvaloniaPropertyVisitor.Visit( - StyledPropertyBase property, - ref SetterVisitorData data) - { - if (data.value is IBinding binding) - { - data.result = new PropertySetterBindingInstance( - data.target, - property, - binding); - } - else if (data.value is ITemplate template && !typeof(ITemplate).IsAssignableFrom(property.PropertyType)) - { - data.result = new PropertySetterLazyInstance( - data.target, - property, - () => (T)template.Build()); - } - else - { - data.result = new PropertySetterInstance( - data.target, - property, - (T)data.value!); - } - } - - void IAvaloniaPropertyVisitor.Visit( - DirectPropertyBase property, - ref SetterVisitorData data) - { - if (data.value is IBinding binding) - { - data.result = new PropertySetterBindingInstance( - data.target, - property, - binding); - } - else if (data.value is ITemplate template && !typeof(ITemplate).IsAssignableFrom(property.PropertyType)) - { - data.result = new PropertySetterLazyInstance( - data.target, - property, - () => (T)template.Build()); - } - else - { - data.result = new PropertySetterInstance( - data.target, - property, - (T)data.value!); - } + return Property.CreateSetterInstance(target, Value); } private struct SetterVisitorData diff --git a/src/Avalonia.Base/Utilities/IAvaloniaPropertyVisitor.cs b/src/Avalonia.Base/Utilities/IAvaloniaPropertyVisitor.cs deleted file mode 100644 index 6a8df91b817..00000000000 --- a/src/Avalonia.Base/Utilities/IAvaloniaPropertyVisitor.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace Avalonia.Utilities -{ - /// - /// A visitor to resolve an untyped to a typed property. - /// - /// The type of user data passed. - /// - /// Pass an instance that implements this interface to - /// - /// in order to resolve un untyped to a typed - /// or . - /// - public interface IAvaloniaPropertyVisitor - where TData : struct - { - /// - /// Called when the property is a styled property. - /// - /// The property value type. - /// The property. - /// The user data. - void Visit(StyledPropertyBase property, ref TData data); - - /// - /// Called when the property is a direct property. - /// - /// The property value type. - /// The property. - /// The user data. - void Visit(DirectPropertyBase property, ref TData data); - } -} diff --git a/tests/Avalonia.Base.UnitTests/AvaloniaPropertyTests.cs b/tests/Avalonia.Base.UnitTests/AvaloniaPropertyTests.cs index ee29c823458..f3f39b465b9 100644 --- a/tests/Avalonia.Base.UnitTests/AvaloniaPropertyTests.cs +++ b/tests/Avalonia.Base.UnitTests/AvaloniaPropertyTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Avalonia.Data; +using Avalonia.Styling; using Avalonia.Utilities; using Xunit; @@ -146,11 +147,6 @@ public void OverrideMetadata(AvaloniaPropertyMetadata metadata) OverrideMetadata(typeof(T), metadata); } - public override void Accept(IAvaloniaPropertyVisitor vistor, ref TData data) - { - throw new NotImplementedException(); - } - internal override IDisposable RouteBind( AvaloniaObject o, IObservable> source, @@ -186,6 +182,11 @@ internal override IDisposable RouteSetValue( { throw new NotImplementedException(); } + + internal override ISetterInstance CreateSetterInstance(IStyleable target, object value) + { + throw new NotImplementedException(); + } } private class Class1 : AvaloniaObject