简体   繁体   English

在 Visual Studio 2015 UML 类图中生成代码不起作用

[英]Generate Code in Visual Studio 2015 UML Class diagram is not working

I made a basic UML Class diagram of a class with two fields, a method, and a subclass with one field but when I hit generate code nothing happens.我制作了一个具有两个字段、一个方法和一个具有一个字段的子类的类的基本 UML 类图,但是当我点击生成代码时,什么也没有发生。 The console says it worked with no errors but when I look at the log it says "(Class): no file generated because the 'AppliesToElement' method of the template 'ClassTemplate.t4' evaluated to false."控制台说它没有错误,但是当我查看日志时,它说“(类):没有生成文件,因为模板 'ClassTemplate.t4' 的 'AppliesToElement' 方法评估为 false。” on both of my classes.在我的两节课上。 What am I missing?我错过了什么?

I fixed this by using the UML Model Explorer.我使用 UML 模型资源管理器修复了这个问题。

I went to the UML Model Explorer, then right-clickd the project, then clicked generate code which popped up this message:我转到 UML 模型资源管理器,然后右键单击该项目,然后单击弹出此消息的生成代码:
在此处输入图片说明
which told me the component cache was out of date so I restarted Visual Studio.这告诉我组件缓存已过期,因此我重新启动了 Visual Studio。 After that I tried to generate the code again through the UML Model Explorer and it Worked.之后,我尝试通过 UML 模型资源管理器再次生成代码,并且成功了。

Unfortunately, the ability to generate UML class and sequence diagrams from code, and turn UML into code, was removed in VS2015.不幸的是,从代码生成 UML 类和序列图并将 UML 转换为代码的能力,在 VS2015 中被删除了。 This is because of the new Roslyn compiler - Microsoft would have needed to rewrite these features for the new compiler but stated they didn't want to spread their resources too thinly.这是因为新的 Roslyn 编译器——微软需要为新的编译器重写这些功能,但表示他们不想过于分散他们的资源。

Source: https://msdn.microsoft.com/en-us/library/dd409436.aspx来源: https : //msdn.microsoft.com/en-us/library/dd409436.aspx

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM