Skip to content
Closed
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
56 changes: 55 additions & 1 deletion src/Avalonia.Base/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@
Compat issues with assembly Avalonia.Base:
MembersMustExist : Member 'public void Avalonia.AvaloniaObject.CoerceValue<T>(Avalonia.StyledPropertyBase<T>)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'protected Avalonia.IAvaloniaObject Avalonia.AvaloniaObject.InheritanceParent.get()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'protected void Avalonia.AvaloniaObject.InheritanceParent.set(Avalonia.IAvaloniaObject)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'public void Avalonia.AvaloniaObject.SetValue(Avalonia.AvaloniaProperty, System.Object, Avalonia.Data.BindingPriority)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'public System.IDisposable Avalonia.AvaloniaObjectExtensions.Bind(Avalonia.IAvaloniaObject, Avalonia.AvaloniaProperty, System.IObservable<Avalonia.Data.BindingValue<System.Object>>, Avalonia.Data.BindingPriority)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'public System.IDisposable Avalonia.AvaloniaObjectExtensions.Bind(Avalonia.IAvaloniaObject, Avalonia.AvaloniaProperty, System.IObservable<System.Object>, Avalonia.Data.BindingPriority)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'public void Avalonia.AvaloniaObjectExtensions.ClearValue(Avalonia.IAvaloniaObject, Avalonia.AvaloniaProperty)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'public void Avalonia.AvaloniaObjectExtensions.ClearValue<T>(Avalonia.IAvaloniaObject, Avalonia.AvaloniaProperty<T>)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'public System.Object Avalonia.AvaloniaObjectExtensions.GetValue(Avalonia.IAvaloniaObject, Avalonia.AvaloniaProperty)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'public System.IDisposable Avalonia.AvaloniaObjectExtensions.SetValue(Avalonia.IAvaloniaObject, Avalonia.AvaloniaProperty, System.Object, Avalonia.Data.BindingPriority)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'public System.IDisposable Avalonia.AvaloniaObjectExtensions.SetValue<T>(Avalonia.IAvaloniaObject, Avalonia.AvaloniaProperty<T>, T, Avalonia.Data.BindingPriority)' does not exist in the implementation but it does exist in the contract.
CannotAddAbstractMembers : Member 'internal System.IDisposable Avalonia.AvaloniaProperty.RouteBind(Avalonia.AvaloniaObject, System.IObservable<Avalonia.Data.BindingValue<System.Object>>, Avalonia.Data.BindingPriority)' is abstract in the implementation but is missing in the contract.
MembersMustExist : Member 'internal System.IDisposable Avalonia.AvaloniaProperty.RouteBind(Avalonia.IAvaloniaObject, System.IObservable<Avalonia.Data.BindingValue<System.Object>>, Avalonia.Data.BindingPriority)' does not exist in the implementation but it does exist in the contract.
CannotAddAbstractMembers : Member 'internal void Avalonia.AvaloniaProperty.RouteClearValue(Avalonia.AvaloniaObject)' is abstract in the implementation but is missing in the contract.
MembersMustExist : Member 'internal void Avalonia.AvaloniaProperty.RouteClearValue(Avalonia.IAvaloniaObject)' does not exist in the implementation but it does exist in the contract.
CannotAddAbstractMembers : Member 'internal System.Object Avalonia.AvaloniaProperty.RouteGetBaseValue(Avalonia.AvaloniaObject, Avalonia.Data.BindingPriority)' is abstract in the implementation but is missing in the contract.
MembersMustExist : Member 'internal System.Object Avalonia.AvaloniaProperty.RouteGetBaseValue(Avalonia.IAvaloniaObject, Avalonia.Data.BindingPriority)' does not exist in the implementation but it does exist in the contract.
CannotAddAbstractMembers : Member 'internal System.Object Avalonia.AvaloniaProperty.RouteGetValue(Avalonia.AvaloniaObject)' is abstract in the implementation but is missing in the contract.
MembersMustExist : Member 'internal System.Object Avalonia.AvaloniaProperty.RouteGetValue(Avalonia.IAvaloniaObject)' does not exist in the implementation but it does exist in the contract.
CannotAddAbstractMembers : Member 'internal void Avalonia.AvaloniaProperty.RouteInheritanceParentChanged(Avalonia.AvaloniaObject, Avalonia.AvaloniaObject)' is abstract in the implementation but is missing in the contract.
MembersMustExist : Member 'internal void Avalonia.AvaloniaProperty.RouteInheritanceParentChanged(Avalonia.AvaloniaObject, Avalonia.IAvaloniaObject)' does not exist in the implementation but it does exist in the contract.
CannotAddAbstractMembers : Member 'internal System.IDisposable Avalonia.AvaloniaProperty.RouteSetValue(Avalonia.AvaloniaObject, System.Object, Avalonia.Data.BindingPriority)' is abstract in the implementation but is missing in the contract.
MembersMustExist : Member 'internal System.IDisposable Avalonia.AvaloniaProperty.RouteSetValue(Avalonia.IAvaloniaObject, System.Object, Avalonia.Data.BindingPriority)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.IAvaloniaObject.AddInheritanceChild(Avalonia.IAvaloniaObject)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public void Avalonia.IAvaloniaObject.AddInheritanceChild(Avalonia.IAvaloniaObject)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public System.IDisposable Avalonia.IAvaloniaObject.Bind(Avalonia.AvaloniaProperty, System.IObservable<System.Object>, Avalonia.Data.BindingPriority)' is present in the implementation but not in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public System.IDisposable Avalonia.IAvaloniaObject.Bind<T>(Avalonia.DirectPropertyBase<T>, System.IObservable<Avalonia.Data.BindingValue<T>>)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public System.IDisposable Avalonia.IAvaloniaObject.Bind<T>(Avalonia.DirectPropertyBase<T>, System.IObservable<Avalonia.Data.BindingValue<T>>)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public System.IDisposable Avalonia.IAvaloniaObject.Bind<T>(Avalonia.StyledPropertyBase<T>, System.IObservable<Avalonia.Data.BindingValue<T>>, Avalonia.Data.BindingPriority)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public System.IDisposable Avalonia.IAvaloniaObject.Bind<T>(Avalonia.StyledPropertyBase<T>, System.IObservable<Avalonia.Data.BindingValue<T>>, Avalonia.Data.BindingPriority)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.IAvaloniaObject.ClearValue(Avalonia.AvaloniaProperty)' is present in the implementation but not in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.IAvaloniaObject.ClearValue<T>(Avalonia.DirectPropertyBase<T>)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public void Avalonia.IAvaloniaObject.ClearValue<T>(Avalonia.DirectPropertyBase<T>)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.IAvaloniaObject.ClearValue<T>(Avalonia.StyledPropertyBase<T>)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public void Avalonia.IAvaloniaObject.ClearValue<T>(Avalonia.StyledPropertyBase<T>)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.IAvaloniaObject.CoerceValue(Avalonia.AvaloniaProperty)' is present in the implementation but not in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.IAvaloniaObject.CoerceValue<T>(Avalonia.StyledPropertyBase<T>)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public void Avalonia.IAvaloniaObject.CoerceValue<T>(Avalonia.StyledPropertyBase<T>)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public Avalonia.Data.Optional<T> Avalonia.IAvaloniaObject.GetBaseValue<T>(Avalonia.StyledPropertyBase<T>, Avalonia.Data.BindingPriority)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public Avalonia.Data.Optional<T> Avalonia.IAvaloniaObject.GetBaseValue<T>(Avalonia.StyledPropertyBase<T>, Avalonia.Data.BindingPriority)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public System.Object Avalonia.IAvaloniaObject.GetValue(Avalonia.AvaloniaProperty)' is present in the implementation but not in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public T Avalonia.IAvaloniaObject.GetValue<T>(Avalonia.DirectPropertyBase<T>)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public T Avalonia.IAvaloniaObject.GetValue<T>(Avalonia.DirectPropertyBase<T>)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public T Avalonia.IAvaloniaObject.GetValue<T>(Avalonia.StyledPropertyBase<T>)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public T Avalonia.IAvaloniaObject.GetValue<T>(Avalonia.StyledPropertyBase<T>)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.IAvaloniaObject.InheritedPropertyChanged<T>(Avalonia.AvaloniaProperty<T>, Avalonia.Data.Optional<T>, Avalonia.Data.Optional<T>)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public void Avalonia.IAvaloniaObject.InheritedPropertyChanged<T>(Avalonia.AvaloniaProperty<T>, Avalonia.Data.Optional<T>, Avalonia.Data.Optional<T>)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.IAvaloniaObject.RemoveInheritanceChild(Avalonia.IAvaloniaObject)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public void Avalonia.IAvaloniaObject.RemoveInheritanceChild(Avalonia.IAvaloniaObject)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public System.IDisposable Avalonia.IAvaloniaObject.SetValue(Avalonia.AvaloniaProperty, System.Object, Avalonia.Data.BindingPriority)' is present in the implementation but not in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.IAvaloniaObject.SetValue<T>(Avalonia.DirectPropertyBase<T>, T)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public void Avalonia.IAvaloniaObject.SetValue<T>(Avalonia.DirectPropertyBase<T>, T)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public System.IDisposable Avalonia.IAvaloniaObject.SetValue<T>(Avalonia.StyledPropertyBase<T>, T, Avalonia.Data.BindingPriority)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public System.IDisposable Avalonia.IAvaloniaObject.SetValue<T>(Avalonia.StyledPropertyBase<T>, T, Avalonia.Data.BindingPriority)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.Threading.IDispatcher.Post<T>(System.Action<T>, T, Avalonia.Threading.DispatcherPriority)' is present in the implementation but not in the contract.
Total Issues: 1
Total Issues: 55
53 changes: 35 additions & 18 deletions src/Avalonia.Base/AvaloniaObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Avalonia.Diagnostics;
using Avalonia.Logging;
using Avalonia.PropertyStore;
using Avalonia.Reactive;
using Avalonia.Threading;

namespace Avalonia
Expand All @@ -17,11 +18,11 @@ namespace Avalonia
/// </remarks>
public class AvaloniaObject : IAvaloniaObject, IAvaloniaObjectDebug, INotifyPropertyChanged, IValueSink
{
private IAvaloniaObject? _inheritanceParent;
private AvaloniaObject? _inheritanceParent;
private List<IDisposable>? _directBindings;
private PropertyChangedEventHandler? _inpcChanged;
private EventHandler<AvaloniaPropertyChangedEventArgs>? _propertyChanged;
private List<IAvaloniaObject>? _inheritanceChildren;
private List<AvaloniaObject>? _inheritanceChildren;
private ValueStore? _values;
private bool _batchUpdate;

Expand Down Expand Up @@ -58,7 +59,7 @@ event PropertyChangedEventHandler? INotifyPropertyChanged.PropertyChanged
/// <value>
/// The inheritance parent.
/// </value>
protected IAvaloniaObject? InheritanceParent
protected AvaloniaObject? InheritanceParent
{
get
{
Expand Down Expand Up @@ -320,14 +321,14 @@ public bool IsSet(AvaloniaProperty property)
/// <param name="property">The property.</param>
/// <param name="value">The value.</param>
/// <param name="priority">The priority of the value.</param>
public void SetValue(
public IDisposable? SetValue(
AvaloniaProperty property,
object? value,
BindingPriority priority = BindingPriority.LocalValue)
{
property = property ?? throw new ArgumentNullException(nameof(property));

property.RouteSetValue(this, value, priority);
return property.RouteSetValue(this, value, priority);
}

/// <summary>
Expand Down Expand Up @@ -385,6 +386,26 @@ public void SetValue<T>(DirectPropertyBase<T> property, T value)
SetDirectValueUnchecked(property, value);
}

/// <summary>
/// Binds a <see cref="AvaloniaProperty"/> to an observable.
/// </summary>
/// <param name="property">The property.</param>
/// <param name="source">The observable.</param>
/// <param name="priority">The priority of the binding.</param>
/// <returns>
/// A disposable which can be used to terminate the binding.
/// </returns>
public IDisposable Bind(
AvaloniaProperty property,
IObservable<object?> source,
BindingPriority priority = BindingPriority.LocalValue)
{
property = property ?? throw new ArgumentNullException(nameof(property));
source = source ?? throw new ArgumentNullException(nameof(source));

return property.RouteBind(this, source.ToBindingValue(), priority);
}

/// <summary>
/// Binds a <see cref="AvaloniaProperty"/> to an observable.
/// </summary>
Expand Down Expand Up @@ -445,9 +466,8 @@ public IDisposable Bind<T>(
/// <summary>
/// Coerces the specified <see cref="AvaloniaProperty"/>.
/// </summary>
/// <typeparam name="T">The type of the property.</typeparam>
/// <param name="property">The property.</param>
public void CoerceValue<T>(StyledPropertyBase<T> property)
public void CoerceValue(AvaloniaProperty property)
{
_values?.CoerceValue(property);
}
Expand Down Expand Up @@ -475,19 +495,19 @@ public void EndBatchUpdate()
}

/// <inheritdoc/>
void IAvaloniaObject.AddInheritanceChild(IAvaloniaObject child)
internal void AddInheritanceChild(AvaloniaObject child)
{
_inheritanceChildren ??= new List<IAvaloniaObject>();
_inheritanceChildren ??= new List<AvaloniaObject>();
_inheritanceChildren.Add(child);
}

/// <inheritdoc/>
void IAvaloniaObject.RemoveInheritanceChild(IAvaloniaObject child)
internal void RemoveInheritanceChild(AvaloniaObject child)
{
_inheritanceChildren?.Remove(child);
}

void IAvaloniaObject.InheritedPropertyChanged<T>(
internal void InheritedPropertyChanged<T>(
AvaloniaProperty<T> property,
Optional<T> oldValue,
Optional<T> newValue)
Expand Down Expand Up @@ -565,14 +585,11 @@ void IValueSink.Completed<T>(
/// <param name="oldParent">The old inheritance parent.</param>
internal void InheritanceParentChanged<T>(
StyledPropertyBase<T> property,
IAvaloniaObject? oldParent)
AvaloniaObject? oldParent)
{
var oldValue = oldParent switch
{
AvaloniaObject o => o.GetValueOrInheritedOrDefault(property),
null => property.GetDefaultValue(GetType()),
_ => oldParent.GetValue(property)
};
var oldValue = oldParent is not null ?
oldParent.GetValueOrInheritedOrDefault(property) :
property.GetDefaultValue(GetType());

var newValue = GetInheritedOrDefault(property);

Expand Down
Loading