开发者

Can I change the way ReSharper generates properties?

开发者 https://www.devze.com 2022-12-10 15:52 出处:网络
Is it possible to change the way that Resharper formats properties? I don\'t like: public string Foo { get

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

精彩评论

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