CodeConverter icon indicating copy to clipboard operation
CodeConverter copied to clipboard

VB -> C#: wrong conversation of hex constants

Open KunzeAndreas opened this issue 4 years ago • 3 comments

VB.Net input code

Const value = &HFFFFFFFF value.Should.Be.EqualTo(-1)

Erroneous output

const int value = 0xFFFFFFFF; this doesn't compile (cannot convert uint to int)

Expected output

var value = int.Parse("FFFFFFFF", System.Globalization.NumberStyles.HexNumber);

when we want to keep value as constant (with hex value as comment) const int value = -1; // 0xFFFFFFFF

Details

  • Product in use: VS extension
  • Version in use: 8.3.1
  • Did you see it working in a previous version, which? No

KunzeAndreas avatar Aug 27 '21 13:08 KunzeAndreas

Thanks for the report. Good thinking with the two different fixes. Since it's a compile error right now, even just a PR to do the const style one (with comment) everywhere would be a worthwhile improvement

GrahamTheCoder avatar Sep 12 '21 09:09 GrahamTheCoder

This implementation fails for the input:

Const mh As ULong = &HffffffffffffffffUL

Because the value is too large for an int.

Should I open a new issue to follow up with these findings or do you want to reopen this one?

franciscosamuel avatar May 08 '23 12:05 franciscosamuel

Thanks, I'll reopen this

GrahamTheCoder avatar May 08 '23 18:05 GrahamTheCoder