Removing all unused references from a project in Visual Studio projects

前端 未结 14 2083
北荒
北荒 2020-11-29 16:41

I just wondered if it possible within various Visual Studio versions to automatically remove all references from a project that were never been used?

In your answer,

14条回答
  •  猫巷女王i
    2020-11-29 17:20

    The following method does not depend on any 'add-on's and is not very painful.

    Step through each of your source files and

    1. Select all (Ctrl-A)
    2. Toggle outline expansion (Ctrl-M, M). This will reduce the file to two lines.
    3. Click on the namespace's '+'. This will show each of the file's classes as a single line. Scan each class's reference count, looking for unreferenced classes.
    4. Click on each of the classes' '+'. This will show each of the class functions as a single line. Scan each function's reference count, looking for unreferenced functions.

    Scanning each file looking for '0 reference' takes only a second.

    Scanning an entire project takes only a couple of minutes.

提交回复
热议问题