Change Procedure to Function Quick Fix

Adjusts a Sub procedure to be a Function procedure, and updates all usages.

This quick-fix is available for the ProcedureCanBeWrittenAsFunction inspection

Applicability

This quick-fix can be applied as a single operation at the following scopes:

Examples

 This example depicts the state of module(s) before and after applying the quick-fix.

Before
Module1 (Any)
Public Sub DoSomething() Dim value As Long GetValue value Debug.Print value End Sub Private Sub GetValue(ByRef value As Long) value = 42 End Sub
After
Module1 (Any)
Public Sub DoSomething() Dim value As Long value = GetValue(value) Debug.Print value End Sub Private Function GetValue(ByVal value As Long) As Long value = 42 GetValue = value End Function

Rubberduck.CodeAnalysis.QuickFixes.Concrete.ChangeProcedureToFunctionQuickFix.cs (Prerelease-v2.5.2.6174)