-
-
Notifications
You must be signed in to change notification settings - Fork 191
Description
Describe the bug 🐞
Probably easier to understand just by looking at the code below but I'll try explaining in text anyway. When using Filter() on a chain starting with a ToObservableChangeSet() on a ObservableCollection, it seems that it changes the way that changes are being handled down the chain, even when the filter does nothing. If you call Move() on the initial collection it does not move the items on the resulting bound ReadOnlyObservableCollection. Some issue also seems to happen if you simply try to swap the places of the items, the index of the change seems to be lost so nothing happens. It makes sense that those things would do nothing when you set a key, since it would be like a dictionary, but it's a list in this case.
Step to reproduce
Simple repro:
ObservableCollection<string> input = new();
input.ToObservableChangeSet()
.Filter(x => true) // If you remove this line it works as expected
.Bind(out ReadOnlyObservableCollection<string> output)
.Subscribe();
input.Add("c");
input.Add("a");
input.Add("b");
input.Move(0, 2); // Move c to last position
Debug.WriteLine($"input: {String.Join(',', input)}"); // input: a,b,c
Debug.WriteLine($"output: {String.Join(',', output)}"); // output: c,a,bSimilarly with a swap:
ObservableCollection<string> input = new();
input.ToObservableChangeSet()
.Filter(x => true) // If you remove this line it works as expected
.Bind(out ReadOnlyObservableCollection<string> output)
.Subscribe();
input.Add("c");
input.Add("b");
input.Add("a");
// Swap a and c (curiously if you swap the other way around it works fine)
var temp = input[0];
input[0] = input[2];
input[2] = temp;
Debug.WriteLine($"input: {String.Join(',', input)}"); // input: a,b,c
Debug.WriteLine($"output: {String.Join(',', output)}"); // output: c,b,aReproduction repository
N/A
Expected behavior
Filter should pass down moves and swaps properly the same as if it wasn't there
Screenshots 🖼️
No response
IDE
Visual Studio 2022
Operating system
Windows
Version
10
Device
No response
DynamicData Version
9.4.1
Additional information ℹ️
Maybe I'm just misunderstanding how this is supposed to work, I'm sorry in advance if I missed something.