tags:

views:

79

answers:

2

Is it possible to change the way that Resharper formats properties?

I don't like:

public string Foo 
{
    get 
    {
        return bar;
    }
    set 
    {
        bar = value;
    }
}

I like:

public string Foo 
{
    get { return bar; }
    set { bar = value; }
}
+1  A: 

If you're using the code expansion template to produce a property, you can update the template in the ReSharper Settings at: ReSharper >> Live Templates >> Predefined Templates >> C# >> prop.

If you're referring to the code produced by refactoring commands, I don't believe it's configurable. However, you may be able to run Code Cleanup and have it reformat.

LBushkin
+2  A: 

You sure can, just go to Resharper > Options > Languages > C# > Formatting Style and tick "place simple property/indexer/event declaration on a single line"

Rob Fonseca-Ensor
Thanks for the hint :) Although in 4.5 its ReSharper > Options -> Languages > C# > Formating Style > Line Breaks and Wrapping > Other > Place simple accessor on single line.
Carl Bergquist

related questions