Displays Code Contracts (when editing C#) in code, Intellisense, and in metadata files.
Inheritance:
Displays contract information on methods with inherited contract information, or on interface/abstract methods
Metadata:
Dispalys contract information in metadata files.
Qui...
Great extension! I especially like the adornments for inherited contracts; a very nice addition.
The IntelliSense output is clobbered by ReSharper unless ReSharper's IntelliSense is disabled. That's unfortunate, but it's no fault of this extension.
EDIT [Possible Bug]: It seems that when defining contracts on an interface method that takes a reference to an interface in the Microsoft.Office.Interop.* namespace as a parameter, the extension does not show adornments for implementing types, nor does the hover text reflect the contract. See [http://social.msdn.microsoft.com/Forums/en-US/codecontracts/thread/dda8fd5a-7a6d-44cb-bea9-dd11549acb61] and [http://stackoverflow.com/questions/9102059/issue-with-code-contracts-on-generic-interface].
In solution with 48 projects (C# and C++) compilation is not possible any more when the "Code Contracts Editor Extensions" is installed. VS2010 Professional (4.0.30319) hangs (CPU 100%, a lot MSBuild processes are spawned) while compiling the first C++ project. Disabling the extension doesn't help, only uninstalling it. It's a pity, because I like to see the code contract information in the tool tips.
This could eventually turn out to be a great extension, but I have several major grievances with it: - It's very slow, so contracts do not appear right when you open a file. It affects basic stuff like typing in editor windows by slowing them down - sometimes the added lag is so bad you can see characters appear way after you typed them (and this is on a modern PC). - The way contracts are displayed consumes too much horizontal space for my taste. It would be better if they appeared collapsed somewhere and only displayed on mouse-over, which may also allow for snappier operation as it wouldn't have to get all contracts at once. - There are various annoying visual glitches in the current release. I'll be keeping my eyes on future releases for now it's a pass from me.
When it works, it's very cool. Many times, it just does not work. And it slows down other operations, so I disabled it at work as I need high speed. But this is a great first release. I will keep it on at home for training and small stuff.
The extension works great, but I'm not getting intellisense support for constructors at all. Example of what I'm talking about follows. I have intellisense support on foo's go method, but not on the constructor.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace CodeContractsTest
{
class Program
{
static void Main(string[] args)
{
ConsoleWriter Foo = new ConsoleWriter("Bob");
Foo.Go();
Console.ReadLine();
}
}
public class ConsoleWriter
{
string _text;
public ConsoleWriter(string text)
{
Contract.Requires(text != null, "null isn't allowed!");
_text = text;
}
public void Go()
{
Contract.Ensures(_text != null, "text can't be null!");
Console.WriteLine(_text);
_text = null;
}
[ContractInvariantMethod]
void ObjectInvariant() {
Contract.Invariant(_text != null);
}
}
}
When I define a contract on an interface method that takes a reference to a type in Microsoft.Office.Interop.* as a parameter, adornments are not displayed on the interface definition or implementing types, and the hover text does not reflect the contract. Replacing the interop type with some other reference type resolves the issue.
Code Contracts DevLab Forum post: [http://social.msdn.microsoft.com/Forums/en-US/codecontracts/thread/dda8fd5a-7a6d-44cb-bea9-dd11549acb61]
StackOverflow Post: [http://stackoverflow.com/questions/9102059/issue-with-code-contracts-on-generic-interface]
Still a great extension!
any way this will work with portable class libraries? i tried using reflector to copy the public 3.5 assemblies into a new PCL library, but that doesn't seem to help (i can reference the Contract class now, but the analysis doesn't seem to do anything)
I tried to install the extensions on Windows XP Professional German but i get an
Install Error : System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
On updating from 1.4.40314.1 to 1.4.40602.0 (the current version) I get the message "The installed version of 'Code Contracts Editor Extensions' is signed, but the update version is not signed. Therefore, the Extension Manager cannot install the update."
Can you sign the update?
I use a small font and the adornments are shown in a very large font. I could not find any setting anywhere to control the font used by the adornment.
Here is a screenshot: http://img820.imageshack.us/i/contractz.png/
Otherwise I like the tool!
Hmm, I thought we chose our font based on what was used for the code. I'll look into this and report back to you soon. Don't hesitate to poke me via email!