在 Visual Studio 中,默认的 MVC 帮助程序允许我跳转到选定的 Controller 或操作:
但是当我创建自定义帮助程序扩展时,我无法再执行此操作:
有没有办法在 Visual Studio/Resharper/或扩展方法本身中添加此功能?
UPD: 扩展方法的代码
public static class HtmlHelpers
{
public static MvcHtmlString MenuLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName)
{
return htmlHelper.ActionLink(linkText, actionName, controllerName);
}
}
最佳答案
Resharper 允许注释来引导其魔力。它们通常通过应用属性来实现,尽管它使用 BCL 类的外部注释文件。您可以在自己的代码中使用它们。我认为它们没有得到充分利用。
有一个example正是您的用例。只需将 [AspMvcAction]
和 [AspMvcController]
应用到适当的参数即可。
关于c# - "Go to declaration"自定义 MVC 帮助器扩展 Controller 和操作的功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17888088/