Carl Bergquist
Carl Bergquist

Reputation: 3942

Can I change the way ReSharper generates properties?

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; }
}

Upvotes: 8

Views: 1798

Answers (2)

Rob Fonseca-Ensor
Rob Fonseca-Ensor

Reputation: 15621

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

Updated for Resharper 8.2: Resharper > Options > Code Editing > C# > Formatting Style > Line Breaks and Wrapping > Other > Place simple property/indexer/event declaration on single line

Upvotes: 11

LBushkin
LBushkin

Reputation: 131806

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.

Upvotes: 2

Related Questions