When invoking a method: optionally automatically fill in all arguments & create local variables for them.

As the architecture in our C# code-base develops, method-calls are growing in size.

Initially we had simple methods like

someObject.SomeMethod(int someNumber, double someDouble);

Now we can have 20 or 30 arguments in a method call.

So we then have to fill in numerous argument-names by hand and create local variables for them all.

This is laborious and can easily be automated.

I would really like it if there was some hotkey or lightbulb option for "Fill in method arguments & create local variables".

So I would type

someObject.SomeMethod(); // fails to compile, as no arguments given

and then when the hotkey/lightbulb was used it would expand to:

// variables created
string someString = ; // no value given, so it won't compile until completed
int someInteger = ; // ditto
double someDouble = ; // ditto
decimal theLastArgumment ; // ditto - maybe the 30th argument variable

// method now has arguments in place
someObject.SomeMethod(someString, someInteger, someDouble, ... , theLastArgument);

Like this, but on steroids: https://devblogs.microsoft.com/visualstudio/argument-completion-made-easy-with-visual-studio-intellicode/

This would save lots of time and enable developers to focus on business logic rather than boilerplate.

I suspect it would be quite easy, too.

What does the community think?

1 comment
Comment actions Permalink
Official comment



Currently, we have a quick-fix "Generate argument stubs" which is available when cursor is set inside parentheses. There's also an option to introduce variable for each method parameter by applying "Introduce refactoring" for each of generated method arguments.

I've filed a feature request which describes an option of combining both of these features into one quick-fix -  https://youtrack.jetbrains.com/issue/RSRP-481301

You are welcome to comment or vote for it.

Thank you.

Please sign in to leave a comment.