gpt4 book ai didi

c# - "Go to declaration"自定义 MVC 帮助程序扩展 Controller 和操作上的功能

转载 作者:行者123 更新时间:2023-11-30 20:55:58 25 4
gpt4 key购买 nike

在 Visual Studio 默认的 MVC 帮助程序中,我可以跳转到选定的 Controller 或操作:

enter image description here

但是当我创建自定义帮助程序扩展时,我不能再这样做了:

enter image description here

有没有办法在 Visual Studio/Resharper/或扩展方法本身中添加此功能?

更新:扩展方法代码

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com