Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is static code verification for potential null object references available?

I would like a way to get warnings when an object reference could potentially throw a Null Reference Exception, so that I can write defensive code for these.

I have looked at Resharper, but didn't see anything there that accomplishes this.

Code Contracts is probably a non-starter; the application is quite large, and it's written in .NET 3.5, before Code Contracts became officially available.

like image 534
Robert Harvey Avatar asked Apr 11 '12 15:04

Robert Harvey


1 Answers

Resharper does in fact accomplish something like this. Possible NullReferenceExpections are highlighted in the IDE in blue, with tooltips when you hover over them.

enter image description here

Resharper then keeps track of potential errors and warnings in it's own inspection results window (separate from Visual Studio's compiler errors and warnings).

enter image description here

like image 146
raveturned Avatar answered Nov 15 '22 04:11

raveturned