icsharpcode / CodeConverter

Convert code from C# to VB.NET and vice versa using Roslyn
https://icsharpcode.github.io/CodeConverter/
MIT License
842 stars 219 forks source link

VB -> C#: Unsigned integer hex constants are not converted correctly #1147

Closed gaschd closed 3 weeks ago

gaschd commented 3 weeks ago

Using hex constants of unsigned integer that exceed the maxvalue of integer values 2147483647 e.g. like 2242054355 are not converted correctly

VB.Net input code

Public Class TestClass
    Const GoodSmallHexUInt As UInteger = &H13198A2EUI
    Const GoodBigUInt As UInteger = 2242054355
    Const BadBigHexUInt As UInteger = &H85A308D3UI
End Class

Erroneous output

  public class TestClass
  {
      private const uint GoodSmallHexUInt = 0x13198A2EU;
      private const uint GoodBigUInt = 2242054355U;
      private const uint BadBigHexUInt = int.MinValue + 0x05A308D3;
  }

Expected output

    public class TestClass
  {
      private const uint GoodSmallHexUInt = 0x13198A2EU;
      private const uint GoodBigUInt = 2242054355U;
      private const uint BadBigHexUInt = 0x85A308D3U;
  }

Details

C# -> VB does not have this issue