Showing posts with label Smart Generate. Show all posts
Showing posts with label Smart Generate. Show all posts

Friday, October 3, 2008

Make Abstract Context Action

Ole asked me to do context actions that make a method abstract or virtual.

It turned out that Resharper already had a context action for making an abstract method virtual, but not the other way around.

So I have implemented the "Make abstract" context action for methods and properties.

I have also fixed some bugs in Smart Generate and Check Assignment To String.

Thursday, September 25, 2008

Using Smart Generate

I am just amazed at how well Smart Generate works.

Here is an example:

Whenever I write use a string, that is visible to the user, I need to run it through a Translate.Text method, e.g:


output.Write(Translate.Text("Visible output"));


However writing the call the Translate.Text is tedious, so I want to put that in Smart Generate.

First I write the statement with out the Translate.Text call.


output.Write("Visible output");


I place the caret on top of the string literal, and press Shift+Enter, which brings up the Smart Generate menu.

From the menu I select "Create Live Template" and then "Surround String Expression".

ReSharpers Live Template Editor opens and I name the Live Template "Translate string". The code of the Live template is:


Translate.Text($SELECTION$)


Save the Live Template and return to original code.

Press Shift+Enter to show the Smart Generate menu and select "Translate string".

And bingo, I have:


output.Write(Translate.Text("Visible output"));


Never have to write another call to Translate.Text manually again.

Big smile!