Code Contracts LiveTemplates for ReSharper
Blog Tuesday, June 08 2010When the Microsoft Code Contracts installer runs, it creates a bunch of really handy code snippets to speed up development. But if you have ReSharper installed, most of the snippets don't work because ReSharper's LiveTemplates feature overrides them.
The snippets installed by Microsoft Code Contracts are documented in the Code Contracts User Manual. My friend Stuart Leitch attended a Visual Studio 2010 Launch Event recently where he heard me speaking about Code Contracts. Stuart, after watching me fail to make "CR [tab] [tab]" expand to "Contract.Requires()" more than once decided that it would be good for me to have ReSharper LiveTemplates that match the original Code Contract snippets. So he built them and mailed them to me. Thanks, Stuart!
Download Stuart Leitch's Exported ReSharper LiveTemplates for Microsoft Code Contracts in C#
If you have ReSharper installed, you can import these templates by selecting the LiveTemplates... option from the ReSharper menu in Visual Studio. On the LiveTemplates manager dialog, highlight the User Templates section and click the Import button. Locate the XML file saved on your system from the link above. After installing Stuart's templates, you should see the shortcuts for the snippets outlined in the Code Contracts documentation:
Hooray! Now I just have to get used to hitting tab just once after typing the shortcuts. Thanks again, Stuart. Now, who wants to write the Visual Basic.NET snippets as ReSharper LiveTemplates?


