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

DbSet<TEntity>.FindAsync() returns ValueTask<TEntity> instead of ValueTask<TEntity?> #20493

Closed
prefetcher-gl opened this issue Mar 30, 2020 · 3 comments

Comments

@prefetcher-gl
Copy link

Version Used:
VS 2019 Version 16.5.1
.NET Core 3.1.3

Also tested on:
VS 2019 16.6.0 Preview 2.0
.NET 5.0.0-preview.1

Steps to Reproduce:

public async Task<string> GetString()
{
    DbSet<string> dbSetStrings = null!;
    string? canBeNull = await dbSetStrings.FindAsync();
    return canBeNull;
}

Actual Behavior:
VS popup tip on return canBeNull says that "canBeNull is not null here". MS Docs tells "If no entity is found, then null is returned", doc comments in metadata of DbSet tells the same.
Change DbSet<string> dbSetStrings to DbSet<string?> dbSetStrings and tip says "may be null here" on return canBeNull.

Expected Behavior:
DbSet<TEntity>.FindAsync() may return ValueTask with null, so the return type must be ValueTask<TEntity?>.

BTW, the method return type from metadata is ValueTask<TEntity>, but it shows Task<TEntity> in the Docs.

@YairHalberstadt
Copy link

Most of the BCL has not yet been annotated. Either way this is an issue for dotnet/runtime

@prefetcher-gl
Copy link
Author

Oh, yes... Please transfer this issue to dotnet/efcore (or where it should be).

@jinujoseph jinujoseph transferred this issue from dotnet/roslyn Apr 1, 2020
@ajcvickers
Copy link
Member

Duplicate of #19007

@ajcvickers ajcvickers marked this as a duplicate of #19007 Apr 2, 2020
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants