4

As question Useful Eclipse Java Code Templates suggest some live templates for java, I start to think about some possibilities in C#

ReSharper has Live Templates: ReSharper -> Live Templates

e.g. (my unique until now)

tt is expanded to:

[Test]
    public void Test(){}

But, out of this scope some other idea. Or about Predefined Templates, exists someone that rocks?

Community
  • 1
  • 1
Custodio
  • 8,594
  • 15
  • 80
  • 115

1 Answers1

4

Here are some I love:

// $type$: $END$ ($user$ on $time$)

  • Shortcut com for comment
  • $type$: TODO is default; first editable
  • $user$: evaluated to current user name
  • $time$: evaluated to current date/time

private readonly Logger _logger = LogManager.GetCurrentClassLogger();

  • Shortcut log for logger

System.Diagnostics.Debug.Assert($condition$, "$condition$");

  • Shortcut as for assertion
  • It is far more productive than the predefined asrt template, because it automatically prints out the condition to the assertion dialog

System.Diagnostics.Debug.Assert($condition$, "$condition$", "$END$");

  • Shortcut asd for assertion detail
  • If you need some more explanation for the assertion

But, always try to ask yourself, what do you type most. Most valuable live templates will differ from domain to domain.

Apart from that, I really like your tt template. I just added it to my templates :) Also I started a new file template that creates the whole default skeleton of a test class.

Matthias
  • 15,919
  • 5
  • 39
  • 84