C# 删除未使用的引用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1788629/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove unused references
提问by Cornel
I want to know if any tool exists for removing unused references (notunused using
directives) within a .NET C# project.
我想知道是否存在用于删除.NET C# 项目中未使用的引用(不是未使用的using
指令)的工具。
采纳答案by Sam Harwell
I am unaware of such a tool off the top of my head - I do know that Visual Studio does not include one by default. However, referenced assemblies that are not actually used by code in the project are automatically removed by the C# compiler from the list of assemblies referenced by the compiled program. If you use Reflector, you can compare the list of actual references to the list of references in the project, and remove the unnecessary ones that the project includes based on that.
我不知道有这样一个工具——我知道 Visual Studio 默认不包含一个。但是,C# 编译器会自动从已编译程序引用的程序集列表中删除项目中代码实际未使用的引用程序集。如果您使用Reflector,您可以将实际引用列表与项目中的引用列表进行比较,并在此基础上删除项目包含的不必要的引用。
回答by Cédric Rup
Resharper will certainly do the trick...
Resharper 肯定会做到这一点......
回答by Carra
Resharper has that option.
Resharper 有这个选项。
回答by Laguna
Check out the Productivity Power-tool Plugin
Removing unused references from project is one of the many helpful features it has. It is free and it has some of the R# features.
从项目中删除未使用的引用是它具有的众多有用功能之一。它是免费的,并且具有一些R# 功能。
回答by David Ferenczy Rogo?an
JetBrains Resharper adds a menu item Remove Unused Referencesto the Referencesnode's context menu in the Solution Explorer.
JetBrains Resharper在解决方案资源管理器的References节点的上下文菜单中添加了一个菜单项Remove Unused References。
When you click it, it'll scan you project and list references which can be removed. You can further select which ones you want to remove.
当您单击它时,它会扫描您的项目并列出可以删除的引用。您可以进一步选择要删除的那些。
回答by Yousha Aleayoub
ResolveUR- Resolve Unused Referencese Unused References
ResolveUR- 解析未使用的引用未使用的引用
https://marketplace.visualstudio.com/items?itemName=battas.ResolveUR-ResolveUnusedReferences
https://marketplace.visualstudio.com/items?itemName=battas.ResolveUR-ResolveUnusedReferences
Works with Visual Studio 2013, 2015, 2017 and 2019
适用于 Visual Studio 2013、2015、2017 和 2019