Don't identify dictionary indexer as NRT #22068
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We currently don't calculate nullability for generic properties, since that's a complex task (dotnet/runtime#29723 is supposed to add this capability to the reflection API at some point). This interferes with the ability to use Dictionary for property bag, since it's a generic type and its indexer is incorrectly identified as non-nullable (the actual nullability of the generic type argument isn't taken into account).
The general inability to handle generic properties hasn't proved problematic - it's been this way since EF Core 3.0 and we've received no user complaints. This is a specific fix to recognize the indexer on Dictionary and not identify it as non-nullable. If this is OK to merge, I'll document the general limitation in our doc page on nullability, and open a separate issue for handling generic properties.
Fixes #20718