Visual Studio 链接到不同区域的代码

发布于 2024-11-09 05:51:10 字数 128 浏览 0 评论 0原文

只是想知道 Visual Studio 2010 中是否有任何功能允许您在评论中添加链接,将您带到解决方案的另一部分。有点像书签功能,但您可以通过单击链接转到书签。

我只是认为为我的每个方法添加一个指向单元测试的链接会很巧妙。

just wondering is there any feature in visual studio 2010 that allows you to put a link in your comments that take you to another part of the solution. Kind of like the bookmark feature but you go to the bookmark by clicking on the link.

I just think it would be neat to put a link to the unit test for each of my methods.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

深空失忆 2024-11-16 05:51:10

如果您使用 Resharper,则可以通过按住 Ctrl 键单击导航到文档注释中放置的任何有效符号。

例如,

/// <summary>
/// <see cref="AReferencedMethod"/>
/// </summary>

只需按住 ctrl 键并单击即可。

不幸的是,我不确定这对于引用单元测试是否有用,因为被测试的程序集通常由单元测试程序集引用,而不是相反。

If you're using Resharper then you can navigate to any valid symbol placed in a doc-comment with ctrl-click.

For example

/// <summary>
/// <see cref="AReferencedMethod"/>
/// </summary>

Just ctrl-click and you're there.

Unfortunately I'm not sure this would be useful for referencing unit tests since the assembly under test is usually referenced by the unit test assembly not the other way around.

带上头具痛哭 2024-11-16 05:51:10

您可以使用超文本注释链接直接链接到文件,如下所示:

//file://c:\users\project\myfile.cpp

但是,这会在内置文件中打开文件在浏览器中,而不是在代码编辑器中,这没有多大用处。它还需要完整路径,因为它似乎没有注册像 $(SolutionDir) 这样的项目变量。

然而,如果这里有人精通编写 Visual Studio 插件,我认为重写超链接系统将是开始工作的好地方。

:D

You can bake in a direct link to a file using the hypertext comment link like this:

//file://c:\users\project\myfile.cpp

However that opens the file in the built-in browser, not the code editor, which isn't much use. It also needs the full path as it doesn't seem to register project variables like $(SolutionDir).

However, if anyone on here is savvy at writing Visual Studio Plugins, I think an override of the hyperlink system would be a good place to start to get this working.

: D

北恋 2024-11-16 05:51:10

尝试使用 HyperAddin 扩展

或者,如果您有商业插件 Visual Assist,它支持在注释中转到 (alt+g),尽管结果会根据注释中符号的完整范围而有所不同。 Visual Assist 还支持可导航评论中的标签 (VA 主题标签),并且可以导航到通过源链接的 文件查看器插件在注释中引用的文件功能

Try the HyperAddin extension.

Alternatively, if you have the commercial addin Visual Assist, it supports go to (alt+g) in comments, though results will vary depending on how fully scoped symbols are in the comments. Visual Assist also supports tags in comments that are navigable (VA Hashtags) and can navigate to files referenced in comments via the File Viewer Plugin for the Source Links feature.

夜空下最亮的亮点 2024-11-16 05:51:10

Supercharger 支持这种导航方式 - 请参阅其“代码链接”实现。基本上,您将 goto:... 结构放在注释中并获得一个可视的可点击热点。

支持以下功能:

  • goto:#TagName 导航到先前定义的标签(带有 tag:#TagName),可以是同一项目中的任何位置
  • goto:MemberName 导航到同一类/结构中的成员
  • goto:CodeTypeName.MemberName 导航到同一代码文件中但位于不同类中的成员,或者导航到不同代码文件中的成员(如果类名)和代码文件名相同
  • goto:FileName\CodeTypeName.MemberName 导航到不同代码文件中的成员

免责声明:我是 Supercharger 的创建者。

Supercharger supports this style of navigation - see its 'Code Links' implementation. Basically, you put goto:... constructs in comments and get a visual clickable hotspot.

The following functions are supported:

  • goto:#TagName navigates to a previously defined tag (with tag:#TagName), can be anywhere in the same project
  • goto:MemberName navigates to a member within the same class/struct
  • goto:CodeTypeName.MemberName navigates to a member within the same code file, but in a different class, or to a member within a different code file, if the class name and the code file name are the same
  • goto:FileName\CodeTypeName.MemberName navigates to a member in a different code file

Disclaimer: I am the creator of Supercharger.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文