简体   繁体   English

Visual Studio:自动参考清理?

[英]Visual Studio: Automated reference cleaning?

Is there any way of finding out what assemblies that's not used in a solution and have them removed automatically? 有没有办法找出解决方案中没有使用的组件并自动删除它们? (Just like when removing unneeded using-statements.) (就像删除不需要的using语句一样。)

Side note: 边注:

Wouldnt it be nice if it was possible to have an algorithm/program to automatically go through all code in a large solution to try to find the optimal way of refactoring it to get a more logical/managable set of projects thats has as few references to each other and other assemblies as possible? 如果有可能让算法/程序自动遍历大型解决方案中的所有代码以试图找到重构它的最佳方式以获得更具逻辑性/可管理的项目集合,那么它是不是很好彼此和其他组件尽可能?

Yes I know this should have been done from the beginning and maintained throughout the project. 是的我知道这应该从一开始就完成并在整个项目中得到维护。 But all information to do this is available to the computer so it should be possible for it to do this for us. 但是所有这样做的信息都可供计算机使用,因此它应该可以为我们这样做。 At least give us hints about some good alternatives. 至少给我们一些关于一些好的选择的提示。 I havent researched this much but there may allready be solutions for this? 我没有研究过这么多,但可能已经有了解决方案吗? Do anyone know? 有人知道吗? ReSharper cant to this I guess? 我觉得ReSharper不能这样吗?

The question is mighty broad. 这个问题非常广泛。

However, if you know what you are trying to achieve, NDepend is a tool that will greatly assist your work 但是,如果您知道自己要实现的目标, NDepend是一款可以极大地帮助您完成工作的工具

NDepend is relatively good at detecting dependency, connected components and has a highly sophisticated Query Language to find certain patterns (or pattern violations). NDepend在检测依赖关系,连接组件方面相对较好,并且具有高度复杂的查询语言以查找某些模式(或模式违规)。

I'd then apply Resharper to actually perform the most refactorings. 然后我应用Resharper来实际执行最多的重构。

Edit In response to edited question: to clean unneeded references, you might use Resharper in any of the following ways: 编辑响应编辑过的问题:要清除不需要的引用,您可以通过以下任何方式使用Resharper:

  1. per reference, Find Dependent Code and if no results are found, remove the reference. 每个参考, Find Dependent Code ,如果没有找到结果,删除参考。
  2. just remove them all and let Resharper suggest which ones you needed ( Alt + Enter ) 只需将它们全部删除,让Resharper建议您需要哪些( Alt + Enter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM