Method arguments are aligned on the left
Hello, I use VS2015 and R# 2017.1. I set the following parameters to the C# Formatting style:
"Line wrapping"->"Wrap long lines" = TRUE
"Line wrapping"->"Right margin (columns)" = 135
"Line wrapping"->"Wrap format parameters" = "Chop if long or multiline"
"Line wrapping"->"Prefer wrap after ( in declaration" = FALSE
Link to setting file
I have such code:
(code 1)
public static void AddOrRemoveOrUpdate<TItem, TNewItem, TKey>(this ICollection<TItem> collection, IEnumerable<TNewItem> newItems, Func<TItem, TKey> getItemKey, Func<TNewItem, TKey> getNewItemKey, Func<TNewItem, TItem> getItem, UpdateDelegate<TItem, TNewItem> updateItem, IEqualityComparer<TKey> comparer = null) {
//code
}
Max width of line is 114 symbols. After "reformat code" I get such result (code 2):
(code 2)
public static void AddOrRemoveOrUpdate<TItem, TNewItem, TKey>( this ICollection<TItem> collection, IEnumerable<TNewItem> newItems, Func<TItem, TKey> getItemKey, Func<TNewItem, TKey> getNewItemKey, Func<TNewItem, TItem> getItem, UpdateDelegate<TItem, TNewItem> updateItem, IEqualityComparer<TKey> comparer = null)
{
//code
}
I want to my code will not been changed after "reformat code"
If I change setting:
"Line wrapping"->"Right margin (columns)" = 140
OR
"Line wrapping"->"Wrap format parameters" = "Chop always"
....then I get original code (code 1) as result after "reformat code"
Where did I mistaken? Tell me, please, what parameter I have to change?
Please sign in to leave a comment.
Hello Egor
Thank you for your valuable feedback!
Wrapping engine that was used in 2016.3 and earlier versions often produced a bad formatting because alignment was too far to the right, for example see https://youtrack.jetbrains.com/issue/RSRP-226622. In 2017.1 new wrapping engine penalizes alignments that take more than half of the wrapping limit, preferring early wrap. Unfortunately, this behaviour leads to problems in your case. We'll try to fix them in the future, but no exact estimations. You can follow https://youtrack.jetbrains.com/issue/RSRP-464310 track the progress. Right now you can turn on either "Keep existing line breaks" option or "Revert to old formatting engine" option in ReSharper | Options | Code Editing | C# | Formatting Style | Other | Other.
Thanks!
"Revert to old formatting engine" option has this bug and I cannot use it) At this moment I switch following setting:
"Wrap format parameters" = "Chop always"
And it saves code to be good-looking (If don't watch that all arguments are wrapped every time).
Thank you, Alexander. Waiting for the next version of R#)