When the list of method arguments grows to such an extent that it doesn’t fit on one line, I like to format the code so that each argument is on a separate line (as suggested by StyleCop), for example:
public void MyMethod( int someArgument, double someOtherArgument, int someMoreArguments)
The problem I am facing is that this formatting is “fragile” and cannot be reformatted automatically when using Ctrl + K + D. For example, if I manage to insert some spaces before one of the arguments, it will not be deleted, and I end up doing tedious manual formatting. If I copy a method (for example, to provide an overloaded signature), the indentation of the argument in the copy becomes completely messy.
I have a similar problem with LINQ statements, which I also like to format on multiple lines, for example:
myEnumerable. .Where(this and that) .Where(this and that) .FirstOrDefault();
I understand that this is full obsessive-compulsive formatting and a very minor problem, but is there a way to make Visual Studio 2010 automatically drag multi-line arguments following this pattern when it shifts?
source share