t4

T4: Is it possible to use a script to fill in a template, while still providing sections via the script?

I have a template that generates a class and a complementary interface to go with it from a script like so: <#@ template language="C#v3.5" hostspecific="True" debug="True" #> <#@ output extension="cs" #> <#@ include file="T4Toolbox.tt" #> <#@ include file="../BusinessObjectTemplate.tt" #> <# BusinessObjectTemplate template = new Busines...

Ascertaining Project Directory from T4 Templates

I am using T4 templates in Visual Studio for code generation, and am trying to reference a local .xml file from the template code so I can parse it for metadata about the application's data model. When the template code (which runs at compile time or when you run "Execute Custom Tool" on the template) tries to obtain the current path th...

T4 Fax encoder in C#

How to implement tiff file to T4 fax data encoding using c# ? ...

How can I get Asp.net MVC add view dialog out of Views folder?

Since I followed this article to implement a theme engine in Asp.net MVC website. But by doing this I can't have "Add View" dialog by right click on ~/Themes/ folder. By default "Add View" dialog can only show up when I click ~/Views/ folder. Can I have any chance to set it show up for ~/Themes/ Folder? Edit: My Teammate want to change...

Why does SubSonic's ActiveRecord T4 template generate ActiveRecord1.cs and not ActiveRecord.cs?

I've used SubSonic's ActiveRecord T4 templates in a couple of projects. Today I added the same templates from one of these projects (without the generated .cs source files) to a new project. For some reason when I run the T4 template code generator, instead of generating: ActiveRecord.cs, Context.cs, StoredProcedures.cs and Structs.cs...

read web.config from another assembly using t4

Does anyone have a good example or helper class that would allow me to read the connection string in a web application from a T4 template residing in ANOTHER assembly referenced by the web application. I am generating some code from the database that it references and i would appresiate some help on how to get the connection string for t...

T4 templates don't work for me in my Visual studio 2008 solution

I download the latest version of Subsonic(3.0.0.3) but when I add the T4 templates in my solution in Visual studio 2008 SP1, the auto-generation don't work. If I right click on the template files also the "Run custom tools" is not present. What I have to do to make visual studio able to generate code from T4 templates? ...

Is there any way to control where the output file of a T4 is generated to?

I would like to generate C# code for silverlight but I dont have access to some dll's that would make my T4 code more powerful. Is there anyway to have my T4 template in a C# Class Library and have it generate a file in the Silverlight Class Library? ...

Generating F# code

T4 is the "official" code generation engine for C#/VB.NET. But F# doesn't support it (this is from April, but I couldn't find any newer mentions). So what is a good way to generate F# code? EDIT: I want to implement 2-3 finger trees in F#. I already have implemented them in C#, so this should be a nice comparison. The "digits" and node...

Recursive block T4 template

Hi Everybody, I have a funtion named IterateThroughChildren() and I want to write the code to emit the code from inside of that function. Normally the code block is included inside <# #> and custom functions are included inside <#+ #>, we emit our code inside <#= #> block. What if I want to recursively execute the above mentioned funct...

Is there any way to have functions in basic T4 templates?

By basic T4 template, I mean not using T4 Toolkit or any of the add-ins. My T4 is getting a little complicated, but I'd like to keep in self-contained for now. Is there a way have functions in your T4 template, without referencing external assemblies? ...

Repository pattern: Dynamic class generation

I would like to implement the repository pattern, having my domain classes being independent from my repository implementation. but maintain my domain classes -on schema updates using EF for example- is really expensive. Do you know someway to automatize domain classes updates based on the ORM classes? -using T4 templates or something ...

T4 template to create *multiple* html (for example) output files per table from database schema

I'd like to use some T4 templates to generate html files derived from a sql server (in this case) database schema. For each table in the database, I would like to create 2 files: tableName_List.aspx - would contain the appropriate html to display in an asp.net GridView, with a grid column defined for each db table column tableName_Ed...

T4 generator problem

I just switched to the Visual Studio 2010 Ultimate Release Candidate, from Beta 2, and the T4 generator that I've been using doesn't work anymore. When I run it, I get an error message that says: "Failed to resolve include text for file:The path '\L2ST4.ttinclude' must be either local to this computer or part of your trusted zo...

T4 (Text Template Transformation Toolkit) for generating a set of types based on a list of basic types e.g. PointI32, PointF32 etc. in C#

Similar to http://stackoverflow.com/questions/2222849/boost-preprocessor-library-for-generating-a-set-of-types-based-on-a-list-of-basic I am asking how to generate: struct Point##TYPE_SUFFIX_NAME { TYPE X { get; set; } TYPE Y; { get; set; } // Other code }; for different basic (POD) data types e.g.: PointF32, Poi...

How to specify if a T4 file should produce any output

I am using T4 for generation of some DTO classes + mappers. I am splitting the files in a number of re-usable bits (some of which containing common methods, some others common procedures) and including them into the T4 templates that will produce my output - which is all good. My problem is that the re-usable .tt files will try and pro...

Is it possible to retrieve connection string inside DDL generation template in VS2010?

I am playing around with creating a T4 template for the "DDL Generation Template option" (model first) process in Visual Studio 2010 RC. Is it possible to retrieve the connection string that is associated with that process? If I right click on the .edmx file and choose "Generate Database from Model..." I have the option of choosing a da...

VS2008 T4 Subsonic Error on DBs with many tables System.Runtime.Remoting.RemotingException

At a consulting assignment they are using Subsonic 3.x (latest) which uses the T4 Code Templating Engine (rather than CodeSmith like 2.x did) When we run it on our DBMS that has ~ 1 thousand tables we run into an error generating the Structs.cs file. T4/Subsonic generates fine on smaller DBs.... An Exception was thrown while running th...

Creating T4 templates at runtime (build-time)?

We are building an inhouse application which needs to generate HTML files for upload into eBay listings. We are looking to use a template engine to generate the HTML files based on database and static fields that we have pre-defined. The template also needs to have logic capabilities (if-then, foreach, etc). We have looked at T4 and it ...

T4 template mandatory config values

i am planning to use T4 template to generate the config files. i have a main.tt file with basic settings. there are different .tt file for each environment which include the main.tt one thing which i want to achieve is how do i make sure that each environment specific .tt files override the main.tt variables. i need to do this since i wa...