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#: Array initialization adds wrong curly brackets. #355

Closed
fabienDaou opened this issue Aug 14, 2019 · 4 comments
Closed

VB -> C#: Array initialization adds wrong curly brackets. #355

fabienDaou opened this issue Aug 14, 2019 · 4 comments
Labels
compilation error A bug where the converted output won't compile VB -> C# Specific to VB -> C# conversion

Comments

@fabienDaou
Copy link
Contributor

fabienDaou commented Aug 14, 2019

Array initialization adds wrong curly brackets. This results in a compilation error.

Input code

Public Class VisualBasicClass
  Public Sub Stuff()
    Dim strs = New String(2) {}
  End Sub
End Class

Erroneous output

public class VisualBasicClass
{
    public void Stuff()
    {
        var strs = new string[3] { }; // Error: An array initializer of length '3' is expected
    }
}

Expected output

public class VisualBasicClass
{
    public void Stuff()
    {
        var strs = new string[3];
    }
}

Details

Product in use: e.g. both
Version in use: e.g. 7.0.0.0

@GrahamTheCoder GrahamTheCoder added compilation error A bug where the converted output won't compile VB -> C# Specific to VB -> C# conversion labels Aug 14, 2019
@fabienDaou
Copy link
Contributor Author

Looking at this one, seems pretty easy.

@GrahamTheCoder
Copy link
Member

Thanks!

I found a test case that's broken, but it's not 100% related and I wanted to get your branch merged since I think it's an improvement already. Here's the test case if you're interested: https://github.com/icsharpcode/CodeConverter/compare/355/related-test?expand=1#diff-ab8f9b4966dbff4521cf21456fd2985fR559

@fabienDaou
Copy link
Contributor Author

Ok I was not aware about this syntax, I'll provide a PR with a fix.

@GrahamTheCoder
Copy link
Member

Closing this issue since your fix covered it and #364 covers the related part I mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compilation error A bug where the converted output won't compile VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

2 participants