Visual Studio:自动参考清理?

发布于 2024-12-09 01:48:27 字数 302 浏览 0 评论 0原文

有没有办法找出解决方案中未使用的程序集并自动删除它们? (就像删除不需要的 using 语句一样。)

旁注:

如果可以有一个算法/程序自动遍历大型解决方案中的所有代码,以尝试找到重构它的最佳方法,那不是很好吗?一组更符合逻辑/更易于管理的项目,彼此之间和其他程序集的引用尽可能少?

是的,我知道这应该从一开始就完成并在整个项目中维护。但是执行此操作的所有信息都可供计算机使用,因此它应该可以为我们执行此操作。至少给我们一些好的替代方案的提示。我还没有研究这么多,但可能已经有解决方案了吗?有谁知道吗?我想 ReSharper 不能做到这一点?

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.)

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

今天小雨转甜 2024-12-16 01:48:27

这个问题非常广泛。

但是,如果您知道自己想要实现什么目标,NDepend 是一个可以极大帮助您工作的工具

NDepend 相对而言擅长检测依赖性、连接组件,并具有高度复杂的查询语言来查找某些模式(或模式违规)。

然后我会应用 Resharper 来实际执行最多的重构。

编辑为了回答已编辑的问题:要清理不需要的引用,您可以通过以下任何方式使用Resharper:

  1. 每个引用,查找依赖代码,如果没有找到结果,删除参考。
  2. 只需将它们全部删除,然后让 Resharper 建议您需要哪些(Alt+Enter

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 is relatively good at detecting dependency, connected components and has a highly sophisticated Query Language to find certain patterns (or pattern violations).

I'd then apply Resharper to actually perform the most refactorings.

Edit In response to edited question: to clean unneeded references, you might use Resharper in any of the following ways:

  1. per reference, Find Dependent Code and if no results are found, remove the reference.
  2. just remove them all and let Resharper suggest which ones you needed (Alt+Enter)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文