T4MVC and Resharper Navigation

天涯浪子 提交于 2020-01-13 10:55:11

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/9269279/t4mvc-and-resharper-navigation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!