Suggestion - Parameters to Struct generation
Some of the work I'm about to do requires a lot of restructuring of code for readability.. Instead of a function taking 4floats, make it take 2points etc.
It would be nice with a tool to assist this process, as i can imagine others sometimes being in the same boat.
A tool where you could mark two floats of the function, say use the struct "point", and map the two float to values in the struct.
It should also allow for creating those Structs for you, so mark the two floats parameters in the function, say create a struct from that, and then it would do the following:
1. Create a struct that matches the given name, and uses the parameter names as values of that Struct
2. Replace the signature from the one with bloated parameter count to the struct version
3. Fix dependcies - Say oh i can see you're now using a struct with the two values, and it'll try as much as possible to fold that out. So code like:
"var x = 5, var y = 10;
x += 5;
print(distance (x,y,5,4));"
Becomes:
"auto p = {5, 10};
p ->x += 5;
print(distance (p,{5,4}));"
I don't imagine this task being easy! But I'm sure it's possible.. and let's say the parameters would fold out.. Let's say the previous example had x coming from a function.. Well, then that just create the point in the beginning of the function.. no need to make it recursive and thus extremely dangerous.. In other words, just because you changed a function named 'lerp' doesn't mean it should change the signature of a function named 'remap'
Hope this feature will be made, even if it's not in the foreseeable future - pretty sure it would help any team out greatly! :)
Please sign in to leave a comment.
Hi,
Could you clarify the language?
K.R.
Sofia
Hi Sofia,
Generally I'm talking about all languages, but mainly C#, in our case n.n
Hello Dax,
There is a Transform Parameters refactoring feature (https://www.jetbrains.com/help/rider/Refactorings_Transform_Parameters.html) in Rider/R# that can help in some cases. Also, there is a feature request: https://youtrack.jetbrains.com/issue/RSRP-26649 that you can upvote to increase its priority.
If there is something to add, please file issues on RIder's tracker https://www.jetbrains.com/ directly.
K.R.
Sofia.