Browse Source
Merge pull request #8115 from Kaktusbot/fix-missing-avalonialist-notifycountchanged
Fix missing NotifyCountChanged in AvaloniaList.AddRange
pull/8117/head
Max Katz
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
23 additions and
0 deletions
-
src/Avalonia.Base/Collections/AvaloniaList.cs
-
tests/Avalonia.Base.UnitTests/Collections/AvaloniaListTests.cs
|
|
|
@ -394,7 +394,13 @@ namespace Avalonia.Collections |
|
|
|
} while (en.MoveNext()); |
|
|
|
|
|
|
|
if (notificationItems is not null) |
|
|
|
{ |
|
|
|
NotifyAdd(notificationItems, index); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
NotifyCountChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -146,6 +146,23 @@ namespace Avalonia.Base.UnitTests.Collections |
|
|
|
Assert.True(raised); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void AddRange_IEnumerable_Should_Raise_Count_PropertyChanged() |
|
|
|
{ |
|
|
|
var target = new AvaloniaList<int>(new[] { 1, 2, 3, 4, 5 }); |
|
|
|
var raised = false; |
|
|
|
|
|
|
|
target.PropertyChanged += (s, e) => { |
|
|
|
Assert.Equal(e.PropertyName, nameof(target.Count)); |
|
|
|
Assert.Equal(target.Count, 7); |
|
|
|
raised = true; |
|
|
|
}; |
|
|
|
|
|
|
|
target.AddRange(Enumerable.Range(6, 2)); |
|
|
|
|
|
|
|
Assert.True(raised); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void AddRange_Items_Should_Raise_Correct_CollectionChanged() |
|
|
|
{ |
|
|
|
|