DynamicData icon indicating copy to clipboard operation
DynamicData copied to clipboard

Fixed ambiguous overloads for `ObservableCacheEx.ExpireAfter()` and `ObservableListEx.ExpireAfter()`.

Open JakenVeina opened this issue 2 years ago • 2 comments

Also moved EnsureUniqueKeys() into proper order.

Currently, the following code produces an ambigous method error at compile-time, for the call to .ExpireAfter().

var source = new SourceCache<string, int>(x => x.GetHashCode());

var result = source.ExpireAfter(_ => TimeSpan.FromSeconds(1));

Since any fix for this would be a breaking change, I've implemented it by just consolidating all of the overloads into one method, for simplicity.

The issue itself is relatively minor, as it can be easily worked-around by doing...

var source = new SourceCache<string, int>(x => x.GetHashCode());

var result = source.ExpireAfter(
    timeSelector: _ => TimeSpan.FromSeconds(1),
    interval: null);

or

var source = new SourceCache<string, int>(x => x.GetHashCode());

var result = source.ExpireAfter(
    timeSelector: _ => TimeSpan.FromSeconds(1),
    scheduler: null);

Since this is a breaking change with low impact, I would propose NOT merging this until we already have a major-version change queued up, due to other issues or enhancements.

JakenVeina avatar Jan 05 '24 03:01 JakenVeina

Even though it's a breaking change, I think this is a good thing. Waiting until a major release mitigates the breaking change somewhat... Thanks for this.

Maybe we should examine the APIs for similar ambiguous overloads and put all the fixes into a feature branch that can be merged before the next major rev. That would be better than making more breaking changes later.

dwcullop avatar Jan 06 '24 17:01 dwcullop

Turns out the list version of ExpireAfter has the exact same issue, so I added the fix for that as well.

JakenVeina avatar Feb 14 '24 00:02 JakenVeina

@JakenVeina apart form merge conflicts, is this ready?

RolandPheasant avatar Jun 03 '24 10:06 RolandPheasant

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Jun 21 '24 01:06 github-actions[bot]