Where do Visual Studio Intellisense comments come from?

天涯浪子 提交于 2019-11-30 11:37:41

When the source code is within the existing solution (or even better, the same project), Visual Studio doesn't need to find an XML file - it knows where the documentation comments are, so it will use them. (Just like Intellisense knows what members you've declared in the other file, even if you haven't actually rebuilt yet.)

You need to create an XML file if you want to add a reference to a DLL rather than a project reference within the same solution. So for example, I supply NodaTime.xml with the Noda Time package, so that even though you don't have the source code, you can still see the comments in Intellisense.

Intellisense gets it from its XML comments.

For example, let's say I have a class:

///<summary>
/// This is an example class
///</summary>
static class Foo
{
    //members
}

In fact, you can go even deeper than that. For example, a method:

///<summary>
///Returns the object to string, uppercased.
///</summary>
///<param name="o">The object to be transformed.</param>
///<returns>The string.</returns>
public string someMethod(object o)
{
   return o.ToString().ToUpper();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!