Create an overloaded delegate quickly
March 23rd, 2008 by jpennalSometimes it is necessary to create method overloads that just pass default values to other overloads. ReSharper allows you to do this quickly and easily.
Take this simple method for example:

We need to take the CreateUser method and add a new parameter to it. However, we also need to keep the old CreateUser method signature around for other code that still uses that version of the method signature. Using ReSharper’s Change Signiture (Control-F6) feature will allow us to create an overloaded method to solve our problem.

When the Change Signature dialog opens for this method, we will go ahead and add our new email parameter to this method.

In the above screenshot, notice the option “Delegate via overloading method” circled in red. Clicking this box is what will take the signature changes and turn them into a new overloaded method.
When the changes are ready, clicking Next in the Change Signature dialog will now produce the following code.

Notice that in the SaveNewUser method, the original method signature remains intact, but it is now delegated through an overloaded method. The CreateUser method now has two overloaded variations, the delegating method and the main method, where we can now add code to handle the new email parameter.
Jeff Pennal
JetBrains .NET Evangelist
March 25th, 2008 at 6:28 pm
“Delegate” seems like a poor choice of works for something that generates .NET code but has nothing to do with a .NET delegate.
“Create new CreateUser overload and call selected CreateUser” seems like it better describes what will happen without using the much overloaded word “delegate”.
April 2nd, 2008 at 12:15 am
What about creating overloaded metod by removing a parameter and calling old versions with default parameter value?
Last R# 4 builds create overload n wrong direction (as for me).