diff --git a/src/Avalonia.Base/Reactive/SerialDisposableValue.cs b/src/Avalonia.Base/Reactive/SerialDisposableValue.cs
deleted file mode 100644
index 9eaf6343bf..0000000000
--- a/src/Avalonia.Base/Reactive/SerialDisposableValue.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-using System.Threading;
-
-namespace Avalonia.Reactive;
-
-///
-/// Represents a disposable resource whose underlying disposable resource can be replaced by another disposable resource, causing automatic disposal of the previous underlying disposable resource.
-///
-internal sealed class SerialDisposableValue : IDisposable
-{
- private IDisposable? _current;
- private bool _disposed;
-
- public IDisposable? Disposable
- {
- get => _current;
- set
- {
- _current?.Dispose();
- _current = value;
-
- if (_disposed)
- {
- _current?.Dispose();
- _current = null;
- }
- }
- }
-
- public void Dispose()
- {
- _disposed = true;
- _current?.Dispose();
- }
-}
diff --git a/src/Avalonia.Base/Utilities/SingleOrDictionary.cs b/src/Avalonia.Base/Utilities/SingleOrDictionary.cs
deleted file mode 100644
index 068c73ba33..0000000000
--- a/src/Avalonia.Base/Utilities/SingleOrDictionary.cs
+++ /dev/null
@@ -1,144 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-
-namespace Avalonia.Utilities
-{
- ///
- /// Stores either a single key value pair or constructs a dictionary when more than one value is stored.
- ///
- /// The type of the key.
- /// The type of the value.
- internal class SingleOrDictionary : IEnumerable>
- where TKey : notnull
- {
- private KeyValuePair? _singleValue;
- private Dictionary? dictionary;
-
- public void Add(TKey key, TValue value)
- {
- if (_singleValue != null)
- {
- dictionary = new Dictionary();
- ((ICollection>)dictionary).Add(_singleValue.Value);
- _singleValue = null;
- }
-
- if (dictionary != null)
- {
- dictionary.Add(key, value);
- }
- else
- {
- _singleValue = new KeyValuePair(key, value);
- }
- }
-
- public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
- {
- if (dictionary == null)
- {
- if (!_singleValue.HasValue || !EqualityComparer.Default.Equals(_singleValue.Value.Key, key))
- {
- value = default;
- return false;
- }
- else
- {
- value = _singleValue.Value.Value;
- return true;
- }
- }
- else
- {
- return dictionary.TryGetValue(key, out value);
- }
- }
-
- public IEnumerator> GetEnumerator()
- {
- if (dictionary == null)
- {
- if (_singleValue.HasValue)
- {
- return new SingleEnumerator>(_singleValue.Value);
- }
- }
- else
- {
- return dictionary.GetEnumerator();
- }
- return Enumerable.Empty>().GetEnumerator();
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- public IEnumerable Values
- {
- get
- {
- if(dictionary == null)
- {
- if (_singleValue.HasValue)
- {
- return new[] { _singleValue.Value.Value };
- }
- }
- else
- {
- return dictionary.Values;
- }
- return Enumerable.Empty();
- }
- }
-
- private class SingleEnumerator : IEnumerator
- {
- private readonly T value;
- private int index = -1;
-
- public SingleEnumerator(T value)
- {
- this.value = value;
- }
-
- public T Current
- {
- get
- {
- if (index == 0)
- {
- return value;
- }
- else
- {
- throw new InvalidOperationException();
- }
- }
- }
-
- object? IEnumerator.Current => Current;
-
- public void Dispose()
- {
- }
-
- public bool MoveNext()
- {
- index++;
- return index < 1;
- }
-
- public void Reset()
- {
- index = -1;
- }
- }
-
- }
-}
diff --git a/src/Avalonia.Controls/DateTimePickers/DatePicker.cs b/src/Avalonia.Controls/DateTimePickers/DatePicker.cs
index 0704d1325d..2f406252f7 100644
--- a/src/Avalonia.Controls/DateTimePickers/DatePicker.cs
+++ b/src/Avalonia.Controls/DateTimePickers/DatePicker.cs
@@ -103,8 +103,6 @@ namespace Avalonia.Controls
SetCurrentValue(MaxYearProperty, new DateTimeOffset(now.Date.Year + 100, 12, 31, 0, 0, 0, now.Offset));
}
- private static void OnGridVisibilityChanged(DatePicker sender, AvaloniaPropertyChangedEventArgs e) => sender.SetGrid();
-
public string DayFormat
{
get => GetValue(DayFormatProperty);
diff --git a/src/Avalonia.Controls/Grid.cs b/src/Avalonia.Controls/Grid.cs
index d181328134..3eb4eae98d 100644
--- a/src/Avalonia.Controls/Grid.cs
+++ b/src/Avalonia.Controls/Grid.cs
@@ -2278,25 +2278,6 @@ namespace Avalonia.Controls
return null;
}
- ///
- /// Sorts row/column indices by rounding error if layout rounding is applied.
- ///
- /// Index, rounding error pair
- /// Index, rounding error pair
- /// 1 if x.Value > y.Value, 0 if equal, -1 otherwise
- private static int CompareRoundingErrors(KeyValuePair x, KeyValuePair y)
- {
- if (x.Value < y.Value)
- {
- return -1;
- }
- else if (x.Value > y.Value)
- {
- return 1;
- }
- return 0;
- }
-
///
/// Calculates final (aka arrange) size for given range.
///
@@ -2985,88 +2966,6 @@ namespace Avalonia.Controls
}
}
- ///
- /// StarDistributionOrderIndexComparer.
- ///
- private class StarDistributionOrderIndexComparer : IComparer
- {
- private readonly IReadOnlyList definitions;
-
- internal StarDistributionOrderIndexComparer(IReadOnlyList definitions)
- {
- this.definitions = definitions ?? throw new ArgumentNullException(nameof(definitions));
- }
-
- public int Compare(object? x, object? y)
- {
- int? indexX = x as int?;
- int? indexY = y as int?;
-
- DefinitionBase? definitionX = null;
- DefinitionBase? definitionY = null;
-
- if (indexX != null)
- {
- definitionX = definitions[indexX.Value];
- }
- if (indexY != null)
- {
- definitionY = definitions[indexY.Value];
- }
-
- int result;
-
- if (!CompareNullRefs(definitionX, definitionY, out result))
- {
- result = definitionX.SizeCache.CompareTo(definitionY.SizeCache);
- }
-
- return result;
- }
- }
-
- ///
- /// DistributionOrderComparer.
- ///
- private class DistributionOrderIndexComparer : IComparer
- {
- private readonly IReadOnlyList definitions;
-
- internal DistributionOrderIndexComparer(IReadOnlyList definitions)
- {
- this.definitions = definitions ?? throw new ArgumentNullException(nameof(definitions));
- }
-
- public int Compare(object? x, object? y)
- {
- int? indexX = x as int?;
- int? indexY = y as int?;
-
- DefinitionBase? definitionX = null;
- DefinitionBase? definitionY = null;
-
- if (indexX != null)
- {
- definitionX = definitions[indexX.Value];
- }
- if (indexY != null)
- {
- definitionY = definitions[indexY.Value];
- }
-
- int result;
-
- if (!CompareNullRefs(definitionX, definitionY, out result))
- {
- double xprime = definitionX.SizeCache - definitionX.MinSizeForArrange;
- double yprime = definitionY.SizeCache - definitionY.MinSizeForArrange;
- result = xprime.CompareTo(yprime);
- }
-
- return result;
- }
- }
-
///
/// RoundingErrorIndexComparer.
///