简体   繁体   English

如何获得我的 C# 项目之间的依赖关系图

[英]How do I get a diagram of the dependencies between my C# projects

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.所以我喜欢将其视为一个组件,其中包含多个项目/dll。 There is also a "common" component.还有一个“通用”组件。 All the other components depend on "common".所有其他组件都依赖于“common”。 So a compile goes like this: "nant component1.compile" will compile "common" and then compile component1 since component1 depends on "common".所以编译是这样的: "nant component1.compile"将编译“common”,然后编译component1,因为component1依赖于“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?你会怎么做?

You could have a look at NDepend : http://www.ndepend.com/你可以看看 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. Patrick Smacchia是 NDepend 的首席开发人员,他的博客位于: http : //codebetter.com/blogs/patricksmacchia/default.aspx并且撰写了很多关于组件化主题的文章,您可能会发现这些文章很有用。

If you have access to Visual Studio 2010 Ultimate , you can select Generate Dependency Graph from the Architecture menu.如果您有权访问 Visual Studio 2010 Ultimate ,则可以从“ Architecture菜单中选择“ Generate Dependency Graph ”。

There is a walkthrough on MSDN: How to: Generate Dependency Graphs for .NET Code MSDN 上有一个演练:如何:为 .NET 代码生成依赖关系图

I'd try importing it into a UML tool that could render the dependency diagram between modules for me.我会尝试将它导入一个 UML 工具,该工具可以为我呈现模块之间的依赖关系图。

There are several on the market, both commercial and open source.市场上有几个,商业的和开源的。 Get the one that gives you the most capability for your budget.获得最适合您的预算的产品。

If you are OK with assembly level information then you should look at Graph add-in to a popular tool Reflector .如果您对程序集级别的信息没有意见,那么您应该查看流行工具Reflector 的Graph插件。 It provides assembly & class level dependency graph.它提供程序集和类级别的依赖关系图。

The tool NDepend proposes a dependency graph coupled with a dependency matrix.工具NDepend提出了一个依赖关系图和一个依赖矩阵。 By default you'll get a dependency graph of .NET assemblies and it is not restricted to assemblies of only one VS solution.默认情况下,您将获得 .NET 程序集的依赖关系图,它不仅限于一个 VS 解决方案的程序集。 NDepend is integrated in VS 2017, 2015, 2013, 2012, 2010 and it can show any kind of graph on your code including: NDepend 集成在 VS 2017、2015、2013、2012、2010 中,它可以在您的代码上显示任何类型的图形,包括:

  • dependencies between assemblies程序集之间的依赖关系
  • method call graph,方法调用图,
  • dependencies of namespaces inside a VS project, VS 项目中命名空间的依赖关系,
  • dependencies of types inside a namespace,命名空间内类型的依赖关系,
  • classes inheritance graph,类继承图,
  • graph representing classes coupling between 2 components图表示 2 个组件之间的类耦合

etc...等等...

This is all explained here .这一切都在这里解释。

NDepend 代码图依赖图

NDepend also proposes a dependency structure matrix (DSM) and a way to query dependencies with C# LINQ queries . NDepend 还提出了一个依赖结构矩阵 (DSM)和一种使用 C# LINQ 查询查询依赖关系的方法。

The latest Resharper version is also capable of creating the reference diagramm.最新的 Resharper 版本也能够创建参考图表。

https://www.jetbrains.com/help/resharper/Architecture__Project_Dependencies_Exploration.html# https://www.jetbrains.com/help/resharper/Architecture__Project_Dependencies_Exploration.html#

understand was suggested to me this morning (:今天早上有人向我建议了理解(:

http://www.scitools.com/ http://www.scitools.com/

but honestly i cannot give a proper report on it, since it is too expensive for me...但老实说,我无法对此做出正确的报告,因为它对我来说太贵了......

Have a look at my free DSM plugin for .NET Reflector downloadable from www.tom-carter.net看看我的免费 DSM 插件 .NET Reflector 可从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.如果它不能直观地提供您要查找的信息,您可以将模型保存到 xml 并在数据上运行您自己的脚本。

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 [更新]此插件现在以 Visual Studio 加载项的形式提供

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

相关问题 如何在Visual C#项目之间同步版本? - How do I sync versions between Visual C# projects? 我应该如何管理/声明开源C#项目之间的依赖关系? - How should I manage/declare dependencies between open source C# projects? 正确组织C#中项目之间的依赖关系 - Right organization of dependencies between projects in C# 如何在c#中保持项目之间共享的公共代码? - How do I keep common code shared between projects in c#? 如何在我的许多 C# 项目的树中协调程序集版本信息? - How do I coordinate assembly version information in my tree of many C# projects? 如何编译使用外部依赖项而不将它们包含在库中的 C# 库? - How do I compile my C# library that uses external dependencies without them included in the library? 生成C#项目及其依赖项 - Build C# Projects and their dependencies 考虑到它们之间的依赖关系,我应该如何将我的项目发布为 NuGet 包? - How should I publish my projects as NuGet packages considering dependencies between them? 如何在C#项目中设计View逻辑 - How do I design View logic into c# projects 如何使用C#以编程方式编译项目和解决方案? - How do I programmatically compile projects and solutions in release with c#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM