C# Visual Studio 没有 XML 标签的智能感知

C# Visual Studio Intellisense without XML tags

有没有办法让 Visual Studio 2019 (Enterprise) 识别 Intellisense 的非 XML 文档字符串,以便当您将鼠标悬停在它上面时,它会显示摘要、参数等。 ?具体来说,与在 C# SDK 中格式化文档字符串的方式相同。

例如,对于 Thread.Sleep(millisecondsTimeout) 它具有以下文档字符串:

    //
    // Summary:
    //     Suspends the current thread for the specified number of milliseconds.
    //
    // Parameters:
    //   millisecondsTimeout:
    //     The number of milliseconds for which the thread is suspended. If the value of
    //     the millisecondsTimeout argument is zero, the thread relinquishes the remainder
    //     of its time slice to any thread of equal priority that is ready to run. If there
    //     are no other threads of equal priority that are ready to run, execution of the
    //     current thread is not suspended.
    //
    // Exceptions:
    //   T:System.ArgumentOutOfRangeException:
    //     The time-out value is negative and is not equal to System.Threading.Timeout.Infinite.

这是显示的内容:Intellisense tooltip

我发现 XML 标签 (<param>millisecondsTimeout</param>) 的想法在查看代码时会损害可读性,我想知道是否有办法让它更类似于 Java' s JavaDoc,通读起来并不困难。

这不能直接在 VS 中完成,如前所述,您需要扩展才能实现此类功能。但是我什么都不知道。

另一方面,甚至 .NET 框架本身也使用 XML 注释。您提到的 Thread.Sleep(millisecondsTimeout) 就是当您在方法调用上按 F12 时 VS 从元数据中呈现给您的内容。其实这个方法有下面XML的注释:

<summary>
Suspends the current thread for the specified number of milliseconds.
</summary>
<param name="millisecondsTimeout">
The number of milliseconds for which the thread is suspended. If the value of the <paramref name="millisecondsTimeout" /> argument is zero, 
the thread relinquishes the remainder of its time slice to any thread of equal priority that is ready to run. 
If there are no other threads of equal priority that are ready to run, execution of the current thread is not suspended.
</param>
<exception cref="T:System.ArgumentOutOfRangeException">
The time-out value is negative and is not equal to <see cref="F:System.Threading.Timeout.Infinite" />.
</exception>

Visual Studio 和 Intellisense 从 XML 文件中获取它,您可以在 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.[=19= 等位置找到该文件].X\mscorlib.xml.