Clean up unwanted code C#

前端 未结 5 517
自闭症患者
自闭症患者 2021-01-05 14:37

I got a C# application with Visual Studio 2005. The code has some 300 KLOC, which has been abused over 3 years.

When I was going through code found out that lot of

相关标签:
5条回答
  • 2021-01-05 14:54

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

    0 讨论(0)
  • 2021-01-05 14:58

    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.

    0 讨论(0)
  • 2021-01-05 15:02

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

    0 讨论(0)
  • 2021-01-05 15:08

    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.

    0 讨论(0)
  • 2021-01-05 15:16

    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.

    0 讨论(0)
提交回复
热议问题