Roslyn: SUGGEST:Should add 'argument cannot be null' feature in C#

Created on 11 Jan 2017  路  2Comments  路  Source: dotnet/roslyn

Just like:
void Sample(object objCanNotBeNull != null)
On developing , IDE should warn 'Sample(null)'.
On runtime , application should throw a exception.

In most cases,we don't want the function arguments to be null,then we must write 'if(obj==null) throw new exception'.It's boring and absolutely no need.Can we add this feature in new C#?

Area-Language Design

All 2 comments

See Mads's recent overview of "non-nullable reference types" being prototyped for C# 8.0. Stay tuned for updates.
I'll go ahead and close this issue. Thanks

Was this page helpful?
0 / 5 - 0 ratings