10

Say there is a method,

void M(int a, int b, int c /* and many more */)

Is there a way to transform M() to M(a: .., b: .., c: ..) at the call-site?

I am using Visual Studio 2013 (Ultimate) 2017 Professional with ReSharper 8 ReSharper 2018.1. A built-in solution (or extension if such is required) that utilized either would be suitable.

This is similar to Is there any tools to help me refactor a method call from using position-based to name-based parameters, although I expect to start with no arguments; and am asking the question 4 years later.

user2864740
  • 60,010
  • 15
  • 145
  • 220
  • 1
    I'm not entirely sure what you're asking here, but if you just want M(a,b,c,...) to be generated for you... I don't know of a one-shot solution but you could just f12 into the method,copy the signature, CTRL - back to the line you were on, paste, select the method signature, and then quick replace int with ": " – Andy Isbell Nov 21 '15 at 07:30

2 Answers2

1

Resharper can do this for you https://www.jetbrains.com/help/resharper/Argument_Style.html

Alexandre
  • 7,004
  • 5
  • 54
  • 72
  • Nice. Just verified it too! This support was added at some more recent than the question (it exists in ReSharper 2018.1, not sure when it was added)- and it's a nice [new] feature to know about! – user2864740 Oct 31 '18 at 02:24
0

Not sure if I fully understand your requirement.

You could use a T4Template and generate a partial class with said method arguments. Other than that I can only see a params parameter working but this would not solve the named parameter issue.

Telimaktar
  • 31
  • 2