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

Nullable Reference Type for FirstOrDefaultAsync #19443

Closed
Vake93 opened this issue Dec 31, 2019 · 5 comments
Closed

Nullable Reference Type for FirstOrDefaultAsync #19443

Vake93 opened this issue Dec 31, 2019 · 5 comments

Comments

@Vake93
Copy link

Vake93 commented Dec 31, 2019

My project has nullable reference types enabled and the following code has the warning CS8619 Nullability of reference types in value of type 'Task' doesn't match target type 'Task<User?>'.

image

FirstOrDefaultAsync can return null and shouldn't FirstOrDefaultAsync return Task<User?> ?

Further technical details

EF Core version: 3.1.0
Database provider: Npgsql.EntityFrameworkCore.PostgreSQL 3.1.0
Target framework: .NET Core 3.1
Operating system: Windows 10
IDE: Visual Studio 2019 16.4.2

@ajcvickers
Copy link
Member

@roji Thoughts?

@mqudsi
Copy link

mqudsi commented Jan 2, 2020

Is there a master issue tracking issues relating to non-nullable reference types, or is there a document containing known issues or limitations? We're seeing some nullability confusion regarding the values passed in to linq functors or as return values from linq expressions.

@roji
Copy link
Member

roji commented Jan 3, 2020

Yeah, we need to annotate our async LINQ extensions for nullability - this is part of #19007. We can close this as a duplicate of that, although there may be value in keeping this open as it's a particularly visible area of the API. Note that System.Linq has already been annotated, so we should be following that (although async may make that a bit challenging).

Is there a master issue tracking issues relating to non-nullable reference types, or is there a document containing known issues or limitations?

There's the Nullable Reference Types doc page which contains most information NRTs, I'll add a note about this current limitation.

@roji
Copy link
Member

roji commented Jan 3, 2020

Submitted dotnet/EntityFramework.Docs#2022

@prashantaggarwal1990

This comment has been minimized.

@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

5 participants