How do you add intellisence text to an object or function?
-
Hi, Can anyone tell me how to add intellisence descriptions to an object, function, and or property? I think it has something to do with adding text in [] above a object, function, or property but that's just a guess. Thanks :)
XML Comments are your friend.
/// <summary>
/// This will appear in the intellisense thingamabob.
/// </summary>
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
-
Hi, Can anyone tell me how to add intellisence descriptions to an object, function, and or property? I think it has something to do with adding text in [] above a object, function, or property but that's just a guess. Thanks :)
You must document your source (or go through the pain-staking process of writing an XML document that conforms to the standards, which is difficult and your source should be documented anyway) and generate an XML document from it. For instance, do something like this:
/// <summary>This class does X.</summary>
/// <remarks>A better, longer description...</remarks>
public class MyClass
{
/// <summary>
/// Creates a new instance of the <see cref="MyClass"/> class.
/// </summary>
public MyClass()
{
}
/// <summary>Returns <paramref name="param1"/> + 1.</summary>
/// <param name="param1">Description of param1</param>
/// <returns>An <see cref="Int32"/> that represents something.
public int SomeMethod(int param1)
{
return param1 + 1;
}
}In VS.NET, right-click on your project and select Properties. Set the configuration to "All Configurations" (recommended) and find the Configuration Properties/Build section. Specify a name in the "XML Documentation File". If you don't specify a path (so just a filename), the filename is written to the build directory (like bin\Debug or bin\Release depending on the build configuration at the time of compiling). This is the same as the /doc option for the csc.exe command-line compiler. See Recommended Tags for Documentation Comments[^] for more information. You can use any tags, but you should at least use these (like many documentation compilers like NDoc[^] that I help with will also recognize <b> tags, <p> tags, etc.). When you deploy your assembly, make sure the generated XML document has the SAME name as the assembly, only that is has a .xml extension instead of .dll. VS.NET (and other editors of any decent value) will query for this file and use it to display comments for your assembly in the source editor.
Microsoft MVP, Visual C#