Is there a tool for finding unreferenced functions

2019-01-07 09:54发布

I want to delete foo() if foo() isn't called from anywhere.

7条回答
贪生不怕死
2楼-- · 2019-01-07 10:20

Gendarme will detect private methods with no upstream callers. It is available cross platform, and the latest version handles "AvoidUncalledPrivateCodeRule".

FxCop will detect public/protected methods with no upstream callers. However, FxCop does not detect all methods without upstream callers, as it is meant to check in the case that your code is part of a Library, so public members are left out. You can use NDepend to do a search for public members with no upstream callers, which I detail here in this other StackOverflow answer.

(edit: added information about Gendarme which actually does what the questioner asked)

查看更多
登录 后发表回答