tags:

views:

21

answers:

2

I am using T4 for generating code. With Visual Studio I could generate code in C# or VB. What is required for generating code in Ruby or Java ?

I have a some utility classes that is required in multiple language (C#, Ruby and Java). I am looking for defining T4 templates...

Thanks

A: 

Hi Venki, You can generate code in any language using T4 or indeed any other textual artifact. You just need to start with an example of what you want to generate and begin to parameterize it.

Only the code generation control code inside the template needs to be in C# or VB.

GarethJ
A: 

With a standard T4 template, you can generate any code, but what comes out is part of your project. While you can generate any kind of text, this is really most useful if you're compiling the code that comes out.

With VS2010, you can now use a T4 PreProcessed Template. Instead of generating a text file, you generate the generator. Making the generator instead of the resulting code should give you lots of flexibility with integrating your Java/Ruby output.

Anything can come out of the generator, but I think you still have to write the actual T4 code in VB or C#.

mattmc3