8

I wish to transform code like:

var p = new Person("Ian", "Smith", 40, 16)

To:

var p = new Person(surname: "Ian", givenName:"Smith", weight:40, age:16)

As a first step in making the code more readable, I am willing to use a 3rd party refactoring tool if need be.

(Please do not tell me to use parameter objects and factor methods etc, these may come later once I can at least read the code!)

Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317
  • Just to clarify: You are looking for a tool that automatically changes your method calls to use named parameters? – Daniel Hilgarth Apr 05 '11 at 10:15
  • @Ian: automatically for all method calls inside your project? Or is it ok, to manually choose which method calls should be changed? – Daniel Hilgarth Apr 05 '11 at 10:43
  • @Daniel, I need to manually choosse the method calls to change. – Ian Ringrose Apr 05 '11 at 10:44
  • There is a regular expersion in VS you can use it and do it with find and replace, I'm not excellent at this but if is important for you can see msdn to learn how to use it. – Saeed Amiri Apr 05 '11 at 10:52
  • @Saeed, if only it was that easy, there are many overloads to the method and it is not clear the one the compiler chooses, so I need a tool that **will get it right every time**. – Ian Ringrose Apr 05 '11 at 10:53
  • 1
    @Ian: Is it an option to code something yourself? http://confluence.jetbrains.net/display/ReSharper/Quick-Fixes+and+Context+Actions and http://hadihariri.com/2010/01/12/writing-plug-ins-for-resharper-part-1-of-undefined/ – Daniel Hilgarth Apr 05 '11 at 10:58
  • @Daniel, coding it myself it unlickly to be an option as it will only take a day or so to change them by hand (until next time...) – Ian Ringrose Apr 05 '11 at 11:00
  • 1
    @Ian: IMHO, coding it yourself doesn't take much longer with the Resharper OpenAPI but it is so much more fun than changing it by hand! :-) – Daniel Hilgarth Apr 05 '11 at 11:02

2 Answers2

2

place cursor in parentheses of method call

alt+<enter>

or click on hammer

  • before

enter image description here

  • after

enter image description here

Chris Hayes
  • 3,876
  • 7
  • 42
  • 72
2

Refactor v2001 vol 1.3 claims to be able to do it.

ReSharper has it in it's issues database, but have not commited doing it yet.

Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317