Is there a tool that can check for null reference exceptions?
-
16-09-2019 - |
Question
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?
Solution
ReSharper can do this.
OTHER TIPS
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.
resharper is checking
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.
Perhaps you may be interested in the new contracts goodies in .NET 4.0?