开发者

Visual Studio/ReSharper: How to wrap long lines with commas before params?

开发者 https://www.devze.com 2023-01-16 05:12 出处:网络
I\'ve been customizing my formatting desires using ReSharper for code clean-up. So far I\'ve been able to make the clean-up rules match my coding style within:

I've been customizing my formatting desires using ReSharper for code clean-up. So far I've been able to make the clean-up rules match my coding style within:

     ReSharper -> Options -> Languages -> C# -> Formatting Style

One 开发者_运维技巧thing I haven't figured out how to do yet is how to have params/fields/list items wrap with leading commas instead of trailing commas.

Example of what I want:

var list = new List<string> {
    "apple"
    , "banana"
    , "orange"
};

Example of what I get currently:

var list = new List<string> {
    "apple",
    "banana",
    "orange"
};


(Not an answer, but this doesn't fit in a comment.)

The reason why some people prefer leading commas to trailing commas is because then it's not the last line that is slightly different from all the others, but the first one. This makes it neater to add new elements at the end.

However, C# allows you to place a comma even after the last element, so all lines look the same:

var list = new List<string> {
    "apple",
    "banana",
    "orange",
};


I asked JetBrains the same question. And they said that it is not possible in ReSharper 5 or 6.

I think I will just need to change my style a little bit then.

If you want the new ReSharper to have that capability, you can try this.


Seems you can do this in Resharper 2017

https://youtrack.jetbrains.com/issue/RSRP-380962#u=1485456634915

0

精彩评论

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