icsharpcode/CodeConverter

VB -> C#: ByRef temporary variable is assigned back into a constant

TymurGubayev opened this issue · 1 comments

VB.Net input code

Public Class ByRefConstArgument
    Public Const i As Integer = 0

    Public Sub M(ByRef o As Object)
        M(i)
    End Sub
End Class

Erroneous output

public class ByRefConstArgument
{
    public const int i = 0;

    public void M(ref object o)
    {
        object argo = i;
        M(ref argo);
        ByRefConstArgument.i = Conversions.ToInteger(argo); // can't do this
    }
}

Expected output

public class ByRefConstArgument
{
    public const int i = 0;

    public void M(ref object o)
    {
        object argo = i;
        M(ref argo);
    }
}

Details

  • Product in use: VS extension
  • Version in use: 95cec96
  • Did you see it working in a previous version, which? No
  • Any other relevant information to the issue, or your interest in contributing a fix.

fixed in #1120