T4MVC and Resharper Navigation

2019-05-08 06:52发布

I frequently use Resharper's 'Go to Declaration' (ctrl + b in the Resharper Default Keymapping) keyboard shortcut to help with navigation within VS2010. Before I included a reference to T4MVC in my application, I would use "string refrences" and Resharper would know where I 'meant' to go.

For example:

@Html.Partial("_Continents" )

When I would use ctrl+b on the string "_Continents", Resharper knew I wanted to go to the partial view named _Continents.cshtml.

Since I have started using T4MVC, the same snippet above could be written:

@Html.Partial( MVC.CascadingDropDownLists.DropDownAjaxPost.Views._Continents )

When I use ctrl+b on _Continents, instead of taking me to the partial view, it takes me to the T4MVC generated code.

Is there any way to keep T4MVC in the project (I really like the strongly typed feel and intellisense support), while restoring the original navigation?

2条回答
甜甜的少女心
2楼-- · 2019-05-08 07:47

I created a small Visual Studio macro to help with this. It has issues, but it is far better than nothing IMO. It replaces F12, so you don't have to use a separate function for each.

I've posted it here:

Visual Studio macro to navigate to T4MVC link

查看更多
别忘想泡老子
3楼-- · 2019-05-08 07:48

Unfortunately, ReSharper's MVC navigation works only on constants. If T4MVC will generate consts instead of readonly fields - it should works.

查看更多
登录 后发表回答