C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\11.0

Generating
Files with the TextTransform Utility

\Program Files\Common Files\Microsoft
Shared\TextTemplating\11.0


C:\Program Files (x86)\Common Files\microsoft
shared\TextTemplating\11.0

T4
(Text Template Transformation Toolkit) Code Generation - Best Kept Visual
Studio Secret - Scott Hanselman


T4 (Text Template Transformation Toolkit) Code Generation
- Best Kept Visual Studio Secret

十月 14, ‘08 Comments
[30]
Posted in ASP.NET | Programming | Tools

Sponsored By

Rob
beat me to it
. Blogging about T4
(the Text
Template Transformation Toolkit
) had been on my list
literally for a year. He and I were singing its praises last night.
Hopefully I can add something small to the conversation.

What‘s the story? Well, T4 is a code generator built right
into Visual Studio. To be clear, you HAVE THIS NOW on your system…go
play.
Now‘s the time to introduce code generation to your
company. If you‘re doing something twice or more, manually, in your
company, generate it.

However, it‘s not deep-deep built in, because there‘s no item
templates in File | New Item and there‘s no intellisense or syntax
highlighting.

You don‘t need this, but if you want really get the most out of T4,
first, head over to Clarius Consulting and get their "T4
Editor Community Edition
." That‘ll get you some basic coloring. They
have a pay version that gets you more if you want.

Now, go into Visual Studio and make a Console App (or any app) and
add a Text File, but name it something with a .tt
extension. You‘ll get a warning since it‘s a generator, that
someone could generate evil. Click OK if you are cool with potential
evil. ;)

Now, look in Solution Explorer at the .tt
file. If you‘re using C#, you‘ll have a sub .cs file, or if you‘re using
VB, a sub .vb file. That‘s the file that will hold the result of the
generation. This is the same visual metaphor used to the express the
template/generated file relationship with .designer files you‘ve seen
elsewhere in Visual Studio.

If you look in the Properties for the .tt file, you‘ll see it‘s using
a CustomTool listed as the "TextTemplatingFileGenerator." This custom
tool extensibility point is how things like XSD and WSDL code generators
hook in to generate their artifacts.

T4 can generate any kind of text file, not just code. Whatever you
like. You can use it in your projects, as above, or you can call
T4 from the command-line
.

Aside from Kzu and the folks at Clarius, Rob
notes that Oleg
Sych
has a great
collection of T4 resources
. He‘s got some great Tutorials:

Here‘s some
of the links from Oleg‘s blog
.

Oleg also has a CodePlex project called T4
Toolbox
that is a library of T4 templates that get added to File |
New Item.

Also, check out Damien
Guard‘s T4 templates that are a wholesale replacement of code that LINQ
to SQL generates
. Here‘s an example, where I use Damien‘s T4
templates against the sample Chinook
Database
.

Notice that I‘ve named the .tt file the same as the .dbml, so
Damian‘s code can find it. I also continue to let original LINQ to SQL
generate it‘s .designer.cs file, but make that file‘s Build Action
"None" so it‘s not ever compiled. That effectively puts Damian‘s code in
charge.

Here‘s a screenshot showing a bit of Damian‘s T4 template using the
syntax highlighting from the Clairus T4 Visual Studio free download. If
I‘d pay them, I‘d get intellisense and syntax highlighting inside
the code blocks also. It looks like a lot like ASP.NET Web Forms,
or Velocity, or any templating language really. The code blocks are
where your logic is and outside the codeblocks is the template for
whatever you want to generate. Notice how Damien gets input and sets
output. You have full control, you can read files off the file system,
from with your project, etc. He sets the output extension also. I like
to use .g.cs or .g.vb, myself. In this example his generated file is
Chinook.generated.cs.

I particularly like Damien‘s example because he‘s swapping out parts
of LINQ to SQL that he didn‘t like (the generated code) while keeping
the part he did (the general mode, the designer, the dbml file.) If you
don‘t like something, fix it.

Plus, it all works in Visual Studio without installing
anything
.

If you‘re doing Code Gen, or thinking about it, check out T4
as it‘s a great place to start. Also, search my blog for "Code
Generation" as I was livign and breathing it with CodeSmith
for the many years I worked at Corillian.
Have fun!

C:\Program Files (x86)\Common Files\microsoft
shared\TextTemplating\11.0

时间: 2024-11-06 03:30:24

C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\11.0的相关文章

删除C:\Program Files (x86)\Common Files\baidu 等误装软件且正常模式删不掉的文件夹

---------方法一-------- C:\Program Files\Common Files\Baidu\BaiduProtect\1.1.0.26打开以上路径找到反注册程序uninst.exe运行即可. 枫9777 补充: 打开任务管理器 ,进程里面找到百度安全组件程序对应的进程,右键,打开文件位置,然后就找到百度安全组件程序所在的位置了,里面有个uninst.exe,双击就卸载了 -----------方法二---------- 删除不了的软件.文件或文件夹的解决方法: 1.开机按F

warning MSB3162: 所选的“Microsoft Report Viewer 2012 Runtime”项需要“Microsoft.SqlServer.SQLSysClrTypes.11.0”。在“系统必备”对话框中选择缺少的系统必备组件,或者为缺少的系统必备组件创建引导程序包。

warning MSB3162: 所选的"Microsoft Report Viewer 2012 Runtime"项需要"Microsoft.SqlServer.SQLSysClrTypes.11.0".在"系统必备"对话框中选择缺少的系统必备组件,或者为缺少的系统必备组件创建引导程序包. 发布ReportViewer程序遇到这个问题. 到处查了下,发现解决方法是这样的. 1)打开这个路径下的xml文件: C:\Program Files (x

未能加载文件或程序集 Microsoft.ReportViewer.Common, Version=11.0.0.0

WinForm客户端软件开发时,使用rdlc做报表,并且使用ReportViewer呈现报表时,开发者的机器运行正常.但是部署到第三方机器上运行时报错.大致有以下几种错误: (1)未能加载文件或程序集"Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"或它的某一个依赖项.系统找不到指定的文件.文件名:"Microsoft.Repor

python 安装最优传输模块POT出现问题:Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)

解决方案: 安装visual studio 2017,选择支持Python, 安装完成后配置路径: Add this to your PATH environment variables: C:\Program Files (x86)\Windows Kits\8.0\bin\x86 Copy these files: rc.exe rcdll.dll From C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64 To C:\P

这个问题是最近才发生的还是安装完VS 2019之后经常这样呢? 我们可以尝试以下的方法来troubleshoot下: 删除文件夹%LocalAppData%\Microsoft\VisualStudio\16.0_xxxx,然后打开VS 2019进行测试 打开CMD,进入VS 2019的安装路径,一般是C:\Program Files (x86)\Microsoft Visual Studio

这个问题是最近才发生的还是安装完VS 2019之后经常这样呢? 我们可以尝试以下的方法来troubleshoot下: 删除文件夹%LocalAppData%\Microsoft\VisualStudio\16.0_xxxx,然后打开VS 2019进行测试 打开CMD,进入VS 2019的安装路径,一般是C:\Program Files (x86)\Microsoft Visual Studio\2019\version name\Common7\IDE,运行命令devenv /safemode以

error MSB4019: 未找到导入的项目“C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets”

error MSB4019: 未找到导入的项目“C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets” This is very easy to do. Open your build definition and go to the "Process" page. Then under the "3. Advan

Eclipse打开弹出Faied to load the JNI shared library "C:\Program Files(x86)\java\jdk1.6.0_21\bin\..\jre\bin\client“的解决方法

今天下载了一个整合eclipse的安卓ADT,打开弹窗显示”C:\Program Files(x86)\java\jdk1.6.0_21\bin\..\jre\bin\client“ 这个路径很奇怪,于是网上查找了一下资料. 出现Faied to load the JNI shared library这类错误,一般有两种情况: 1,jdk的环境配置有问题 2,jdk与Eclispe的版本不一致(32位/64位) cmd中输入”java -version“能出现java版本信息说明配置是没有问题的

vs打开项目出错:未找到导入的项目“C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.props”的解决办法

有时候由于CUDA升级或者下载的源码原创建项目的CUDA版本与自己的不同,在打开项目的时候发现加载不上,提示:未找到导入的项目“C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.props” 解决办法: 找到项目中的.vcxproj文件,用记事本或别的打开,找到以下内容 <Import Project="$(VCTargetsPath)\BuildCustomizations\CUD

VS2008编译错误:error C2065: &#39;PMIB_TCPSTATS&#39; : undeclared identifier c:\program files (x86)\microsoft sdks\windows\v7.0a\include\iphlpapi.h 411

安装了VS2008编译之前的程序,结果出现了编译错误,以为是VS2008的Sp1补丁没装好,重装补丁后还是不行,编译错误如下: 双击错误会定位在iphlpapi.h中, 一个可行的解决办法是:把iphlpapi.h文件的line386---line421 都注释掉了: 然后再尝试编译,编译成功,运行也没有问题. 看起来,这几行代码不会影响程序运行. VS2008编译错误:error C2065: 'PMIB_TCPSTATS' : undeclared identifier c:\program