Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
There is a Visual Studio Extension: Code Contracts Editor Extensions. This extension displays code contracts.

The extension works and displays the code contracts in the ToolTip of a method, but I'm not getting the code contracts in the ToolTip for constructors.

Is there a possibility to display 'Code Contracts' in Visual Studio as ToolTip for constructors?

I´ am using .Net 4.0 in MS Visual Studio 2010 Professional.

Here is the Example-Code:
C#
class Foo
   {
       public Foo(string name)
       {
           Contract.Requires<ArgumentNullException>(name != null, "name");
       }

       public void Execute(ICollection<int> executedIds)
       {
           Contract.Requires<ArgumentNullException>(executedIds != null, "executedIds");
       }
   }

   class Bar
   {
       public static void Execute()
       {
           var foo = new Foo("foo");
           foo.Execute(new Collection<int>());
       }
   }



http://i.cubeupload.com/U3cmxi.png -> Constructor has no Code Contracts displayed in ToolTip

http://i.cubeupload.com/NWZFwo.png -> Method has Code Contracts displayed in ToolTip

Many thanks
Posted
Updated 12-Mar-13 11:57am
v3
Comments
Sergey Alexandrovich Kryukov 12-Mar-13 11:20am    
Not clear. A short but comprehensive code sample would help...
—SA
DrNimnull 12-Mar-13 16:01pm    
I have edited my Question. Hope it´s a bit more clear?
Sergey Alexandrovich Kryukov 12-Mar-13 16:55pm    
Yes, it is, thank you very much for clarification. Unfortunately, at this moment I don't know the answer, perhaps someone else can help...
Do you mean Intellisense, which is technically, not a tooltip?..
—SA
DrNimnull 12-Mar-13 18:00pm    
Thanks. You´re right. The code contracts are only displayed in the ToolTip. To avoid confusions I removed Intellisense from my question. Although the 'Parameter Info' (->ToolTip) is also part of Intellisense =).
Sergey Alexandrovich Kryukov 12-Mar-13 18:14pm    
Great. Well, I guess this is a matter of delving deeper into VS add-in SDK... I'm just curious: why would you need those ToolTips, if the project you referenced provides Intellisense support for them? Is it not good enough?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900