New CodeRush Plugin – CR_CorrectReturnType

In my previous post I was extolling the virtues of Convert to Function.

You’ll recall that it is used to alter the return type of the current function, from void to the value of the expression on the return statement at the caret.

MethodReturningIEnumerableInt

Well what if you have a pre-existing function which returns a string, and you need to alter the function to return an int.

Convert to Function is only available if the method is of type void. It is not available if the function returns anything else.

Enter CR_CorrectReturnType

My latest plugin, Correct Return Type provides the same functionality as Convert to Function, however it works where Convert to Function does not.

If the active function’s return type is non-void, and differs from that of the return statement at the caret, then Correct Return Type will become available instead of Convert to Function.

CorrectReturnType

Availability

As usual this plugin is available from both the Visual Studio Gallery and from GitHub.

The source code is available on GitHub.

no comments
No Comments

Please login or register to post comments.