开发者

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 
    {
      开发者_JAVA技巧  return bar;
    }
    set 
    {
        bar = value;
    }
}

I like:

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜