Skip to content

Commit ea5faf3

Browse files
committed
update CollectionView to use nullable object types
1 parent 92b8930 commit ea5faf3

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/ItemsSource/CollectionView.Properties.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public IList Source
5555
/// </summary>
5656
/// <param name="index">The zero-based index of the item to get or set.</param>
5757
/// <returns>The item at the specified index.</returns>
58-
public object this[int index]
58+
public object? this[int index]
5959
{
6060
get => _view[index];
6161
set => _view[index] = value;
@@ -69,7 +69,7 @@ public object this[int index]
6969
/// <summary>
7070
/// Gets or sets the current item in the view.
7171
/// </summary>
72-
public object CurrentItem
72+
public object? CurrentItem
7373
{
7474
get => CurrentPosition > -1 && CurrentPosition < _view.Count ? _view[CurrentPosition] : null!;
7575
set => MoveCurrentTo(value);

src/ItemsSource/CollectionView.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ namespace WinUI.TableView;
1515
/// <summary>
1616
/// A collection view implementation that supports filtering, sorting, and incremental loading.
1717
/// </summary>
18-
internal partial class CollectionView : ICollectionView, ISupportIncrementalLoading, INotifyPropertyChanged, IComparer<object>
18+
internal partial class CollectionView : ICollectionView, ISupportIncrementalLoading, INotifyPropertyChanged, IComparer<object?>
1919
{
2020
private IList _source = default!;
2121
private bool _allowLiveShaping;
22-
private readonly List<object> _view = [];
22+
private readonly List<object?> _view = [];
2323
private readonly ObservableCollection<FilterDescription> _filterDescriptions = [];
2424
private readonly ObservableCollection<SortDescription> _sortDescriptions = [];
2525
private CollectionChangedListener<CollectionView>? _collectionChangedListener;
@@ -259,7 +259,7 @@ private void HandleFilterChanged()
259259
}
260260
}
261261

262-
var viewHash = new HashSet<object>(_view);
262+
var viewHash = new HashSet<object?>(_view);
263263
var viewIndex = 0;
264264
for (var index = 0; index < _source.Count; index++)
265265
{
@@ -442,7 +442,7 @@ public void CopyTo(object[] array, int arrayIndex)
442442
/// </summary>
443443
/// <param name="item">The item to locate in the collection.</param>
444444
/// <returns>The index of the item if found in the collection; otherwise, -1.</returns>
445-
public int IndexOf(object item)
445+
public int IndexOf(object? item)
446446
{
447447
return _view.IndexOf(item);
448448
}
@@ -464,7 +464,7 @@ public void Insert(int index, object item)
464464
/// </summary>
465465
/// <param name="item">The item to move to.</param>
466466
/// <returns>true if the operation is successful; otherwise, false.</returns>
467-
public bool MoveCurrentTo(object item)
467+
public bool MoveCurrentTo(object? item)
468468
{
469469
return item == CurrentItem || MoveCurrentToIndex(IndexOf(item));
470470
}
@@ -520,7 +520,7 @@ public bool MoveCurrentToPrevious()
520520
/// </summary>
521521
/// <param name="item">The item to remove.</param>
522522
/// <returns>true if the item was successfully removed; otherwise, false.</returns>
523-
public bool Remove(object item)
523+
public bool Remove(object? item)
524524
{
525525
if (IsReadOnly) throw new NotSupportedException("Collection is read-only.");
526526

0 commit comments

Comments
 (0)