c# - Why is resharper suggesting that the left operand is never null -


seems dialog results return nullable boolean (bool?), whenever using return dialog, should take care of null option (which i'm yet waiting see happening ... ).

the above code (vs2012, resharper 8), suggests left operand never null. ideas why?

bool? dlg_result = some_window.showdialog(); bool some_bool = !dlg_result ?? true; // resharper suggests won't happen. 

here's screenshot, easier see:

screenshot

edit:
i've had in resharper files, , seems showdialog won't null when using commondialog , control, might null when using window. attaching screenshot.
have dig bit deeper seems, since i'm not sure 1 i'm using.

screenshot2

resharper includes feature called code annotations provides mechanism decorating source code hints resharper. example:

[notnull] public object foo() {     return null; // warning: possible 'null' assignment }       

the notnull attribute instruct resharper issue visual studio warning in method if tries return null. cause resharper issue suggestion null coalescing operator (??) not necessary because method return value never null:

foo() ?? new object; //causes '??' left operand never null suggestion 

resharper has additional support adding external annotations core .net code. allows these hints added code resharper doesn't control. (you can use if wanted add annotation 3rd party library).

so wrap up, appears resharper has annotated window.showdialog [notnull] though return type nullable, resharper "knows" never null , makes suggestion seeing.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -