t4

TextTransform.exe seems to only accept an older version of C#

旧城冷巷雨未停 提交于 2019-12-22 13:53:15
问题 When I expand T4 templates inside Visual Studio, I can use the full C# 3.0 syntax, including LINQ expressions, etc. When I expand it outside Visual Studio using TextTransform.exe it complains about LINQ expressions and other new features of C# 3.0. Is there a newer version of TextTransform.exe? The one I'm running is in: C:\Program Files\Common Files\Microsoft Shared\TextTemplating\1.2\TextTransform.exe 回答1: 1.2 is the version of TextTransform that shipped with Visual Studio 2008. However, it

customizing some auto generated codes with T4

吃可爱长大的小学妹 提交于 2019-12-22 13:49:19
问题 I Used "EF 4.x DbContext Fluent Genarator" to generate my poco classes , mapping files and also Context file, in EF Code first.(in fact "EF 4.x DbContext Fluent Genarator" uses 3 T4 files) now i want apply some changes on auto generated codes: change namespace of some classes. Mark some fields of some classes as [NonSerializable] change body of Some auto generated custom methods on pocos that i added to T4 template. how can i do these works with continuing using T4 files? 回答1: for #3. this

T4 with languages other than C# and VB

喜欢而已 提交于 2019-12-22 12:23:33
问题 Is it posible to write T4 templates in other .NET languages? In particular I'm interested in F# and IronPython. 回答1: The doc stipulates that only VB and C# are supported: T4 Template Directive, see the language attribute. 回答2: I was complaining about this on twitter some time ago. It seems reasonable - afterall, T4 is just using CodeDOM provider! Anyway, Michael Hutchinson (from Mono team) suggested using the implementation in Mono, which should be extensible. I didn't look into that further,

T4 Output to String

醉酒当歌 提交于 2019-12-22 11:29:08
问题 I am new to T4, I want to generate CRUD Stored Procedures, Data access layer, output to string, I am trying to create kind of webservice api to be useful to other programmers also, just input the data, and download zip file. I have searched a lot but could not find a way to generate output to string, is it possible, any articles, links, a bit of code if possible would be helpful. Yes, we can also use StringBuilder, but The question is "T4 Output to String" please all type of answers are

Custom Output File Path For T4 Template

这一生的挚爱 提交于 2019-12-22 11:12:18
问题 I am finding it really difficult to use t4 templates with a non-standard directory structure. I am using links inside my csproj file, which seems to be at the root of the problem. I have it working, however, VS automatically makes a change which breaks things. I've have the following directory structure: /source + MyLib.cs /generate /MyLib + MyLib.tt + MyLib.A.t4 // included by MyLib.tt + MyLib.B.t4 // included by MyLib.tt + MyLib.C.t4 // included by MyLib.tt /build_examples /vs + MyLib

In T4 code generation, how can I grab a type from a referenced assembly?

☆樱花仙子☆ 提交于 2019-12-22 08:06:08
问题 Since T4 runs outside of the context of a project, I don't have access to the current assembly or other assemblies. How can I register access to a referenced assembly, then grab a type from it? 回答1: I am guessing you want to access an assembly your building in your project. What I've done in the sample code below is adding a project to my solution called TestLib which I build to the folder .\T4Libs in the solution directory. TestLib has a class called MyHelper which holds a magic number. FYI

Visual Studio serialization error when T4 uses DTE to open generated file

旧时模样 提交于 2019-12-22 07:45:30
问题 We have a C# T4 file named GenerateProxies.tt which calls several command-line codegen utilities. Using the System.Diagnostics Process class, we redirect the standard output to the T4 output text file (GenerateProxies.txt) so that we can review the command-line output for errors. I added the following simple code to the end of the T4 so that Visual Studio will open the generated text file as the last step in the process (the workingDirectory variable is declared and populated earlier in the

Visual Studio 2012 T4 templates generating XML gives error

半腔热情 提交于 2019-12-22 05:06:59
问题 I'm using visual studio 2012 to generate XML from a T4 template. The top of the template looks like <#@ template language="VBv4" hostspecific="True" debug="True" #> <#@ output extension="wmef" #> <?xml version="1.0" encoding="utf-8" standalone="yes"?> The T4 template correctly generates the XML. This is no problem. However visual studio is getting confused and it additionally tries to process the template itself as XML and reports build errors saying the XML is ill formed which of course it

Run T4 text template programmatically

血红的双手。 提交于 2019-12-22 04:55:10
问题 Is there a way to programmatically run T4 text templates from code? I'm making a custom domain specific language and I would like the related text templates to run every time the user saves. Currently, this is what I do in the DSL model: protected override void OnDocumentSaved(EventArgs e) { IVsCommandWindow commandWindow = (IVsCommandWindow)this.ServiceProvider.GetService(typeof(IVsCommandWindow)); if (commandWindow != null) { commandWindow.ExecuteCommand("TextTransformation

Custom Scaffolding Templates in Visual Studio 2013

ぐ巨炮叔叔 提交于 2019-12-22 04:28:28
问题 Previously, with Visual Studio 2012, I was able to bring the CodeTemplates folder up to my project directory and then modify the existing T4 templates or add entirely new T4 templates to meet my particular code generation requirements. It seems that the previously described approach will no longer work with the new scaffolding engine introduced with Visual Studio 2013. In particular, it seems that the new scaffolding logic resides here: C:\Program Files (x86)\Microsoft Visual Studio 12.0