visual-studio 如何在 T4 模板中获得智能感知?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/420766/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how can I get intellisense in a T4 template?
提问by Vitor Silva
When trying out these tutorials (T4 Tutorial: Creating reusable code generation templates) I noticed that although I was using plain c# I didn't get any intellisense, probably because of the file extension (.tt)
在尝试这些教程(T4 教程:创建可重用代码生成模板)时,我注意到虽然我使用的是普通的 c# 我没有得到任何智能感知,可能是因为文件扩展名 (.tt)
Isn't there anyway to say to Visual Studio to consider those .tt files as .cs files and thus get the correct intellisense help?
是不是要告诉 Visual Studio 将这些 .tt 文件视为 .cs 文件,从而获得正确的智能感知帮助?
采纳答案by Oleg Sych
You can purchase the professional version of T4 Editor. It works very well in standalone .tt files, but unfortunately, due to the differences in how the pro version of T4 Editor and T4 itself compile the templates, you will get false errors reported for this tutorial, which relies on T4 Toolbox.
您可以购买专业版的 T4 Editor。它在独立的 .tt 文件中运行良好,但不幸的是,由于专业版 T4 Editor 和 T4 本身编译模板的方式不同,您将收到本教程报告的错误错误,该教程依赖于T4 Toolbox。
回答by Dan
Resharpercan do this, with the help of the ForTea Pluginthat adds support for editing T4 (.tt) files.
回答by Mohammed Vaseem Siddiqui
http://visualstudiogallery.msdn.microsoft.com/en-us/60297607-5fd4-4da4-97e1-3715e90c1a23
http://visualstudiogallery.msdn.microsoft.com/en-us/60297607-5fd4-4da4-97e1-3715e90c1a23
Here you go with a plugin...
给你一个插件...
Vaseem.
瓦西姆。
EDIT
编辑
Also available for Visual Studio 2012: Tangible T4 Editor 2.3.0
Also available for Visual Studio 2015: Tangible T4 Editor 2.3.0
Also available for Visual Studio 2017: Tangible T4 Editor 2.4.0
也适用于 Visual Studio 2012:Tangible T4 Editor 2.3.0
也适用于 Visual Studio 2015:Tangible T4 Editor 2.3.0
也适用于 Visual Studio 2017:Tangible T4 Editor 2.4.0
回答by Mohammed Vaseem Siddiqui
You can just download tangible's T4 Editor at t4editor.tangible-engineering.com it has Intelli-Sense for most important namespaces also in the FREE EDITION.
您只需在 t4editor.tangible-engineering.com 上下载 tangible 的 T4 编辑器,它在免费版中也为最重要的命名空间提供智能感知。
回答by rohancragg
As Scott Hanselman also points out, the intellisense you might be expecting from some of the videos and articles on T4 are not built in to VS2008, you need the T4 Editor from Clarius, but they do have a community edition with some minimalist featuresto get you started.
正如Scott Hanselman 还指出的那样,您可能对 T4 的某些视频和文章所期望的智能感知不是 VS2008 内置的,您需要来自 Clarius 的 T4 编辑器,但他们确实有一个带有一些极简功能的社区版才能获得你开始了。
回答by Maxter
For some reasons, I couldn't install the extensions mentionned in the other answers. My solution was to use Visual Studio Code to edit the .tt files. VS Code has some good t4 synthax highlighter plugins.
由于某些原因,我无法安装其他答案中提到的扩展。我的解决方案是使用 Visual Studio Code 来编辑 .tt 文件。VS Code 有一些不错的 t4 synthax 荧光笔插件。

