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#: *.Designer.vb files not converted #133

Closed
jhonzah opened this issue Jun 23, 2018 · 1 comment
Closed

VB -> C#: *.Designer.vb files not converted #133

jhonzah opened this issue Jun 23, 2018 · 1 comment

Comments

@jhonzah
Copy link

jhonzah commented Jun 23, 2018

When I try to convert from VB to C# a whole winforms project none of the Designer.vb files are converted.
When I try to convert Form1.Designer.vb file I get a System.NullReferenceException.

Input code

Form1.Designer.vb

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(289, 147)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(75, 23)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Button1"
        Me.Button1.UseVisualStyleBackColor = True
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(800, 450)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

    Friend WithEvents Button1 As Button
End Class

Erroneous output

Writing converted files to disk:
* Failure processing Form1.Designer.vb
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxNodeRemover.SyntaxRemover.<>c.<.ctor>b__5_0(SyntaxNode n)
       at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
       at Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxNodeRemover.SyntaxRemover..ctor(SyntaxNode[] nodesToRemove, SyntaxRemoveOptions options)
       at Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxNodeRemover.RemoveNodes[TRoot](TRoot root, IEnumerable`1 nodes, SyntaxRemoveOptions options)
       at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode.RemoveNodesCore(IEnumerable`1 nodes, SyntaxRemoveOptions options)
       at Microsoft.CodeAnalysis.SyntaxNodeExtensions.RemoveNodes[TRoot](TRoot root, IEnumerable`1 nodes, SyntaxRemoveOptions options)
       at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.VisitFieldDeclaration(FieldDeclarationSyntax node)
       at Microsoft.CodeAnalysis.VisualBasic.Syntax.FieldDeclarationSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
       at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
       at ICSharpCode.CodeConverter.CSharp.CommentConvertingNodesVisitor.DefaultVisit(SyntaxNode node)
       at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.VisitFieldDeclaration(FieldDeclarationSyntax node)
       at Microsoft.CodeAnalysis.VisualBasic.Syntax.FieldDeclarationSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
       at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.<>c__DisplayClass27_0.<<ConvertMembers>g__ConvertMembersInner|0>d.MoveNext()
       at Microsoft.CodeAnalysis.SyntaxList`1.CreateNode(IEnumerable`1 nodes)
       at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.VisitClassBlock(ClassBlockSyntax node)
       at Microsoft.CodeAnalysis.VisualBasic.Syntax.ClassBlockSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
       at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
       at ICSharpCode.CodeConverter.CSharp.CommentConvertingNodesVisitor.WithPortedTrivia[TSource,TDest](SyntaxNode node, Func`3 portExtraTrivia)
       at ICSharpCode.CodeConverter.CSharp.CommentConvertingNodesVisitor.VisitClassBlock(ClassBlockSyntax node)
       at Microsoft.CodeAnalysis.VisualBasic.Syntax.ClassBlockSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
       at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.<VisitCompilationUnit>b__24_3(StatementSyntax m)
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at Microsoft.CodeAnalysis.SyntaxList`1.CreateNode(IEnumerable`1 nodes)
       at Microsoft.CodeAnalysis.SyntaxList`1..ctor(IEnumerable`1 nodes)
       at Microsoft.CodeAnalysis.CSharp.SyntaxFactory.List[TNode](IEnumerable`1 nodes)
       at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.VisitCompilationUnit(CompilationUnitSyntax node)
       at Microsoft.CodeAnalysis.VisualBasic.Syntax.CompilationUnitSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
       at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
       at ICSharpCode.CodeConverter.CSharp.CommentConvertingNodesVisitor.DefaultVisit(SyntaxNode node)
       at ICSharpCode.CodeConverter.CSharp.CommentConvertingNodesVisitor.VisitCompilationUnit(CompilationUnitSyntax node)
       at Microsoft.CodeAnalysis.VisualBasic.Syntax.CompilationUnitSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
       at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.ConvertCompilationTree(VisualBasicCompilation compilation, VisualBasicSyntaxTree tree)
       at ICSharpCode.CodeConverter.CSharp.VBToCSConversion.SingleFirstPass(Compilation sourceCompilation, SyntaxTree tree)
       at ICSharpCode.CodeConverter.Shared.ProjectConversion.SingleFirstPass(SyntaxTree tree, String treeFilePath)
       at ICSharpCode.CodeConverter.Shared.ProjectConversion.FirstPass()
    

Code conversion failed with 1 error

Details

Product in use: VS 2017 Community version 15.7.4, VS extension 5.7.0.0

Last working version of VS extension: 5.6.3.0

@GrahamTheCoder
Copy link
Member

I believe #134 covered the same error message from this and is now fixed.
#132 covers failure to convert files within a project, so let's move any further discussion to those issues. If you could check the latest build of master that'd be useful since I can't repro and #134 may be the root cause of #132.
Thanks for the issue report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants