[英]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.