Skip to content

VB -> C#: Nullref in WinformsConversions.CreatePropertyAssignment #1242

@Posworx

Description

@Posworx

VB.Net input code

    Public Class UCCustomers

        Private Sub PictureBox1_Click(sender As Object, e As Global.System.EventArgs) Handles PictureBox1.Click
            Me.OpenCustomerPicker()
        End Sub

        Public Property MyCustomer As Global.PWLibrary.Customers.Customer

        Private Sub TextBox1_TextChanged(sender As Object, e As Global.System.EventArgs) Handles txtCustomer.MouseDoubleClick
            Me.OpenCustomerPicker()
        End Sub
        Public Sub OpenCustomerPicker()

            Using frmChooseCustomers As New Global.PWControls.frmChooseCustomers

                frmChooseCustomers.ShowDialog()
                Me.MyCustomer = frmChooseCustomers.MyCustomer
                Me.txtCustomer.[Text] = frmChooseCustomers.MyCustomer.Name & " " & frmChooseCustomers.MyCustomer.Surname
                Me.txtCustomer.Tag = frmChooseCustomers.MyCustomer.Number

            End Using
        End Sub
        Private Sub UCCustomers_Load(sender As Object, e As Global.System.EventArgs) Handles Me.Load

            If Not Global.Microsoft.VisualBasic.Information.IsNothing(Me.MyCustomer) Then
                Me.txtCustomer.[Text] = Me.MyCustomer.Name & " " & Me.MyCustomer.Surname
                Me.txtCustomer.Tag = Me.MyCustomer.Number
            Else
                Me.txtCustomer.PlaceholderText = "Search for customer"
            End If

        End Sub
    End Class

Erroneous output

    class _failedMemberConversionMarker1
    {
    }
#error Cannot convert ClassBlockSyntax - see comment for details
    /* Cannot convert ClassBlockSyntax, CONVERSION ERROR: Object reference not set to an instance of an object. in 'Public Class UCCustomers\r\...' at character 0
       at ICSharpCode.CodeConverter.CSharp.WinformsConversions.CreatePropertyAssignment(IdentifierNameSyntax id)
       at ICSharpCode.CodeConverter.CSharp.WinformsConversions.GetRequiredReassignmentOrNull(AssignmentStatementSyntax s)
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
       at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
       at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
       at ICSharpCode.CodeConverter.CSharp.DeclarationNodeVisitor.<>c__DisplayClass44_0.<ConvertMembersAsync>g__WithAdditionalMembers|0(IEnumerable`1 convertedMembers)
       at ICSharpCode.CodeConverter.CSharp.DeclarationNodeVisitor.<ConvertMembersAsync>d__44.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at ICSharpCode.CodeConverter.CSharp.DeclarationNodeVisitor.<VisitClassBlock>d__50.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at ICSharpCode.CodeConverter.CSharp.CommentConvertingVisitorWrapper.<ConvertHandledAsync>d__12`1.MoveNext()

Expected output

If relevant, the output you expected, or a description of what you expected.

Details

  • Product in use: e.g VS extension. 10.0.1.0
  • Version in use: 10.0.1.0
  • Did you see it working in a previous version, which? no,
  • Any other relevant information to the issue, or your interest in contributing a fix. It seems fail on the most basic conversations and works in alot of other conversions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good for coding agentCoding agent might get it in one - small change with reproVB -> C#Specific to VB -> C# conversion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions