如何获取 C# 项目之间的依赖关系图
我有一个相当复杂的应用程序,它已分解为多个组件。每个组件都有一个解决方案文件,其中包含一堆项目。所以我喜欢将其视为一个包含多个项目/dll 的组件。还有一个“通用”组件。所有其他组件都依赖于“common”。所以编译是这样的: "nant component1.compile"
将编译“common”,然后编译 component1,因为 component1 依赖于“common”。 随着时间的推移,“常见”已经变得相当大了。我很确定它可以分成几个更小的组件。那么组件只需要依赖于其中一些较小的、分解的“公共”。这有望减少不同组件的编译时间。
所以问题: 我想可视化应用程序中所有不同项目之间的依赖关系,同时标记项目所属的组件。你会怎么做?
I have a fairly complex application which has been broken up into multiple components. Each component has a solution file which contains a bunch of projects. So I like to think of this as a component has multiple projects/dlls in it. There is also a "common" component. All the other components depend on "common". So a compile goes like this:"nant component1.compile"
will compile "common" and then compile component1 since component1 depends on "common".
Over time "common" has become quite big. I'm pretty sure it can be split into a few smaller components. Then components need to depend only on some of these smaller, broken up "common". This would hopefully cut down on compile time for the different components.
So question:
I'd like to visualise the dependency between all the different projects in the application while also tagging which component the project belongs to. How would you do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
你可以看看 NDepend : http://www.ndepend.com/
编辑< /em> 添加:
Patrick Smacchia,NDepend 的首席开发人员,博客在这里:http://codebetter.com/blogs/patricksmacchia/default.aspx 并写了很多关于组件化主题的文章,您可能会发现有用。
You could have a look at NDepend : http://www.ndepend.com/
edit to add:
Patrick Smacchia, lead developer of NDepend, blogs here: http://codebetter.com/blogs/patricksmacchia/default.aspx and has written much on the subject of componentisation, which you may find useful.
如果您有权访问 Visual Studio 2010 Ultimate,则可以从
体系结构
菜单中选择生成依赖关系图
。MSDN 上有一个演练:如何:为 .NET 代码生成依赖关系图< /a>
If you have access to Visual Studio 2010 Ultimate, you can select
Generate Dependency Graph
from theArchitecture
menu.There is a walkthrough on MSDN: How to: Generate Dependency Graphs for .NET Code
工具 NDepend 提出了与依赖矩阵相结合的依赖图。默认情况下,您将获得 .NET 程序集的依赖关系图,并且它不限于仅一个 VS 解决方案的程序集。 NDepend 集成在 VS 2017、2015、2013、2012、2010 中,它可以在代码上显示任何类型的图,包括:
等...
这一切都在这里进行了解释< /a>.
NDepend还提出了一个依赖结构矩阵(DSM ) 以及使用 C# LINQ 查询查询依赖项的方法。
The tool NDepend proposes a dependency graph coupled with a dependency matrix. By default you'll get a dependency graph of .NET assemblies and it is not restricted to assemblies of only one VS solution. NDepend is integrated in VS 2017, 2015, 2013, 2012, 2010 and it can show any kind of graph on your code including:
etc...
This is all explained here.
NDepend also proposes a dependency structure matrix (DSM) and a way to query dependencies with C# LINQ queries.
我会尝试将其导入到 UML 工具中,该工具可以为我呈现模块之间的依赖关系图。
市场上有几种,包括商业的和开源的。选择一款能够为您的预算提供最大功能的产品。
I'd try importing it into a UML tool that could render the dependency diagram between modules for me.
There are several on the market, both commercial and open source. Get the one that gives you the most capability for your budget.
如果您对程序集级别信息感到满意,那么您应该查看图表流行工具 Reflector 的插件。它提供组装和类级别依赖图。
If you are OK with assembly level information then you should look at Graph add-in to a popular tool Reflector. It provides assembly & class level dependency graph.
最新的 Resharper 版本还能够创建参考图。
https://www.jetbrains.com/help/resharper/Architecture__Project_Dependency_Exploration.html#< /a>
The latest Resharper version is also capable of creating the reference diagramm.
https://www.jetbrains.com/help/resharper/Architecture__Project_Dependencies_Exploration.html#
今天早上向我建议理解(:
http://www.scitools.com/
但老实说我不能给一个适当的报告,因为它对我来说太贵了......
understand was suggested to me this morning (:
http://www.scitools.com/
but honestly i cannot give a proper report on it, since it is too expensive for me...
看看我的 .NET Reflector 的免费 DSM 插件,可从 www.tom-carter.net
下载允许对依赖关系有两种不同的视图:用于查找程序集之间的依赖关系的部署模型和用于显示类型之间的依赖关系的体系结构模型。
如果它没有直观地提供您要查找的信息,您可以将模型保存到 xml 并在数据上运行您自己的脚本。
依赖矩阵的优点在于,它比方框图和折线图更容易直观地分析依赖关系
如果您需要更多帮助,请立即联系我
[更新]该插件现在以 Visual Studio 的形式提供插件
Have a look at my free DSM plugin for .NET Reflector downloadable from www.tom-carter.net
It allows two different views on your dependencies : a deployment model to find the dependencies between assemblies and an architectural model to show dependencies between types.
If it does not provide visually the information your looking for, you can save the model to xml and run your own script on the data.
The advantage of a dependency matrix is that its much more easier to analyse dependencies visually than box and line graphs
If you need more help let me now
[Update] This plugin is now available in form of a Visual Studio Add-In