How to easyily find unused public methods/properties

北慕城南 提交于 2019-12-10 03:50:00

问题


I have a .Net(C#) solution. The solution contains bunch of projects. The projects were implemented not by me. It is not a framework, it means that I need to have amount of public methods/properties as less as possible. My task is to identify methods and properties which are not used, but exist in the projects. Well, I can find private methods which are not used using R#. But it is completely unclear how to find public methods/properties which are not used.

I heard that they have NDepend tool, but it is not very simple tool, is it.

So, the question is: could you please point to a tool which can be used to identify methods which are not used in a solution. It is OK with me to have command line tool or something pretty simple.

UPD: I tried to use trial NDepend.

Well, first of all it seems like it is possible to see public methods (properties are represented as get_ set_ methods) which are not used in this particular assembly.

But NDepend does not recognize if the public method is used from another project/assembly, which is a part of the solution and shows the method as unused. But this is not true.

UPD2: mcintyre321 advised to use R#. Please read a first comment below.


回答1:


If you turn on solution wide analysis in ReSharper (5.0 and above) it will flag them for you. This includes public methods.

  • Explanation of Solution-Wide analysis

  • How to enable




回答2:


Heck I have done it old school. I just comment out methods I don't think are being used and build. If I get an error, then I leave it there.



来源:https://stackoverflow.com/questions/1471855/how-to-easyily-find-unused-public-methods-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!