4

I want to create a live template with resharper that allows me to write logging information inserting method name and method parameters, something like this:

I have in my code, a method like this:

public void searchByParams(String param1, String param 2)
{
    SearchClass mySearchClass = new SearchClass();
    mySearchClass.Search(param1, param2);
}

Now, I want to add logging, so far, I have two live templates created with resharper:

Enter, which template code is:

_logger.Info("Ingreso al método $METHOD_NAME$ ");

And Exit, which template code is:

_logger.Info("Salida del método $METHOD_NAME$ ");

for $METHOD_NAME$, I've choosen the macro: "containing type member name"

Then, after using these live templates, my method ends as follows:

public void searchByParams(String param1, String param 2)
{
    _logger.Info("Ingreso al método searchByParams ");
    SearchClass mySearchClass = new SearchClass();
    mySearchClass.Search(param1, param2);
    _logger.Info("Salida del método searchByParams ");
}

which is fine.

Now, I want to modify my "Enter" template, in order to have it inserting the list of arguments (in this example, param1 and param2), and make it usable for methods with different number of input params, and different types.

How can I do this?

I'm using resharper 6.

Thanks in advance.

Fernando Moyano
  • 1,097
  • 4
  • 15
  • 29

1 Answers1

0

I am not sure this can be done actually, not that I know of. Today I found myself needing the same thing so I am making a feature request to JetBrains. If you still care, please vote for this.

Jonas Van der Aa
  • 1,441
  • 12
  • 27