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# : redim preserve bad choice for temporary var name #393

Closed
v1nce opened this issue Oct 23, 2019 · 1 comment
Closed

VB -> C# : redim preserve bad choice for temporary var name #393

v1nce opened this issue Oct 23, 2019 · 1 comment
Assignees
Labels
compilation error A bug where the converted output won't compile good first issue VB -> C# Specific to VB -> C# conversion

Comments

@v1nce
Copy link

v1nce commented Oct 23, 2019

THANK YOU for your tool.

I think there's a problem with the name of temporary array in the case of redim preserve.
It's called old%FULL_ARRAY_NAME% which breaks if the array is a property of an object instance (among multiple other possible cases)

instead of
var oldinstance.prop = instance.prop is wrong.
it should be
var oldprop = instance.prop
or something like
var __oldinstance__prop = instance.prop

Input code

ReDim Preserve instance.prop(size)

Erroneous output

var oldinstance.prop = instance.prop;
instance.prop = new string[size + 1 + 1];
if (oldinstance.prop != null)
Array.Copy(oldinstance.prop, instance.prop, Math.Min(size + 1 + 1, oldinstance.prop.Length));

Expected output

var oldinstance_prop = instance.prop;
instance.prop = new string[size + 1 + 1];
if (oldinstance_prop != null)
Array.Copy(oldinstance_prop, instance.prop, Math.Min(size + 1 + 1, oldinstance_prop.Length));

Details

VS extension

@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Oct 24, 2019 via email

@GrahamTheCoder GrahamTheCoder added compilation error A bug where the converted output won't compile good first issue VB -> C# Specific to VB -> C# conversion Hacktoberfest labels Oct 24, 2019
@GrahamTheCoder GrahamTheCoder self-assigned this Nov 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compilation error A bug where the converted output won't compile good first issue VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

2 participants