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 of arrays not initialised correctly #364

Closed
mrmonday opened this issue Aug 21, 2019 · 1 comment
Closed

VB -> C#: Array of arrays not initialised correctly #364

mrmonday opened this issue Aug 21, 2019 · 1 comment
Assignees
Labels
output logic error A bug where the converted output behaves differently to the input code VB -> C# Specific to VB -> C# conversion

Comments

@mrmonday
Copy link
Contributor

Input code

Module Module1
    Sub Main()
        Dim ls As New ArrayList(5)
        Dim s(ls.Count - 1)() As String
        For i As Integer = 0 To ls.Count - 1
            ReDim s(i)(1)
        Next
    End Sub
End Module

Erroneous output

using System.Collections;

namespace ConsoleApp10
{
    static class Module1
    {
        public static void Main()
        {
            ArrayList ls = new ArrayList(5);
            string[][] s = default(string[][]);
            for (int i = 0, loopTo = ls.Count - 1; i <= loopTo; i++)
                s[i] = new string[2];
        }
    }
}

Expected output

using System.Collections;

namespace ConsoleApp10
{
    static class Module1
    {
        public static void Main()
        {
            ArrayList ls = new ArrayList(5);
            string[][] s = new string[ls.Count][];
            for (int i = 0, loopTo = ls.Count - 1; i <= loopTo; i++)
                s[i] = new string[2];
        }
    }
}

Worth double checking this - I haven't tested it, there's more than a good chance of an off-by-one here or similar.

Details

Version in use: master @ 2483369

@GrahamTheCoder GrahamTheCoder added output logic error A bug where the converted output behaves differently to the input code VB -> C# Specific to VB -> C# conversion labels Aug 21, 2019
@GrahamTheCoder
Copy link
Member

I think this relates to the issue I mentioned on #355. Let's track it here, Here's the related testcase:
https://github.com/icsharpcode/CodeConverter/compare/355/related-test?expand=1#diff-ab8f9b4966dbff4521cf21456fd2985fR559

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
output logic error A bug where the converted output behaves differently to the input code VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

2 participants