Usability, MVC, ASP.NET

16. March 2008 01:34
by Henrik Stenbæk
2 Comments

The prop snippet and Visual Studio 2008

16. March 2008 01:34 by Henrik Stenbæk | 2 Comments

In Visual Studio 2005 typing "prop[tab][tab]" will give you something like this:

vs2005

This is fine and one of the most time saving code snippets ever invented. If one type the same in Visual Studio 2008 it's ends out a little different:

vs2008

This is due to the new Automatic Properties Feature in .NET 3.0/VS 2008. This is somehow also fine as long as one don't want to maintain a .NET 2.0 project with VS 2008, doing this will end up with an compile time error saying:".. must declare a body because it is not marked abstract or extern"

must declare a body because it is not marked abstract or extern

A solution to this is to download this file:

prop.zip (604,00 bytes)

place in your "My Code Snippets" folder:

C:\users\*your user name*\Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets

Now you can simply type propp[tab][tab] in Visual Studio 2008 and get the VS 2005 style property snippet. Why propp? After typing porp your finger is over the [p] button so I thought it would be the fastest solution. If you don't like it: open the prop.snippet file with Visual Studio or any text editor and edit the shortcut tag:

<Shortcut>propp</Shortcut>

Comments

  1. Martin H&#248;st Normark

    I actually hate that they replaced the code produced by the prop snippet with the new Dynamic Properties. If you work on a .Net 2.0 project, you won't be able to use them.

    So a replacement is a must!

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading