You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: SortAndVirtualize emits all items if the virtual request window size is 0. #1037
For some scenario that requires lazy load, an initial virtualize window size 0 is expected. However, when a virtual request has size of 0, the SortAndVirtualize will ignore the request and emit all items to downstream.
I think this is the code that caused this problem, if the size is 0, the request is ignored.
var paramsChanged = _virtualRequests.Synchronize(locker)
.DistinctUntilChanged()
// exclude dodgy params
.Where(parameters => parameters is { StartIndex: >= 0, Size: > 0 })
.Select(request =>
{
virtualParams = request;
// have not received the comparer yet
if (applicator is null) return Empty;
// re-apply virtual changes
return ApplyVirtualChanges();
});
Sorry for the delayed response. I wanted to give @RolandPheasant a chance to address it, as it was his operator, and he would know if there's a specific reason this was intentional.
For my part, though, I agree, the behavior is counter-intuitive, and unless it's documented as intentional, I'd say it's a defect. However..... it kinda IS documented as intentional? Sort of? There's other virtualization operators that explicitly state they don't accept size values of 0. Some of them are marked Obsolete, but at least one of them is not.
thrownewArgumentOutOfRangeException(nameof(numberOfItems),"Number of items should be greater than zero");
If we're going to change the behavior, we'll probably want to be consistent across the board, so I'd like to have at least @RolandPheasant weigh in on the impact of changing these old operators to now allow empty pages. From what I can tell, the impact is minimal. There's a handful of spots where we're artificially restricting ourselves to Size values being greater than 0meaning the only change is that we no longer throw exceptions where we did before. The actual core virtualizer logic only passes .Size to Enumerable.Take(), which is perfectly happy to spit out an empty sequence. Likewise, within VirtualResponse, there's no restriction placed on .Size, and that appears to be an exclusively-public API: nothing inside DynamicData uses it to do anything downstream of a virtualization operator.
I've got a preliminary PR written up that should do the trick, if we want to go forward with the change.
Activity
JakenVeina commentedon Oct 6, 2025
Sorry for the delayed response. I wanted to give @RolandPheasant a chance to address it, as it was his operator, and he would know if there's a specific reason this was intentional.
For my part, though, I agree, the behavior is counter-intuitive, and unless it's documented as intentional, I'd say it's a defect. However..... it kinda IS documented as intentional? Sort of? There's other virtualization operators that explicitly state they don't accept
sizevalues of0. Some of them are markedObsolete, but at least one of them is not.DynamicData/src/DynamicData/Cache/ObservableCacheEx.VirtualiseAndPage.cs
Line 135 in 3d72c9e
Also, its equivalent in List-land.
DynamicData/src/DynamicData/List/ObservableListEx.cs
Line 1819 in 3d72c9e
If we're going to change the behavior, we'll probably want to be consistent across the board, so I'd like to have at least @RolandPheasant weigh in on the impact of changing these old operators to now allow empty pages. From what I can tell, the impact is minimal. There's a handful of spots where we're artificially restricting ourselves to
Sizevalues being greater than 0meaning the only change is that we no longer throw exceptions where we did before. The actual core virtualizer logic only passes.SizetoEnumerable.Take(), which is perfectly happy to spit out an empty sequence. Likewise, withinVirtualResponse, there's no restriction placed on.Size, and that appears to be an exclusively-public API: nothing inside DynamicData uses it to do anything downstream of a virtualization operator.I've got a preliminary PR written up that should do the trick, if we want to go forward with the change.