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?

Vitor Silva
  • 17,114
  • 8
  • 33
  • 27

7 Answers7

37

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

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Dan
  • 2,818
  • 23
  • 21
  • 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 nothing – Matthew Lock Sep 05 '16 at 02:30
  • For anyone wondering how to actually install this, it can be found from the extension manager in resharper menu in visual studio. – David S. Apr 06 '17 at 08:47
  • Oirginally I said ... "**Resharper**" wins again with the help of the [ForTea](https://github.com/MrJul/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 ? – Dan Jul 19 '17 at 16:38
  • 1
    This answer [was brought up on Meta](https://meta.stackoverflow.com/questions/352494/why-was-this-spam-flag-declined). 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? – Cody Gray - on strike Jul 19 '17 at 16:51
  • 1
    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 experience – Dan Jul 19 '17 at 17:02
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

grexter89
  • 1,091
  • 10
  • 23
  • 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) – Matthew Lock Sep 05 '16 at 02:29
  • I'm getting the same problem with this version sadly. I don't hold out hope with getting an answer quickly either :( – Richard Griffiths Dec 19 '17 at 16:42
  • 4
    **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**. –  Feb 25 '22 at 23:46
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.

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.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Oleg Sych
  • 598
  • 3
  • 4
  • 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. – Mel Jan 14 '09 at 15:19
  • Link to Visual T4, Free: http://visualstudiogallery.msdn.microsoft.com/40a887aa-f3be-40ec-a85d-37044b239591 – iappwebdev Nov 28 '11 at 15:21
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

HackSlash
  • 4,944
  • 2
  • 18
  • 44
  • 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. – Literate Corvette Oct 06 '22 at 16:26
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.

rohancragg
  • 5,030
  • 5
  • 36
  • 47
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.

Maxter
  • 716
  • 7
  • 15