VisualStudio |摘要 - IntelliSense自定义标记

时间:2018-04-10 13:59:50

标签: visual-studio resharper documentation summary

有没有办法为summary中的VisualStudio 2017添加自定义代码,以便在IntelliSense中查看? 我有一个包含HtReturnStatus的对象HtErrorCode。我们的图书馆大约有100个HtErrorCode。因此,如果可以声明方法可以返回的错误代码,那将对我们来说是一种改进。

(如果需要,ReSharper可用)

信息:https://docs.microsoft.com/de-de/dotnet/csharp/programming-guide/xmldoc/recommended-tags-for-documentation-comments

public class Foo
{
    /// <summary>
    /// This method returns error codes.
    /// </summary>
    /// <ErrorCodes>
    /// <see cref="HtErrorCode.USER_WrongCredentials"/> / <see cref="HtErrorCode.USER_UserNotFound"/>
    /// </ErrorCodes>
    public static HtReturnStatus Login()
    {
        return HtReturnStatus.Failed(HtErrorCode.USER_WrongCredentials);
    }
}

提示 如果要在XML文档文件中添加自定义标记,请查看Peter Macejhttps://stackoverflow.com/a/49757547/6229375

中的解决方案

1 个答案:

答案 0 :(得分:1)

您是否需要在IntelliSense或生成的文档中显示有关错误代码的信息?如果在IntelliSense中,您应该将其放在一些现有的顶级XML doc标记中。看起来最好&lt; return&gt;对我来说。例如:

/// <summary>
/// This method returns error codes.
/// </summary>
/// <returns>
/// The <see cref="HtErrorCode"/> object with one of the following error codes:
/// <see cref="HtErrorCode.USER_WrongCredentials"/> or <see cref="HtErrorCode.USER_UserNotFound"/>.
/// </returns>

如果该信息更长,我会把它放在&lt; remarks&gt;标签

如果你真的想要一个单独的顶级块,就像你的例子一样,这可以做到。但它不会在Intellisense中显示,仅在生成的文档中显示。 我不知道其他工具怎么样,但我们的VSdocman(我是它的开发者)完全支持custom tags

相关问题