How to remove unused features in Visual Studio 2013

Is there a way to show unused features in Visual Studio 2013?

What is the best solution to remove these features?

+6
source share
3 answers

ReSharper can detect and highlight dead code when solution analysis is enabled.

It will report some false positives, so manual verification is still necessary. For example, R # will not determine when a function is used only through reflection, and will consider that it is not used. The same goes for things like agreement-based IoC containers, etc.

JetBrains provides some custom attributes to decorate your code (for example, [UsedImplicitly] ). They guide the R # parsing engine and document your code.

+7
source

If you enable code analysis (Project => Properties => Code Analysis), you will get a list of problems. This list uses unused methods or variables, as well as many other potential problems.

+6
source

You can use the NDepend tool to search for unused functions. NDepend is integrated into Visual Studio to write code rules as C # LINQ queries. About 200 default code rules are provided, and 3 of them are:

Such a request can be executed and edited in real time in Visual Studio, and the matching methods (here unused methods) are listed.

Potentially dead method in visual studio with ndepend

+2
source

Source: https://habr.com/ru/post/973363/


All Articles