Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/DynamicData.Tests/Cache/TransformImmutableFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,26 @@ public void TransformFactoryThrows_ExceptionIsCaptured()
results.IsCompleted.Should().BeFalse();
}

// https://github.com/reactivemarbles/DynamicData/issues/925
[Fact]
public void TDestinationIsValueType_DoesNotThrowException()
{
using var source = new Subject<IChangeSet<string, string>>();

using var results = source
.TransformImmutable(transformFactory: static value => value.Length)
.AsAggregator();


source.OnNext(new ChangeSet<string, string>()
{
new(reason: ChangeReason.Add, key: "Item #1", current: "Item #1", index: 0)
});

results.Error.Should().BeNull();
results.Messages.Count.Should().Be(1, "1 source operation was performed");
}

private class Item
{
public static readonly Func<Item, int> IdSelector
Expand Down
4 changes: 3 additions & 1 deletion src/DynamicData/Cache/Internal/TransformImmutable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Reactive;
using System.Reactive.Linq;

using DynamicData.Kernel;

namespace DynamicData.Cache.Internal;

internal sealed class TransformImmutable<TDestination, TSource, TKey>
Expand Down Expand Up @@ -40,7 +42,7 @@ public IObservable<IChangeSet<TDestination, TKey>> Run()
current: _transformFactory.Invoke(change.Current),
previous: change.Previous.HasValue
? _transformFactory.Invoke(change.Previous.Value)
: default,
: Optional.None<TDestination>(),
currentIndex: change.CurrentIndex,
previousIndex: change.PreviousIndex));
}
Expand Down