Question

I have an open source project with a user that would like to know what the default for a property is. How do I get the default to show in intellisense? Is there an attribute or tag?

Here is the related post: https://comparenetobjects.codeplex.com/discussions/535877

/// <summary>
/// If true, compare fields of a class (see also CompareProperties).
/// The default is true.
/// </summary>
public bool CompareFields { get; set; }
Was it helpful?

Solution 2

You can generate an XML file from your XML-style comments if you enable XML documentation file in the Build properties of your project or using the /doccommand line switch when compiling.

This XML file can then be used by Visual Studio to display the additional information about the property or method and its parameters. Your user just needs to place this XML into the same folder as the referenced DLL.

For the Designer of Visual Studio there is the DefaultValueAttribute which can be put on all targets (properties, fields, ...).

OTHER TIPS

The best way to ensure that users working in the IDE see your default value for fields or properties is to include the default value in the <summary> tag. To include a default value for a parameter in of a method, you can either use the optional parameters feature of C#, or include a note about the suggested default value in the <param> element for that parameter.

While other elements are available (e.g. <remarks> and <value>), the built-in support for IntelliSense only consistently presents the content of the <summary> and <param> elements to users.

Finally, to ensure that users of your library also have access to this information, make sure to take the following steps:

  1. Configure your build to produce XML documentation for your project.
  2. Make sure to distribute the XML documentation file alongside your assembly if are planning for users to reference the assembly directly in their projects.

I am currently working hard to make the Peek Help feature which was recently added to Productivity Power Tools for Visual Studio 2013 work with 3rd party documentation sources. If/when this feature becomes available, users who wish to see more information than just the <summary> tag will be able to press Alt+F1 to bring up the inline documentation browser. In the meantime, opening the built-in Code Definition Window in Visual Studio may allow you to see more information than IntelliSense wants to present by default (although it won't be rendered in a pretty format).


Detailed answer to the original question.

In Visual Studio 2010 and up, the IntelliSense information you see is divided into three primary operations:

  1. Code Completion: This is the dropdown you get when typing a new word, or after typing a .. It contains a list of available items, and if you select one it often shows additional information about that item.
  2. Quick Info: This is the tooltip you see when you hover over an item and it shows a popup with information about the item.
  3. Signature Help: This is the popup you get by pressing Ctrl+Shift+Space, or after typing the ( character to start calling a method. It contains information about the current parameter of a method call.

Each of these features is under the control of the individual language implementations in Visual Studio (e.g. C# controls its own information, and Visual Basic controls its own information). Inside the IDE, the information is provided by the ICompletionSession, IQuickInfoSession, and ISignatureHelpSession (respectively) to a language-independent implementation of IIntellisensePresenter for display. This separation between the language and the presentation makes it very difficult to modify the IntelliSense information which is displayed for one of the built-in languages.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top