Code stubbing with Visual Studio 2010 UML modeling

前提是你 提交于 2019-11-27 15:23:13

问题


Currently I'm exploring my way through all the new features added to the Visual Studio 2010 Beta 1 IDE and I found a feature that will hopefully be of great help to me. The UML Modeling tool in the Architecture Edition. I wanted to create a new test project, nothing special. I started out with creating just a standard UML Logical Class Diagram. Then after I had finished I wanted to export my diagram to C# code with class stubs but I couldn't figure out how to do it. So naturally I consulted MSDN, but I couldn't find any reference to the top down approach of design and sort of gave up on it. Then I happened to be on the Channel 9 website and I watch the Top down architecture video and they alluded to the possibility of Visual Studio 2010 being able to accomplish this task.

So I guess my question is, can Visual Studio 2010 take a Logical Class Diagram and generate code stubs from it?

I'm currently using Visual Studio 2010 Beta 1 Team System on Windows 7 (if that helps any).

Thank you


回答1:


Try the following topics from the RC docs:

  • How to: Generate Files from a UML Model

    From a UML model, you can generate program code, schemas, documents, resources, and other artifacts of any kind. One convenient method of generating text files from a UML model is to use text templates. These let you embed program code inside the text that you want to generate.

  • Customizing Your Model with Profiles and Stereotypes

    You can adapt the standard UML model elements, such as classes and components, to customize them for specific purposes. You can apply a stereotype to a model element that can change the element's list of properties. Stereotypes are defined within collections called profiles.

You might also check out this blog post by Tim Fischer helps: "How To: Generate Code from Team System UML Diagrams in VS 2010 Team System Beta 2 (Update 4)"

Here is the first code-snippet about how to generate code from UML-Diagrams using T4 Text-Templates.
(source: msdn.com)

Here's another blog post by Oleg Sych: UML Modeling and Code Generation in Visual Studio 2010

Assuming that reader is already familiar with UML, it focuses on custom UML profiles - an extensibility mechanism that can be used to tailor UML models to a particular problem domain. Readers will see an example of such a profile, which extends UML Class Diagrams for database modeling. Finally, the article shows how code can be generated from UML models using T4 text templates.

I've posted more links on my profile for more info.




回答2:


You answer is Visualization and Modeling Feature Pack. This pack gives your what ever you need regarding code generation from Visual Studio 2010 modeling facilities and more.




回答3:


According to MSFT, the answer is no. Or at least, it is not built in by default though may be delivered by extension. See here



来源:https://stackoverflow.com/questions/1269414/code-stubbing-with-visual-studio-2010-uml-modeling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!