Visual Studio macro to navigate to T4MVC link

Posted by shannon on Stack Overflow See other posts from Stack Overflow or by shannon
Published on 2012-06-19T11:36:56Z Indexed on 2012/06/19 15:16 UTC
Read the original article Hit count: 294

I use T4MVC and I'm happy with it and want to keep it - it keeps down run time defects. Unfortunately, it makes it harder to navigate to views and content (a.k.a. Views and Links in T4MVC) though. Even using Resharper, I can't navigate to the referenced item:

T4MVC and Resharper Navigation

Can I get a hand building a macro to do this? Never having built a VS IDE macro before, I don't have a grasp on how to get at some things, like the internal results of the "Go To Definition" process, if that's even possible.

If you aren't familiar with T4MVC, here's generally what the macro might do to help:

  1. Given the token: Links.Content.Scripts.jQuery_js in the file MyView.cshtml, '(F12) Go To Definition'. This behaves properly.

  2. Having arrived at the the related assignment: public readonly string jQuery_js = "~/Content/Scripts/jQuery.js"; in a file generated by T4MVC (which is very nice, thank you David, but we really don't ever need to see), capture the string assigned and close the file.

  3. Navigate in Solution Explorer to the PhysicalPath represented by the captured string.

This process would also work for views/layouts/master-pages/partials, etc.

If you provide a macro or link to a macro to do this, or have another solution, wonderful. Otherwise, hints on how to do step 3 simply in a VS macro would be especially appreciated and receive upvote from me. I'd post the macro back here as an answer when done.

Thanks!

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about visual-studio