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

Remove last ! from Caching.Abstractions #85918

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hrrrrustic
Copy link
Contributor

Close #64147

@msftbot msftbot bot added the community-contribution Indicates that the PR has been added by a community member label May 8, 2023
@msftbot
Copy link
Contributor

msftbot bot commented May 8, 2023

Tagging subscribers to this area: @dotnet/area-extensions-caching
See info in area-owners.md if you want to be subscribed.

Issue Details

Close #64147

Author: hrrrrustic
Assignees: -
Labels:

area-Extensions-Caching

Milestone: -

@@ -174,7 +174,8 @@ public static ICacheEntry SetOptions(this ICacheEntry entry, MemoryCacheEntryOpt

foreach (PostEvictionCallbackRegistration postEvictionCallback in options.PostEvictionCallbacks)
{
entry.RegisterPostEvictionCallback(postEvictionCallback.EvictionCallback!, postEvictionCallback.State);
ArgumentNullException.ThrowIfNull(postEvictionCallback.EvictionCallback);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a beneficial change? It seems like it's adding another check-and-throw that's just duplicating what RegisterPostEvictionCallback is about to do, anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not opposite to simply remove !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a small discussion #64147 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not opposite to simply remove !

EvictionCallback is typed as PostEvictionDelegate?. RegisterPostEvictionCallback is typed to accept PostEvictionDelegate. So we can't just remove the !. I'm just not clear on why we need to change anything here, if all we're going to do is throw the same exception.

Copy link
Contributor Author

@hrrrrustic hrrrrustic May 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's fine to just pass null to the next check in RegisterPostEvictionCallback, I'll update it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update it

Update it to what? The ! is necessary to suppress the warning about passing in something that's possibly null to something that requires not-null, right?

From the discussion you linked to, it sounds like the goal of the issue was to review !s in the library and this was the last one. This one is actually necessary, so I'd suggest we just close that issue and this PR.

But I'll leave it for @eerhardt to decide, since he was part of that linked conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Extensions-Caching community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove ! from Microsoft.Extensions.Caching.Abstractions
2 participants