Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to leverage Resharper's "navigate to controller method" feature

Resharper 6 has a very nice new feature: If I write RedirectToAction or Html.Action anywhere in a MVC3 project, it get's underlined and using ctrl-click I can navigate there. It also notifies me if no such action exists.
However, I have a helper method in my BaseController, which takes an additional parameter (to put into TempData), and then calls a RedirectToAction. Unfortunately, Resharper doesn't acknowledge these strings as controller and method names, and doesn't underline.

I'm using the same parameter naming convention as MVC, my return type is the same, but still no. Is it possible that MVC's methods are hard-coded into Resharper? Is there a way to make it work on my method too?

Image included for clarity

like image 390
TDaver Avatar asked Nov 19 '11 21:11

TDaver


1 Answers

Yes, you can do it by using ReSharper's code annotation attributes.

First, go to ReSharper->Options->Code Annotations, copy attributes' implementation to clipboard and add them to your project.

Then, mark parameters of your methods with necessary attributes. For example, parameter containing action string, mark with AspMvcActionAttribute; controller - with AspMvcControllerAttribute and etc.

like image 101
derigel Avatar answered Nov 15 '22 01:11

derigel