Skip to content

'TernaryOperatorWithAddignmentCodeFixProvider' encountered and error #496

@paul1956

Description

@paul1956

This happens a lot and I have a small test case that does it every time.

    Private Class MyCustomer
        Public Property Value As String
    End Class
    Public Class ExcelLineRecordClass
        Public Property LineNumber As Integer
        Public Property imported As Boolean
    End Class
        Dim ExcelRecord As New ExcelLineRecordClass
        Dim lCell As New MyCustomer
        If lCell Is Nothing Then
            ExcelRecord.imported = False
        Else
            ExcelRecord.imported = If(Debugger.IsAttached, lCell.Value.ToString = "X" Or lCell.Value.ToString = "Y", lCell.Value.ToString = "Y")
        End If

When you try to preview turning the if into a Ternary, it crashes. There are a lot of other case where it also fails but they all seem to involve a class. The following works

        Dim ExcelRecord As Boolean
        Dim lCell As New MyCustomer
        If lCell Is Nothing Then
            ExcelRecord = False
        Else
            ExcelRecord = If(Debugger.IsAttached, lCell.Value.ToString = "X" Or lCell.Value.ToString = "Y", lCell.Value.ToString = "Y")
        End If

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions