This is a really quick method to do a find and replace in VS2008 to replace your get/set properties to the new syntax, using regular expressions. You can even use this for C#2.0 targetted projects, the main requirement is the VS2008 (or msbuild.exe from framework 3.5).
If you have a few of these style property declarations:
private int _foo;
public int Foo
{
get
{
return _foo;
}
set
{
_foo = value;
}
}
and you want to change them to
public int Foo { get; set; }
you can make use of the VS Find and Replace dialog. In the "Find Options" group, check the "Use" box, and select "Regular Expressions".
The search pattern is:
UPDATED 2008/01/23: Minor mistake with the last get/set in a class
\n[:b\n]+\{[:b\n]+get[:b\n\{:a;_]+return[:b\n:a;\}_$()]+set[:b\n\{:a;=_$()]+value[);]+([:b\n]+\})^2
and the replace text is:
{ get; set; }
The regular expression will skip any get/set properties that have extra code (except brackets/spacing). Once these have been replace, you can remove the unused private variables, or use ReSharper to remove them for you :)