Pherenetic
NRT: How to correctly annotate my generic-class when inheriting from another generic class?
Hello. I'm trying to correctly annotate nullable reference types (NRT) to a generic class derived from another generic class.
Here is some simplified code:
The shown implementation triggers the CS8604 as commented which I understand. But how do I tell the compiler: I don't know if the user will use a nullable type or not for
K
?
When I change Dictionary<T, K>
to Dictionary<T, K?>
intellisense says that even my instance tmp
can have null
s added but my type parameter clearly states that I don't want that to be allowed.
So how do I correctly annotate this kind of scenario (I have a couple more like that)?
Thanks in advance60 replies