Visual Studio and Interface property stubs

Last year, I posted a question on StackOverflow asking if it was possible to replace the property stubs for interface refactoring

Is it possible to change the stub used to implement interfaces in Visual Studio 2008?

For instance, when I choose either
Implement interface 'IMyInterface'
Explicitly implement interface 'IMyInterface'

Instead of a number of properties that look like this:

    public string Comment
            throw new NotImplementedException();
            throw new NotImplementedException();
I'd like my properties to use the C# 3.0 auto-implemented properties and look like this:

    public string Comment {get;set;}
I want to do this to avoid forcing this interface to be an abstract class.

I've looked through the snippets in the Visual Studio folder, but I didn't see any that would be appropriate. I've also googled and searched SO, and found nothing.

If this isn't possible, does anyone have a macro I can steal?


I then discovered that you can edit the file at:

[program files]\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Refactoring\PropertyStub.snippet

and modify the xml node ‘Code’ to contain the following:

<Code Language="csharp">
    <![CDATA[ $signature$ { $GetterAccessibility$ get; $SetterAccessibility$ set;} $end$]]>

I really wish this was the default for .NET 3.0 and higher (since auto-implemented properties have been around).

Related Articles