Let's say you have a signature like so:
public void MyFooBar(IExtraSuperLongTypeName param1, TypeA param2 ISomeotherReallyLongTypeName param3, TypeB param4, TypeC param5)
Formatting in on one line is ugly and hard to read. A style that resharper uses to format this is to push the parameters down like so
public void MyFooBar(IExtraSuperLongTypeName param1, TypeA param2,
ISomeotherReallyLongTypeName param3, TypeB param4, TypeC param5)
But I still find that hard to immediately interpret what the parameters are.
I have also seen this approach used:
public void MyFooBar(IExtraSuperLongTypeName param1,
TypeA param2,
ISomeotherReallyLongTypeName param3,
TypeB param4,
TypeC param5)
I find this much easir to read, but I'm not a fan of having all that white space in the way, and I don't like how the spacing of the whitespace may not match the tab size exactly. Additionally, if you method name is exceeding long, it can still push the parameters too far to the right.
I have thought of another way to format code like so:
public void MyFooBar
(
IExtraSuperLongTypeName param1,
TypeA param2,
ISomeotherReallyLongTypeName param3,
TypeB param4,
TypeC param5
)
To me, this is easy to read and doesn't suffer from the disadvantages of the above approach. Can anyone see any issues with the above method of formatting code? If I can't find any reasons not to write functions that way, I'll start using it in my projects for long method signatures. The same approach can be made to function calls, eg:
MyFooBar myFooBar = MyFooBar
(
arg1,
arg2,
arg3,
arg4,
arg5
);