visual-studio 在 VS 2010 中将代码逆向工程为 UML 类图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2281419/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:33:41  来源:igfitidea点击:

Reverse Engineering Code into a UML Class Diagram in VS 2010

visual-studio-2010visual-studiouml

提问by Emmanuel

Reverse engineering source code into a VS 2010 UML class model?

将源代码逆向工程为 VS 2010 UML 类模型?

I have a bad feeling that this is not supported in VS 2010 (I'm using the RC from Feb 2010). I've tried dragging classes from the "Architecture Explorer" to the "UML Model Explorer" but that doesn't work (won't let me drop on the UML Model).

我有一种不好的感觉,这在 VS 2010 中不受支持(我从 2010 年 2 月开始使用 RC)。我已经尝试将类从“架构资源管理器”拖到“UML 模型资源管理器”,但这不起作用(不会让我放弃 UML 模型)。

I've tried generating an old style class diagram (*.cd) and dragging the resulting diagram object to a blank UML Class diagram. No luck.

我已经尝试生成旧样式的类图 (*.cd) 并将生成的图对象拖到空白的 UML 类图中。没有运气。

Binging does show up anything other than some MS marketing blurbs about "top-down modelling" and, as expected, forward engineering code from the UML model. This makes me suspect that the VS team didn't tackle reverse engineering code into models.

除了一些关于“自顶向下建模”的 MS 营销宣传外,Binging 确实显示了任何其他内容,正如预期的那样,来自 UML 模型的转发工程代码。这让我怀疑 VS 团队没有将逆向工程代码处理到模型中。

I was able to generate UML Activity diagrams from code. Nice. But other diagrams (and resulting generation of VS UML Model Repository Objects) is elusive.

我能够从代码生成 UML 活动图。好的。但是其他图表(以及由此产生的 VS UML 模型存储库对象)是难以捉摸的。

If my suspicions are correct, this is a big disappointment. A lot of my work - and I would venture to guess that this is the case for most developers - is adding features to existing software and not doing green-field work. Without the ability to reverse engineer existing code into the VS UML Model repository or import models from other tools, I don't see how adoption of VS UML modelling will get very far. I'll just have to stick with my current favorite tool - Enterprise Architect by Sparks Systems.

如果我的怀疑是正确的,这是一个很大的失望。我的很多工作——我敢于猜测大多数开发人员都是这种情况——正在为现有软件添加功能,而不是进行全新的工作。如果无法将现有代码逆向工程到 VS UML 模型存储库或从其他工具导入模型,我看不出 VS UML 建模的采用会走多远。我只需要坚持使用我目前最喜欢的工具 - Sparks Systems 的 Enterprise Architect

I think this missing feature is a major shortcoming. What do others think?

我认为这个缺失的功能是一个主要的缺点。其他人怎么看?

What are others planning to do? Continue using their current, favorite UML modelling solution and ignoring VS 2010's offering?

其他人打算做什么?继续使用他们当前最喜欢的 UML 建模解决方案并忽略 VS 2010 的产品?

采纳答案by Esther Fan - MSFT

This question was answered on the VS 2010 Architecture & Modelingforum.

这个问题在VS 2010 Architecture & Modeling论坛上得到了回答。

Basically, this functionality will appear in a power tool release around VS 2010 RTM. I encourage you to post in the forum if you have more questions.

基本上,此功能将出现在 VS 2010 RTM 周围的电动工具版本中。如果您有更多问题,我鼓励您在论坛中发帖。

UPDATE

更新

You can now do this by getting the Visual Studio 2010 Feature Pack 2.

您现在可以通过获取Visual Studio 2010 Feature Pack 2来做到这一点。

回答by Esther Fan - MSFT

You can now do this by getting the Visual Studio 2010 Feature Pack 2.

您现在可以通过获取Visual Studio 2010 Feature Pack 2来做到这一点。

回答by Patrick from NDepend team

Have you tried NDepend tool for .NET developers? It comes with both a dependency graph and a dependency matrix and integrates in VS, and it is objectively 100x faster than VS2010at generating reverse-engineered code graph.

您是否为 .NET 开发人员尝试过 NDepend 工具?它带有依赖图和依赖矩阵,并集成在 VS 中,客观上比 VS2010生成逆向工程代码图快 100 倍

You can download and use the free trial editionfor a while and make your own opinion.

您可以下载并使用免费试用版一段时间并发表自己的意见。

More on NDepend Dependency Graphenter image description here

更多关于 NDepend 依赖图在此处输入图片说明

More on NDepend Dependency Matrix: enter image description here

更多关于 NDepend 依赖矩阵在此处输入图片说明

Disclaimer: I am part of the tool team

免责声明:我是工具团队的一员

回答by CularBytes

For creating UML class diagrams in Visual Studio 2013 Ultimate:

在 Visual Studio 2013 Ultimate 中创建 UML 类图:

In Visual Studio 2013 Ultimate you can do this without any external tools.

在 Visual Studio 2013 Ultimate 中,您无需任何外部工具即可完成此操作。

  • In the menu, click on Architecture, New DiagramSelect UML Class Diagram
  • This will ask you to create a new Modeling Projectof you don't have one already.
  • 在菜单中,点击Architecture, New Diagram选择UML Class Diagram
  • 这将要求您创建一个您还没有的新建模项目

You will have a empty UMLClassDiagram.classdiagram.

您将拥有一个空的 UMLClassDiagram.classdiagram。

  • Again, go to Architecture, Windows, Architecture Explorer.
  • A window will pop up with your namespaces, Choose Class View.
  • Then a list of sub-namespaces will appear, if any. Choose one, select the classes and drag them to the empty UMLClassDiagram1.classdiagram window.
  • 再次转到ArchitectureWindowsArchitecture Explorer
  • 将弹出一个窗口,其中包含您的命名空间,选择类视图
  • 然后将出现子命名空间列表(如果有)。选择一个,选择类并将它们拖到空的 UMLClassDiagram1.classdiagram 窗口中。

Reference: Create UML Class Diagrams from Code

参考:从代码创建 UML 类图