Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

C# -> VB: Case with GetType converted to string #583

Closed
marcal opened this issue Jun 28, 2020 · 0 comments
Closed

C# -> VB: Case with GetType converted to string #583

marcal opened this issue Jun 28, 2020 · 0 comments
Labels
VB -> C# Specific to VB -> C# conversion

Comments

@marcal
Copy link

marcal commented Jun 28, 2020

Hello,
Sorry, it is a VB-> C# case
I have made a test with the last version (the "Beta" to test if the previous problems were solved and I saw a new problem.
Thank you

Input code

Private Sub Test3(CurRow As DataRow)
For Each CurCol As DataColumn In CurRow.GetColumnsInError
If IsDBNull(CurRow.Item(CurCol)) Then
Select Case CurCol.DataType
Case GetType(String)
CurRow.Item(CurCol) = String.Empty
Case Else
CurRow.Item(CurCol) = 0
End Select
CurRow.ClearErrors()
End If
Next
End Sub


### Erroneous output
```C#
private void Test3(DataRow CurRow)
        {
            foreach (DataColumn CurCol in CurRow.GetColumnsInError())
            {
                if (Information.IsDBNull(CurRow[CurCol]))
                {
                    switch (CurCol.DataType)
                    {
                        case var @case when CultureInfo.CurrentCulture.CompareInfo.Compare(@case, new string(typeof(string) ?? new char[0]), CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth) == 0:
                            {
                                CurRow[CurCol] = string.Empty;
                                break;
                            }

                        default:
                            {
                                CurRow[CurCol] = 0;
                                break;
                            }
                    }

                    CurRow.ClearErrors();
                }
            }
        }

Expected output

private void Test3(DataRow CurRow)
        {
            foreach (DataColumn CurCol in CurRow.GetColumnsInError())
            {
                if (Information.IsDBNull(CurRow[CurCol]))
                {
                    switch (CurCol.DataType)
                    {
                        case var @case when @case==typeof(string) :
                            {
                                CurRow[CurCol] = string.Empty;
                                break;
                            }

                        default:
                            {
                                CurRow[CurCol] = 0;
                                break;
                            }
                    }

                    CurRow.ClearErrors();
                }
            }
        }

Details

I use the last version (the "Beta version" that is built as it is more recent than the one in Visual Studio
It is working in the old version. I think that it is because of the correction #579.

@marcal marcal added the VB -> C# Specific to VB -> C# conversion label Jun 28, 2020
@marcal marcal closed this as completed Jun 28, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

1 participant