diff --git a/src/Avalonia.Base/AvaloniaObject.cs b/src/Avalonia.Base/AvaloniaObject.cs
index 28fa4d5d0c9..37457ad7c34 100644
--- a/src/Avalonia.Base/AvaloniaObject.cs
+++ b/src/Avalonia.Base/AvaloniaObject.cs
@@ -9,8 +9,8 @@
using Avalonia.Diagnostics;
using Avalonia.Logging;
using Avalonia.PropertyStore;
-using Avalonia.Reactive;
using Avalonia.Threading;
+using Avalonia.Utilities;
namespace Avalonia
{
@@ -126,7 +126,7 @@ public IBinding this[IndexerDescriptor binding]
/// The property.
public void ClearValue(AvaloniaProperty property)
{
- _ = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
VerifyAccess();
_values.ClearValue(property);
}
@@ -137,7 +137,7 @@ public void ClearValue(AvaloniaProperty property)
/// The property.
public void ClearValue(AvaloniaProperty property)
{
- property = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
VerifyAccess();
switch (property)
@@ -159,7 +159,7 @@ public void ClearValue(AvaloniaProperty property)
/// The property.
public void ClearValue(StyledProperty property)
{
- property = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
VerifyAccess();
_values.ClearValue(property);
@@ -171,11 +171,11 @@ public void ClearValue(StyledProperty property)
/// The property.
public void ClearValue(DirectPropertyBase property)
{
- property = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
VerifyAccess();
var p = AvaloniaPropertyRegistry.Instance.GetRegisteredDirect(this, property);
- p.InvokeSetter(this, p.GetUnsetValue(GetType()));
+ p.InvokeSetter(this, p.GetUnsetValue(this));
}
///
@@ -216,7 +216,7 @@ public void ClearValue(DirectPropertyBase property)
/// The value.
public object? GetValue(AvaloniaProperty property)
{
- _ = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
if (property.IsDirect)
return property.RouteGetValue(this);
@@ -232,7 +232,7 @@ public void ClearValue(DirectPropertyBase property)
/// The value.
public T GetValue(StyledProperty property)
{
- _ = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
VerifyAccess();
return _values.GetValue(property);
}
@@ -245,7 +245,7 @@ public T GetValue(StyledProperty property)
/// The value.
public T GetValue(DirectPropertyBase property)
{
- property = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
VerifyAccess();
var registered = AvaloniaPropertyRegistry.Instance.GetRegisteredDirect(this, property);
@@ -262,7 +262,7 @@ public T GetValue(DirectPropertyBase property)
///
public Optional GetBaseValue(StyledProperty property)
{
- _ = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
VerifyAccess();
return _values.GetBaseValue(property);
}
@@ -274,7 +274,7 @@ public Optional GetBaseValue(StyledProperty property)
/// True if the property is animating, otherwise false.
public bool IsAnimating(AvaloniaProperty property)
{
- property = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
VerifyAccess();
@@ -292,7 +292,7 @@ public bool IsAnimating(AvaloniaProperty property)
///
public bool IsSet(AvaloniaProperty property)
{
- property = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
VerifyAccess();
@@ -310,7 +310,7 @@ public bool IsSet(AvaloniaProperty property)
object? value,
BindingPriority priority = BindingPriority.LocalValue)
{
- property = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
return property.RouteSetValue(this, value, priority);
}
@@ -330,7 +330,7 @@ public bool IsSet(AvaloniaProperty property)
T value,
BindingPriority priority = BindingPriority.LocalValue)
{
- _ = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
VerifyAccess();
ValidatePriority(priority);
@@ -357,7 +357,7 @@ public bool IsSet(AvaloniaProperty property)
/// The value.
public void SetValue(DirectPropertyBase property, T value)
{
- property = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
VerifyAccess();
property = AvaloniaPropertyRegistry.Instance.GetRegisteredDirect(this, property);
@@ -401,7 +401,7 @@ public void SetCurrentValue(AvaloniaProperty property, object? value) =>
///
public void SetCurrentValue(StyledProperty property, T value)
{
- _ = property ?? throw new ArgumentNullException(nameof(property));
+ ThrowHelper.ThrowIfNull(property, nameof(property));
VerifyAccess();
LogPropertySet(property, value, BindingPriority.LocalValue);
@@ -458,8 +458,8 @@ public IDisposable Bind(
IObservable