DynamicData icon indicating copy to clipboard operation
DynamicData copied to clipboard

[Bug]: SourceCache with Sample and TransformWithInlineUpdate throws DynamicData.MissingKeyException

Open ethpch opened this issue 4 months ago • 7 comments

Describe the bug 🐞

SourceCache with Sample and TransformWithInlineUpdate throws DynamicData.MissingKeyException with message "1 is not found." Sample with Transform works well, but I need inline update to ensure correct selection behavior in DataGrid control.

SourceCache<..., ...> cache = new(...);
cache.Connect()
     .Sample(TimeSpan.FromMilliseconds(1000))
     //.Transform(x => ...)         //works well
     .TransformWithInlineUpdate(    //throws on running
         transformFactory: x => ...,
         updateAction: (y, x) => ...,
         )
     .Subscribe();

Observable.Timer(TimeSpan.Zero, TimeSpan.FromMilliseconds(100))
    .Subscribe(x =>
        cache.AddOrUpdate(...);
    );

And I find that if difference of elapse of Timer and Sample is small like this:

cache.Connect()
     .Sample(TimeSpan.FromMilliseconds(1000))
...
Observable.Timer(TimeSpan.Zero, TimeSpan.FromMilliseconds(980))

it won't throw the exception, sometimes, maybe first run works well but stop and re-run throws. If elapse of Timer is greater than Sample it won't throw.

I have uploaded the minimum console project.

Step to reproduce

  1. Clone the reproduction repository
  2. Build and run
  3. See error

Reproduction repository

https://github.com/ethpch/DynamicData.Test

Expected behavior

Sample with TransformWithInlineUpdate works as expected.

Screenshots 🖼️

image

IDE

Visual Studio 2022

Operating system

Windows

Version

23H2, 22631.4317

Device

Desktop

DynamicData Version

9.0.4

Additional information ℹ️

No response

ethpch avatar Oct 18 '24 11:10 ethpch