Reporter | Alexander Shvedov (shvedov) |
---|---|
Created | Apr 6, 2012 3:02:53 AM |
Updated | Apr 6, 2012 3:02:53 AM |
Priority | Major |
Type | Bug |
Fix versions | No Fix versions |
State | Submitted |
Assignee | Dmitry Ivanov (daivanov) |
Subsystem | Refactoring |
Affected versions | 7.0 Preview |
Fixed in build | No Fixed in build |
Module Module1 Sub Main() Dim x = 12 Foo(x) Foo(x) Console.WriteLine(x) ' <~ prints 14 End Sub Sub Foo(ByRef x As Integer) x = x + 1 End Sub End Module
After:
Module Module1 Sub Main() Dim x = 12 x = Foo() x = Foo() Console.WriteLine(x) ' <~ prints 1 End Sub Function Foo() As Integer Dim x As Integer x = x + 1 Return x End Function End Module
VB.NET ByRef parameters are equal to C# ref-parameters, not out-parameters (they are not presented in VB.NET at all). So it's not possible to use the same C# technique to transform ByRef parameters (only when ByRef parameter has no any of read usages before return value assignment).
I think it's possible to extend refactoring to support ByRef-parameters (and in C# version too), simply by turning them into ByVal parameters when needed.