-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Fix nullable detection #12202
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
Fix nullable detection #12202
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, two comments:
- Not sure if model processing speed is an issue, but you may want to look at caching context nullability at the type and module level, to avoid doing a lot of reflection over and over again. In EF Core we've seen some
insaneprolific models where this could be an issue. - I can see the comment about not handling generics and NNRT, but we may want to consider identifying pre- and post-conditions such as [MaybeNull] (fully explained here).
src/Mvc/Mvc.DataAnnotations/src/DataAnnotationsMetadataProvider.cs
Outdated
Show resolved
Hide resolved
src/Mvc/Mvc.DataAnnotations/src/DataAnnotationsMetadataProvider.cs
Outdated
Show resolved
Hide resolved
src/Mvc/Mvc.DataAnnotations/src/DataAnnotationsMetadataProvider.cs
Outdated
Show resolved
Hide resolved
src/Mvc/Mvc.DataAnnotations/src/DataAnnotationsMetadataProvider.cs
Outdated
Show resolved
Hide resolved
Thanks @roji I'm not immediately concerned about intermediate caching, the results of this will all be cached as well.
Are these types actually defined anywhere? I keep seeing design notes, but I don't see these types in use anywhere. |
00b152e
to
72b778a
Compare
72b778a
to
3fab972
Compare
Take a look in corefx, they're used a lot there. BTW unlike NullableAttribute and NullableContextAttribute, these are actually defined in System.Diagnostics.CodeAnalysis (not sure why the different approach). Note also https://github.com/dotnet/corefx/issues/36222#issuecomment-511973898 (things are going to change again a bit..). |
It seems like most of the overlap here is with generic-typed fields and properties right? |
I think so, but there are also some other cases. For example, you may want to have a property that can be set to null but will never return null (e.g. because it will return some sort of default). Exactly how we interpret that in ASP.NET/EF is also not immediately obvious. |
Fixes: #11828 and #11813