包中的IntelliSense和三次斜杠注释

时间:2016-10-18 14:16:49

标签: c# visual-studio intellisense nuget-package xml-documentation

我开发了一个代码库,我花了很多时间将其记录下来。

使用三斜杠XML(xmldoc)注释对类,方法和属性进行注释。

/// <summary>
/// Adds two numbers together.
/// </summary>
/// <param name="a">The first number.</param>
/// <param name="b">The second number.</param>
/// <returns>The sum.</returns>
public int Add(int a, int b)
{
    return a + b;
}

但是当我将其编译成DLL文件并从我的其他项目引用它,或者将其打包为我引用的NuGet包时,Visual Studio / IntelliSense不会为我的库提供任何文档。

为什么会这样,我该怎么办?

2 个答案:

答案 0 :(得分:6)

我不是100%确定它是否能解决您的问题,但您是否尝试过生成xml doc文件。如果它与dll打包在一起,可能会被intelliSense选中。

enter image description here

答案 1 :(得分:0)

编译器从结果注释中删除所有注释,因此当通过其.DLL直接引用程序集时,IntelliSense无法提供任何文档。

通过启用输出&#34; XML文档文件&#34;在项目属性中,除了编译的.dll文件之外,编译器还会输出.xml文件。 当使用NuGet生成包(使用dotnet pack -c release完成)时,它包含XML文档文件(如果存在),因此使用NuGet安装的包为IntelliSense提供文档(如果存在)。