简体   繁体   English

如何在Visual Studio中保存时从文本文件生成普通的旧代码?

[英]How can I generate plain old code from a text file on save with visual studio?

Many of the features in visual studio rely on editing a markup file and then saving it to auto-generate POC in C#. Visual Studio中的许多功能都依赖于编辑标记文件,然后将其保存以在C#中自动生成POC。

For example, editing and saving a database *.dbml file will generate a *.designer.cs file that you can call from POC. 例如,编辑和保存数据库*.dbml文件将生成一个*.designer.cs文件,您可以从POC调用*.designer.cs文件。 It's also seen with ASP.Net *.aspx files, generating an *.aspx.designer.cs upon save so that the controls can be accessed in the codebehind files. 还可以在ASP.Net *.aspx文件中看到该文件, *.aspx.designer.cs在保存时生成*.aspx.designer.cs ,以便可以在代码隐藏文件中访问控件。

Is it possible to leverage this functionality in my own software so that I can define my own text files in CSV, JSON, or XML format and specify rules for generating code upon saving the file? 是否可以在自己的软件中利用此功能,以便我可以以CSV,JSON或XML格式定义自己的文本文件,并指定保存文件时生成代码的规则?

用于生成代码的Visual Studio功能称为T4模板化

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

相关问题 如何在Visual Studio中创建加载项以从设置文件生成javascript,CSS和其他代码 - How can I create an addin in Visual Studio to generate javascript, CSS and other code from a settings file 如何从Visual Studio 2012中编写的C#代码生成Visio 2010中的UML图? - How can I generate UML diagrams from C# code written in Visual Studio 2012 into Visio 2010? 如何将Visual Studio中的所有源代码导出到文本文件中? - How to export all the source code from Visual Studio into a text file? 如何在Visual Studio中为getter和setter以及构造函数自动生成标准代码? - How can I auto generate standard code for getters and setters and constructors in Visual Studio? 如何使用Visual Studio 2015从代码生成UML图? - How do I generate UML diagram from code using Visual Studio 2015? 如何将“CodeLens 引用”窗口的内容保存到 Visual Studio 2015 中的文件中? - How can I save the contents of the “CodeLens References” window to a file in Visual Studio 2015? 如何从Visual Studio 2013中的C#解决方案生成序列图? - How can I generate Sequence Diagram from a C# solution in Visual Studio 2013? 如何在 Visual Studio for Mac 2022 上生成身份页面? - How can I generate identity pages on Visual Studio for Mac 2022? 从Visual Studio扩展生成代码 - Generate Code from a Visual Studio Extension Visual Studio从UML图生成代码? - Visual Studio generate code from UML diagrams?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM