Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

VB -> C#: improve int const adjustments in some cases #1064

Open
TymurGubayev opened this issue Dec 13, 2023 · 0 comments
Open

VB -> C#: improve int const adjustments in some cases #1064

TymurGubayev opened this issue Dec 13, 2023 · 0 comments

Comments

@TymurGubayev
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I'm always frustrated when a hexadecimal constant is converted in a way I can't search for it anymore (in some cases).

VB.NET input:

Dim i As Integer = &H80040E19
If (i = &H80040E19) Then
End If

Current output:

int i = int.MinValue + 0x00040E19;
if (i == int.MinValue + 0x00040E19)
{
}

Describe the solution you'd like
I think a much nicer output would be using unchecked instead of changing the constant literal, something like this:

int i = unchecked((int)0x80040E19);
if (i == unchecked((int)0x80040E19))
{
}

Describe alternatives you've considered
Write a Roslyn replacement rule to restore the constants in a pass after CodeConverter is done.

Additional context
None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant