CodeConverter icon indicating copy to clipboard operation
CodeConverter copied to clipboard

VB -> C#: `GetType(Nullable(Of))` is not handled correctly

Open jswolf19 opened this issue 11 months ago • 2 comments

VB.Net input code

Public Class Test
    Public Function IsNullable(ByVal type As Type) As Boolean
        Return type.IsGenericType AndAlso type.GetGenericTypeDefinition() Is GetType(Nullable(Of))
    End Function
End Class

Erroneous output

public class Test {
    public bool IsNullable(Type @type) {
        return type.IsGenericType && ReferenceEquals(type.GetGenericTypeDefinition(), typeof(object));
    }
}

Expected output

public class Test {
    public bool IsNullable(Type @type) {
        return type.IsGenericType && ReferenceEquals(type.GetGenericTypeDefinition(), typeof(Nullable<>));
    }
}

Details

  • Product in use: VS extension
  • Version in use: 9.2.6.0

jswolf19 avatar Jan 09 '25 23:01 jswolf19

Working on this, just about have it figured out. Well, my fix is working, but I don’t understand what’s happening with the test. The test is getting an unexpected using statement. Also, the fix is too narrow, doubt it works with multiple open generic parameters.

jrmoreno1 avatar Jul 29 '25 10:07 jrmoreno1

@jrmoreno1 Thanks for working on this!

I don't know how much help I can be, but if you point me to some code to look at, I'll be happy to try to help.

jswolf19 avatar Jul 29 '25 11:07 jswolf19