is there any Open source static code analysis tool that can help to find unreachable /unused code in C# programs?
FxCop, which is built into higher editions of Visual Studio, will warn of unused private or internal members. Right-click your project and choose Run Code Analysis. In conjunction with "unreachable code segments" being identified by the compiler as others have noted, this should catch the remaining unused code.
(Note FxCop will not warn of unused public or protected members, because these could be part of an API intended for use by external callers. Also, FxCop is not available in all editions of Visual Studio though older versions are available for download.)
The best I can suggest is a code coverage tool used on the main executable instead of a test assembly, then put the application through it's paces... A static analysis of code would be NP hard to do in some more esoteric cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With