diff --git a/src/Avalonia.Base/Utilities/SafeEnumerableList.cs b/src/Avalonia.Base/Utilities/SafeEnumerableList.cs index 2c87194c8e..4e0e7ddf9a 100644 --- a/src/Avalonia.Base/Utilities/SafeEnumerableList.cs +++ b/src/Avalonia.Base/Utilities/SafeEnumerableList.cs @@ -11,7 +11,7 @@ using Avalonia.Collections; namespace Avalonia.Utilities { - internal class SafeEnumerableList : IAvaloniaList, INotifyCollectionChanged + internal class SafeEnumerableList : IAvaloniaList, IList, INotifyCollectionChanged { private AvaloniaList _list = new(); private int _generation; @@ -137,6 +137,36 @@ namespace Avalonia.Utilities GetList().RemoveRange(index, count); } + public int Add(object? value) + { + return ((IList)GetList()).Add(value); + } + + public bool Contains(object? value) + { + return ((IList)_list).Contains(value); + } + + public int IndexOf(object? value) + { + return ((IList)_list).IndexOf(value); + } + + public void Insert(int index, object? value) + { + ((IList)GetList()).Insert(index, value); + } + + public void Remove(object? value) + { + ((IList)GetList()).Remove(value); + } + + public void CopyTo(Array array, int index) + { + ((ICollection)_list).CopyTo(array, index); + } + public int Count => _list.Count; public bool IsReadOnly => ((ICollection)_list).IsReadOnly; @@ -144,6 +174,13 @@ namespace Avalonia.Utilities public ResetBehavior ResetBehavior { get => _list.ResetBehavior; set => _list.ResetBehavior = value; } public IAvaloniaListItemValidator? Validator { get => _list.Validator; set => _list.Validator = value; } + public bool IsFixedSize => ((IList)_list).IsFixedSize; + + public bool IsSynchronized => ((ICollection)_list).IsSynchronized; + + public object SyncRoot => ((ICollection)_list).SyncRoot; + + object? IList.this[int index] { get => ((IList)_list)[index]; set => ((IList)GetList())[index] = value; } public T this[int index] { get => _list[index]; set => GetList()[index] = value; } public struct SafeListEnumerator : IEnumerator