[英]I want to put a comment that will let me get to a different block of code in c#
我想我可以在 xml 注释中使用 cref。
我还发现了一种使用 nameof 运算符的狡猾方法。
string fakeString = nameof( NewForm.HandleCommandLineArgments ); // use go to definition to get to NewForm.HandleCommandLineArgments
还有其他想法吗?
更新:我意识到如何去定义,理想情况下我不必添加“string fakeString”。 我认为 cref 有点令人失望,因为我认为它只能在方法顶部的 xml 注释中,但您可以将它们放在任何地方。
我要去:
/// <see cref="NewForm.HandleCommandLineArgments">
PipeClient.SendSimpleStringMessage( "scriptcode", "[Arguments]" + commandLineArguments );
在 Visual Studio 2017 中,您只需使用Ctrl + T (或分配给Edit/Go To All
任何快捷方式)即可转到任何类型。 即使在早期的 Visual Studio 版本中,ReSharper 也具有类似的功能。
不需要更多; 和像您的fakeString
这样的变量fakeString
是一种代码异味(甚至可能由于“未使用的变量”诊断而导致构建/维护问题)。
如果它与方法相关,那么通过<see cref="..."/>
和/或<seealso cref="..."/>
在 XML Doc 中包含链接也是完全可以接受的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.