Skip to content

[Bug]: ArgumentOutOfRangeException/Index out of range exception when using TransformAsync #623

Description

@oysteinkrog

Describe the bug 🐞

Message: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
Source: System.Private.CoreLib
TargetSite: Void ThrowArgumentOutOfRange_IndexException()
StackTrace:
   at void DynamicData.ChangeAwareList<T>.InsertItem(int index, T item) in /_/src/DynamicData/List/ChangeAwareList.cs:line 445
   at async Task DynamicData.List.Internal.TransformAsync<TSource, TDestination>.Transform(ChangeAwareList<TransformedItemContainer> transformed, IChangeSet<TSource> changes) in /_/src/DynamicData/List/Internal/TransformAsync.cs:line 78
   at async Task<ChangeAwareList<TransformedItemContainer>> DynamicData.List.Internal.TransformAsync<TSource, TDestination>+<>c__DisplayClass3_0.<Run>b__1(?)+(?) => { } in /_/src/DynamicData/List/Internal/TransformAsync.cs:line 52
   at void System.Reactive.PlatformServices.ExceptionServicesImpl.Rethrow(Exception exception) in /_/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServicesImpl.cs:line 19
   at void System.Reactive.ExceptionHelpers.Throw(Exception exception) in /_/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServices.cs:line 16
   at void System.Reactive.Stubs.Throw(Exception ex) in /_/Rx.NET/Source/src/System.Reactive/Internal/Stubs.cs:line 16
   at void System.Reactive.AnonymousSafeObserver<T>.OnError(Exception error) in /_/Rx.NET/Source/src/System.Reactive/AnonymousSafeObserver.cs:line 62
   at void System.Reactive.Sink<TTarget>.ForwardOnError(Exception error) in /_/Rx.NET/Source/src/System.Reactive/Internal/Sink.cs:line 60
   at void System.Reactive.Concurrency.Synchronize<TSource>+_.OnError(Exception error) in /_/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.Synchronize.cs:line 50
   at void System.Reactive.AutoDetachObserver<T>.OnErrorCore(Exception exception) in /_/Rx.NET/Source/src/System.Reactive/Internal/AutoDetachObserver.cs:line 77
   at void System.Reactive.ObserverBase<T>.OnError(Exception error) in /_/Rx.NET/Source/src/System.Reactive/ObserverBase.cs:line 59
   at void System.Reactive.Sink<TTarget>.ForwardOnError(Exception error) in /_/Rx.NET/Source/src/System.Reactive/Internal/Sink.cs:line 60
   at void System.Reactive.Sink<TSource, TTarget>.OnError(Exception error) in /_/Rx.NET/Source/src/System.Reactive/Internal/Sink.cs:line 94
   at void System.Reactive.Subjects.Subject<T>.OnError(Exception error) in /_/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs:line 120
   at void DynamicData.SourceList<T>.OnError(Exception exception) in /_/src/DynamicData/List/SourceList.cs:line 204
.....
....


InnerException(1): System.ArgumentOutOfRangeException
Message: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
Source: System.Private.CoreLib
TargetSite: Void ThrowArgumentOutOfRange_IndexException()
StackTrace:
   at void DynamicData.ChangeAwareList<T>.InsertItem(int index, T item) in /_/src/DynamicData/List/ChangeAwareList.cs:line 445
   at async Task DynamicData.List.Internal.TransformAsync<TSource, TDestination>.Transform(ChangeAwareList<TransformedItemContainer> transformed, IChangeSet<TSource> changes) in /_/src/DynamicData/List/Internal/TransformAsync.cs:line 78
   at async Task<ChangeAwareList<TransformedItemContainer>> DynamicData.List.Internal.TransformAsync<TSource, TDestination>+<>c__DisplayClass3_0.<Run>b__1(?)+(?) => { } in /_/src/DynamicData/List/Internal/TransformAsync.cs:line 52
   at void System.Reactive.PlatformServices.ExceptionServicesImpl.Rethrow(Exception exception) in /_/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServicesImpl.cs:line 19
   at void System.Reactive.ExceptionHelpers.Throw(Exception exception) in /_/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServices.cs:line 16
   at void System.Reactive.Stubs.Throw(Exception ex) in /_/Rx.NET/Source/src/System.Reactive/Internal/Stubs.cs:line 16
   at void System.Reactive.AnonymousSafeObserver<T>.OnError(Exception error) in /_/Rx.NET/Source/src/System.Reactive/AnonymousSafeObserver.cs:line 62
   at void System.Reactive.Sink<TTarget>.ForwardOnError(Exception error) in /_/Rx.NET/Source/src/System.Reactive/Internal/Sink.cs:line 60
   at void System.Reactive.Concurrency.Synchronize<TSource>+_.OnError(Exception error) in /_/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.Synchronize.cs:line 50
   at void System.Reactive.AutoDetachObserver<T>.OnErrorCore(Exception exception) in /_/Rx.NET/Source/src/System.Reactive/Internal/AutoDetachObserver.cs:line 77
   at void System.Reactive.ObserverBase<T>.OnError(Exception error) in /_/Rx.NET/Source/src/System.Reactive/ObserverBase.cs:line 59

Step to reproduce

I will try to create a repro scenario.

Reproduction repository

N/A yet

Expected behavior

Exception should not happen :)

Screenshots 🖼️

No response

IDE

No response

Operating system

No response

Version

No response

Device

No response

DynamicData Version

7.9.7

Additional information ℹ️

This is with the latest DD version (after index out of range fix for normal Transform).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions