1

When reordering arguments in a function signature, callers do not get updated (unless specifically using the Change signature method in Resharper) and continue to compile fine with the old order. This is not a problem semantically but may look a bit messy when many callers end up having different argument orders.

Is there any way with Resharper - or any other tool - to automatically reorder named parameters solutionwide so that they can perfectly match the function signature?

This seems like a nice refactoring function that would make the code look more consistent, and to which I don't see any possible side effect or negative aspect, much like standardizing other cosmetic aspects across a solutions.

3
  • Have you tried the "Change signature" refactor option on the method name? It will fix callers, as long as callers are in the same solution. Commented Oct 18, 2013 at 6:50
  • I know, but I am looking for a way to do this automatically for all functions in the solutions, which would take time if I had to do it manually (thousands of functions spread across many files). Commented Oct 18, 2013 at 6:53
  • @LasseV.Karlsen obviously he has, since it's right there in the post. Commented Oct 18, 2013 at 6:53

1 Answer 1

1

Might have some drawbacks too:

Ordering of parameters often conveys information to the developer: it might show some logical grouping of information, e.g.

 Foo(foo: 3,
     zyx: "hello",
     flurb: null,    // these 3 from the config file

     val: 42);       // from the input xml
Sign up to request clarification or add additional context in comments.

2 Comments

Why would it be a bad idea to ensure callers use named arguments in the same order as in the original function signature? I am not talking about renaming parameters per se, if this is what you feared. Thanks for the 2 suggestions though.
Would you believe I missed that in the title? Anyways, edited

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.