C#/.NET analysis tool to find race conditions/deadlocks

Steve Dunn picture Steve Dunn · Mar 4, 2010 · Viewed 19.7k times · Source

Is there a tool that analyses .NET code and finds race conditions?

I have a bit of code that has a public static property that gets or creates a private static field. It also has a public static method that sets this field to null (...yes, I know!..)

As there are no locks around either of these methods, it's a safe bet that things'll go horribly wrong in the future. I need a tool that'll recursively go through things that call either of these methods and see if anything was spawned on another thread.

I'm looking for a tool or perhaps an nDepend SQL script (if this is possible).

Answer

Lasse V. Karlsen picture Lasse V. Karlsen · Mar 4, 2010

You're probably looking for one of these:


NOTE: This answer is from 2010. As with all recommendations answers, recommendations tend to change over time. There may be other products out there now, CHESS which was a Microsoft Research Labs project may have evolved into a final product or been scrapped altogether. Please take this answer with a grain of salt and conduct new research into which products are suitable now.