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#: Conversion error with missing variable #259

Open
mrmonday opened this Issue Apr 5, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@mrmonday
Copy link
Contributor

mrmonday commented Apr 5, 2019

Input code

Public Class Class1
    Sub Foo()
        For Me.Index = 0 To 10

        Next
    End Sub
End Class

Erroneous output

public class Class1
{
    public void Foo()
    {
        ;/* Cannot convert ForBlockSyntax, System.NullReferenceException: Object reference not set to an instance of an object.
   at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.MethodBodyVisitor.VisitForBlock(ForBlockSyntax node)
   at Microsoft.CodeAnalysis.VisualBasic.Syntax.ForBlockSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
   at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
   at ICSharpCode.CodeConverter.CSharp.CommentConvertingMethodBodyVisitor.ConvertWithTrivia(SyntaxNode node)
   at ICSharpCode.CodeConverter.CSharp.CommentConvertingMethodBodyVisitor.DefaultVisit(SyntaxNode node)

Input: 
        For Me.Index = 0 To 10

        Next

 */
    }
}

Expected output

public class Class1
{
    public void Foo()
    {
        for (var this.Index = 0; Index <= 10; Index++)
        {
        }
    }
}

Details

Product in use: VS extension

Version in use: 6.6.0

The tool should be able to convert the for loop, even with the missing variable defintion.

@GrahamTheCoder

This comment has been minimized.

Copy link
Member

GrahamTheCoder commented Apr 8, 2019

Hopefully just a case of not dealing with member access expressions properly

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.