views:

164

answers:

5

Is there a tool available that can scan code and check for possible null reference exceptions, i.e. where there is no code to check for null before calling a method / accessing a property?

+8  A: 

ReSharper can do this.

John Saunders
+5  A: 

Resharper will offer suggestions for when you might have accessed a member on an object that could be null.

In 4.0, "code-contracts" support this at compile time - for example, it will stop you passing a possible-null into a method that states it doesn't want one.

Marc Gravell
+1  A: 

resharper is checking

ArsenMkrt
+1  A: 

RedGate has a commercial tool called Exception Hunter that can analyse your (compiled) code and show which exceptions can be thrown from an given function. You can also find all methods that throw a particular exception.

adrianbanks
A: 

Perhaps you may be interested in the new contracts goodies in .NET 4.0?

Ion Todirel