how can I get intellisense in a T4 template?
Asked Answered
T

7

53

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?

Trujillo answered 7/1, 2009 at 15:39 Comment(0)
A
3

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.

Affine answered 8/1, 2009 at 11:47 Comment(2)
The Clarius T4 editor is the only option I know of at this point. There's a community edition that'll get you some basic syntax highlighting.Appledorf
Link to Visual T4, Free: visualstudiogallery.msdn.microsoft.com/…Concenter
M
38

Resharper can do this, with the help of the ForTea Plugin that adds support for editing T4 (.tt) files.

Maquis answered 10/8, 2013 at 6:17 Comment(5)
It's okay, but it can't seem to resolve any of the symbols in the t4 file github.com/MrJul/ForTea/issues/50 at least it actually does some syntax highlight though unlike Tangible T4 or Devart T4 which did nothingPlott
For anyone wondering how to actually install this, it can be found from the extension manager in resharper menu in visual studio.Wamble
Oirginally I said ... "Resharper" wins again with the help of the ForTea Plugin. I still think the same. @Cody , please excuse me if is too obvious but why you have edited this answer... ? is it grammatically incorrect ?Maquis
This answer was brought up on Meta. Someone flagged it as being "spam", and that flag was rightfully declined. I edited the answer to make it more clear what you're suggesting. "Resharper wins again" doesn't make any sense to me. What does it win? How does it win again? When did it win the first time?Yacano
Well I'm not a native English speaker but..., but I think :), that I tried to transfer the "emotional" factor of finding the right tool, and it happens to be the same one I used before to solve similar issues ...with "colloquial language" , perhaps it's lost in translation. But I see the point... it's too subjective to my own experienceMaquis
N
36

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
Also available for Visual Studio 2019: Tangible T4 Editor 2.5.0

Nadabb answered 18/8, 2010 at 5:8 Comment(3)
I installed Tangible T4 but my tt files didn't get any syntax highlighting. Even the feedback form after you uninstall doesn't work too. (Complains about JS being disabled when it isn't)Plott
I'm getting the same problem with this version sadly. I don't hold out hope with getting an answer quickly either :(Vogt
Note to Googlers 2022+: Whilst a fine answer at the time (and I loved Tangible T4), Tangible T4 seems to be dead for anything beyond 2019 (which to be fair, no one was talking about including the poster at the time). The last blog post was in 2019 and the last forum announcement was in 2020.Sorilda
H
9

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.

Huskamp answered 23/3, 2009 at 19:13 Comment(0)
A
3

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.

Affine answered 8/1, 2009 at 11:47 Comment(2)
The Clarius T4 editor is the only option I know of at this point. There's a community edition that'll get you some basic syntax highlighting.Appledorf
Link to Visual T4, Free: visualstudiogallery.msdn.microsoft.com/…Concenter
G
2

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 features to get you started.

Globuliferous answered 24/3, 2009 at 10:13 Comment(2)
That link currently points a plumbing advice website... I guess Clarius don't sell Visual T4 anymore.Bravery
Yeah, :-( I guess Clarius are no more?!Globuliferous
A
2

I found the devart T4 editor has all the features I was looking for in a Visual Studio Extension for free. It's all native. Feels like editing any other source file.

https://www.devart.com/t4-editor/download.html

Ahmadahmar answered 25/11, 2020 at 0:9 Comment(1)
I might be doing something wrong, but the annoying thing with this one to me was that if you do an auto-format indents everything about ten times further than it should be, all the way across the screen. It also doesn't seem to recognize parameters specified with a colon when called, as the .edmx .tt files use, and uses colors that aren't very good for dark theme.Shannan
T
0

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.

Transport answered 6/2, 2020 at 15:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.