Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VB -> C#: Variables not initialised #263

Closed
mrmonday opened this Issue Apr 5, 2019 · 0 comments

Comments

Projects
None yet
2 participants
@mrmonday
Copy link
Contributor

mrmonday commented Apr 5, 2019

Input code

Public Class Class1
    Sub Foo()
        Dim x As Integer

        Dim y = x
    End Sub
End Class

Erroneous output

public class Class1
{
    public void Foo()
    {
        int x;

        var y = x;
    }
}

Expected output

public class Class1
{
    public void Foo()
    {
        int x = 0;

        var y = x;
    }
}

Details

Product in use: e.g. VS extension

Version in use: e.g. 6.6.0

VB default initialises variables, where C# doesn't. This gives the following error:

CS0165	Use of unassigned local variable 'x'

mrmonday added a commit to mrmonday/CodeConverter that referenced this issue Apr 18, 2019

Ensure that local variables are initialized
Visual Basic default initialises local variables, where C# does not.
Ensure that these are initialized (if required) when converting.

Closes icsharpcode#263

@mrmonday mrmonday referenced this issue Apr 18, 2019

Merged

Ensure that local variables are initialized #285

2 of 2 tasks complete

GrahamTheCoder added a commit to mrmonday/CodeConverter that referenced this issue Apr 19, 2019

Ensure that local variables are initialized
Visual Basic default initialises local variables, where C# does not.
Ensure that these are initialized (if required) when converting.

Closes icsharpcode#263

# Conflicts:
#	Tests/CSharp/ExpressionTests.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.