Skip to content
Discussion options

You must be logged in to vote

I think that's exactly the right behavior. Consider this modification to your code:

public void Foo(IDictionary<string, Bar?> lookup) {
   lookup.Add("foo", null);
}

Now in Test, you have Dictionary<string, Bar> which can give you null Bar, so there should be a warning somewhere and I think where the compiler puts it now is the right place for it.

Also, instead of all those #nullable disable/enable, you can just use !.

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@333fred
Comment options

@bbarry
Comment options

@svick
Comment options

svick Sep 11, 2020
Collaborator

@bbarry
Comment options

Answer selected by bbarry
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants