Clean up unwanted code C#

好久不见. 提交于 2019-11-30 20:27:20

Resharper has a Clean Code function and gives pretty good indication of which methods/classes aren't being used.

You can query your code base with NDepend using CQL to find out which methods and classes are not being used.

Be careful of code that is invoked via reflection. A lot of refactoring tools will flag this code as not being accessed when in fact they are.

The safest is to run your unit tests (you do have these already right?) before and after the refactoring to ensure that everything still works.

1st use re-sharper as other have suggested.

Resharper assumes public methods are used somewhere by an external assembly, even if they are not, so search and replace "public " with "private " and recompile.

I have used Gendarme (like FxCop) to determine which code wasn't called. AFAIK it can't be automated, but at least you don't need to go line by line.

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