t4

Domain Specific Language resources

I was just listening to some older .Net Rocks! episodes, and I found #329 on DSLs to be interesting. My problem is that I can't find any good online resources for people trying to learn this technology. I get the basics of the creating new designers, but the MS docs on the T4 engine used by the DSL tools and then how to integrate the tem...

TypeLoadException on System.Xml.Linq.XDocument when running T4 template on build server

I'm having a problem running a T4 template using TextTransform.exe on my build server. On my dev machine the template works perfectly. The error message is as follows. error : Running transformation: System.TypeLoadException: Could not instantiate type System.Xml.Linq.XDocument The build server has the windows 2008 SDK on it, my ma...

class with valueTypes fields and boxing

I'm experimenting with generics and I'm trying to create structure similar to Dataset class. I have following code public struct Column<T> { T value; T originalValue; public bool HasChanges { get { return !value.Equals(originalValue); } } public void AcceptChanges() { originalValue = value; ...

T4 Template directory missing on build server

I've just set up a new build server with the Windows 2008 .NET 3.5 SDK, and for some reason it hasn't installed c:\Program Files\Common Files\Microsoft Shared\TextTemplating so I can't run t4 templates on it. I had a look at the install options in add/remove programs and every single option is checked. Any ideas why it is missing? Any ...

How do I use templates inside a T4 ClassBlock method?

I'm starting to investigate T4 for Code Generation. I get that you have a basic template in which you can embed little chunks of c#/vb which can perform clever stuff... <#@ template language="VB" debug="True" hostspecific="True" #> <#@ output extension=".vb" debug="True" hostspecific="True" #> Imports System <#For Each Table as String ...

Is there any good resources for T4 (Text Templating framework from Microsoft)?

Anything would be good. Exemples, best practices, samples, etc. ...

What is causing this T4 Error?

I'm trying to use a class within a T4 template in VS2008. Here is a simplified version of what I'm doing... <#@ template language="VB" debug="True" hostspecific="True" #> <#@ output extension=".vb" debug="True" hostspecific="True" #> <#@ assembly name="System.Data" #> <#@ assembly name="System.Windows.Forms.dll" #> <#@ assembly name="S...

Does anyone have any T4 example Templates that can be used to generate a Webservice?

Does anyone have any T4 example Templates (or links to same) that can be used to generate a Webservice? I'm thinking of the fact that I guess the Webservice is not just the Vb or Cs field but also requires an appropriate asmx file. I'm really not sure how to achieve this ...

How can I use Linq in a T4 template?

I am using T4 to generate some screens and middle-tier code for a project, and would like to use Linq to simplify some of my template code. However, when I try to use Linq, the template reports a syntax error. ...

How to add a dependency to a arbitrary file to a T4 template?

I have a T4 template that generates classes from an xml file. How can I add a dependency between the xml file and the template file so that when the xml file is modified the template is rerun automatically without choosing "Run custom tool" from the context menu? ...

T4 not working in Visual Studio 2008

Hi, I have to machines setup to run Visual Studio 2008 (SP1) & NET Framework 3.5 (SP1). If I create a .tt file in a console appliaction on machine #1 it automatically creates the sub .cs file for me, however if I do the exact same on machine #2 then no sub .cs file is created. I have tried toggeling the "Show All Files" option, restart...

T4 Templates - suitable for generating C++ code?

Are there any issues which might make MS's T4 Template code-generation system unsuitable for generating C++ code? ...

Getting the location of a .tt file in T4.

Using T4 I want to generate some code based on examining what files are in a directory relative to the template file being executed. Is there a way in c# to identify what the path of the current template file is? ...

Code generator (.net)

Do you have any experience with T4 and T4 Editor? Can you compare it to CodeSmith or MyGeneration? What code generators do you use? What do you recommend? I want to use it for generatig of SPs. Is there anything else you find code generation useful? ...

How to use T4 and Visual Studio to Extend a Partial Class

I wanted to use T4 to generate properties for a partial class. I'm running into a configuration problem where my .TT file is in the same project as the class file I want to extend. So if I have to include the assembly in the .TT file it get's locked. I tried to do a command line in the pre-build but the problem there is that VS always wa...

How to get t4 files to build in visual studio?

When I build my c# solution the .tt files will not create the .cs file outputs. But if I right click the .tt files one at a time in solution explorer and select "Run Custom Tool" the .cs is generated, so the build tool setting is correct. What do I do to get the overall solution build to force the custom tool to run on the .tt files? ...

What's the difference between Visual Studio 2008 Standard and Professional?

What does Pro have that's not in Standard (or vice-versa)? I need Visual Studio for personal use but I can't use the Express editions because I need T4. ...

how to save the result of a t4 template on a different folder

When i try to specify an absolute path for the generated files using someTemplate.RenderToFile("c:\\tmp\\filename.ext"); I'm getting the following error Error 263 Running transformation: System.Runtime.InteropServices.COMException (0x80004005): There is already a file of the same name in this folder. even though the folder is empt...

how can I get intellisense in a T4 template?

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) Isn't there anyway to say to Visual Studio to consider those .tt files as .cs files and thus get the correct intellisense help...

Can I redistribute the Microsoft T4 Engine with my product?

I'm generating code dynamically, currently using String.Format and embedding placeholders - but reformatting the C# code for use as a template is a pain, and I think using a T4 template would be better. However, the code generation will be happening on a running system, so I need to know that I can safely and legally redistribute the Mi...