how can I get intellisense in a T4 template?

24,221

Solution 1

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.

Solution 2

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

Solution 3

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

Solution 4

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.

Solution 5

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

Share:
24,221
Vitor Silva
Author by

Vitor Silva

Team Lead at Samsys myLinkedInProfile

Updated on July 09, 2022

Comments

  • Vitor Silva
    Vitor Silva almost 2 years

    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?

  • Mel
    Mel over 15 years
    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.
  • iappwebdev
    iappwebdev over 12 years
  • Matthew Lock
    Matthew Lock over 7 years
    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
    Matthew Lock over 7 years
    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
  • Stephen Hewlett
    Stephen Hewlett over 7 years
    That link currently points a plumbing advice website... I guess Clarius don't sell Visual T4 anymore.
  • rohancragg
    rohancragg over 7 years
    Yeah, :-( I guess Clarius are no more?!
  • David S.
    David S. about 7 years
    For anyone wondering how to actually install this, it can be found from the extension manager in resharper menu in visual studio.
  • Dan
    Dan almost 7 years
    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 ?
  • Cody Gray
    Cody Gray almost 7 years
    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?
  • Dan
    Dan almost 7 years
    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
  • Richard Griffiths
    Richard Griffiths over 6 years
    I'm getting the same problem with this version sadly. I don't hold out hope with getting an answer quickly either :(
  • MickyD
    MickyD over 2 years
    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.