20
votes

In C# or Vb.Net, using the Visual Studio 2013 SDK, how I could add an additional element on Intellisense when the info of a member is shown?.

My intention is not to add a completion/suggestion element, I would like to add custom additional info below the info that is shown for a member that can throw an exception like a method, function or property (getter/setter), not a keyword.

I read a little bit the members of Microsoft.VisualStudio.Language.Intellisense namespace but I didn't take any clear idea about it.

My goal, with the help I could get here, is to find the answer to develop a simple extension that will add (documented)Exception information for members, something like this:

enter image description here

I wonder to bring back this useful feature in Visual Studio for C#, and add it also for VB.Net, then if successful I'll share it for free with all yours like I did in the past with this useful extension:

Just I comment that because any help could be rewarded for all of us in that way!.


Additionally to my question, and only Additionally, if someone could start guiding me about how to figure out the way to retrieve the Xml documentation of the members ( <exception cref="Exception name"> ) to do this, or maybe a simple way, I would be very grateful.

EDIT:

About the Xml documentation, I get the idea to use the Visual Studio object browser to inspect the exceptions of the member that will be listed by Intellisense instead of messing with Reflection? to get exception info. That could be a better and viable way to do it once I can figure out how to automate the object browser from SDK, but I'm just commenting this, maybe that will be a new question once this question could be solved, because firstly I need to solve this step, I hope so.

1
How is this question different from your previous question?Bjørn-Roger Kringsjå
@Bjørn-Roger Kringsjå Thanks for comment. In that question I asked for the existence of a guided way to enable the feature from the IDE (such a hidden option or command), or from an existing 3rd party extension. This question is different, this is programming-language specific to start trying to develop an extension from scratch to add that feature.ElektroStudios
Personally, I would not want complete, verbose documentation in Intellisense. The arguments and return are appropriate for when you are typing a method name. Looking things up in Object Browser to see commentary and/or exceptions is very much a different step (for me).Ňɏssa Pøngjǣrdenlarp
As stated in your previous question even in VS2105 C# does not even have this capability anymore so I would guess as mentioned before that it's not likely you can implement this functionality.Karen Payne
@Karen Payne and Plutonix Thanks for comment. Please be aware that a lot of Visual Studio professional extensions (non-open source) like for example Telerik (Just Code) interacts with IntelliSense to add extra information, then, with this argument I can confirm its possible to extend Intellisense, more than that, there is the IntelliSense class that I linked in my question to play with things!, but I can't figure how to.ElektroStudios

1 Answers

12
votes

There are few types of IntelliSence extensibility points that you need to use for each of the following cases:

  • The tool-tip shown when hovering text element is called QuickInfo tool-tip, and can be implemented by yourself via inheriting from IQuickInfoSource interface and creating a matching IIntellisenseController. A full walk-through can be found on MSDN:

    • Example:

      QuickInfo Tool-Tip

    • Make sure to make your IQuickInfoSourceProvider load your IQuickInfoSource before the default Visual-Studio one by using the Order attribute - otherwise the default QuickInfo is not going to be shown:

      [Order(Before = "Default Quick Info Presenter")]
      
  • The tool-tip shown when writing method name which shows it's signature is called Signature Help and can be implemented by inheriting ISignatureHelpSource in a very similar way to the QuickInfo tool-tip. A full walkthrough can be found on MSDN:

    • Example:

      Signature Help

  • Code Snippets - which are irrelevant for you.

  • Statement Completions - which are irrelevant for you.

Note that you will need to make an IClassifier in your project for the tool-tips to be displayed, with this you can also modify the view so that the Exceptions will be viewed differently as you wish. Guide on MSDN.

Getting the information on the methods on the other hand is up to you. you can use an external manual source and use it in your IQuickInfoSource or read it from a matching XML Comment document by analysing the ITextStructureNavigator's read word using Roslyn over the code document that you are navigating.

Sorry if it was a little abstract answer but this is a very broad question and there are many ways to implement such an extension.

P.S.: I've managed to make a similar extension in low quality in order to study this field so if you have any following questions about the implementation itself feel free to ask.