views:

51

answers:

1

In Visual Studio 2010, is it possible to change the default template used when implementing an interface?

I would like to change the implementation of properties from

public int MyProperty
{
    get
    {
        throw new NotImplementedException();
    }
    set
    {
        throw new NotImplementedException();
    }
}

to

public int MyProperty { get; set; }

Edit

so i tried to Edit PropertyStub.snippet but to no avail, it didn't change anything...

I found this question Changing property stubs for interface refactoring which says that ReSharper is the only way.

Anyone able to make this work, with example, cause the change i made did not seem to have any effects

+1  A: 

Yes it is possible to change this template. The C# IDE uses templates for the majority of it's code generation and the IDE. You can update these templates to control the code generation process. They are located in the following directory

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Refactoring

Note: The " (X86)" portion will be abscent on 32 bit machines.

For this particular situation you want to change the PropertyStub.snippet file.

JaredPar
Well I Tried but it didn't work... any requirement for this to work?
moi_meme
@moi_meme, did you restart VS?
JaredPar
Yes I did, many times... I tried just adding a contant and nothing changed... do yoou have a working example?
moi_meme