Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ambiguous overloads for ObservableCacheEx.ExpireAfter() and ObservableListEx.ExpireAfter(). #822

Merged
merged 2 commits into from
Jun 6, 2024

Conversation

JakenVeina
Copy link
Collaborator

@JakenVeina JakenVeina commented Jan 5, 2024

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 JakenVeina added bug breaking change Items that contain a breaking change to the codebase labels Jan 5, 2024
@JakenVeina JakenVeina marked this pull request as draft January 5, 2024 03:29
@dwcullop
Copy link
Member

dwcullop commented Jan 6, 2024

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.

@JakenVeina JakenVeina force-pushed the bug/ambiguous-expire-after-overloads branch from 664f7f3 to 4aec675 Compare February 14, 2024 00:50
@JakenVeina JakenVeina changed the title Fixed ambiguous overloads for ObservableCacheEx.ExpireAfter(). Fixed ambiguous overloads for ObservableCacheEx.ExpireAfter() and ObservableListEx.ExpireAfter(). Feb 14, 2024
@JakenVeina
Copy link
Collaborator Author

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

@RolandPheasant
Copy link
Collaborator

@JakenVeina apart form merge conflicts, is this ready?

@JakenVeina JakenVeina force-pushed the bug/ambiguous-expire-after-overloads branch from 4aec675 to f07f8cb Compare June 5, 2024 00:53
@JakenVeina JakenVeina marked this pull request as ready for review June 5, 2024 01:47
@RolandPheasant RolandPheasant self-requested a review June 6, 2024 05:33
@JakenVeina JakenVeina merged commit 903afc8 into main Jun 6, 2024
1 check passed
@JakenVeina JakenVeina deleted the bug/ambiguous-expire-after-overloads branch June 6, 2024 05:40
Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators Jun 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking change Items that contain a breaking change to the codebase bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants