paul1956 / CSharpToVB

New version of CSharpToVB converter
MIT License
25 stars 9 forks source link

Tuple Deconstruction #56

Closed DualBrain closed 3 years ago

DualBrain commented 3 years ago

Wondering if the tuple deconstruction could be modified to generate something similar to:

Original...

(string[] types, string[] names, string[]? fields) = ExtractProperties(parser);        

When converted...

Dim tupleTemp = ExtractProperties(parser) : Dim types = tupleTemp.Item1, names = tupleTemp.Item2, fields = tupleTemp.Item3

And to take this request further, would it be possible to "fixup" the function returning the tuple so that, if it doesn't have names for the tuple values, the names could be transitioned to the method signature based on the caller - once done the first time, don't try to do it again.

Doing so could potentially produce a result of:

Dim tupleTemp = ExtractProperties(parser) : Dim types = tupleTemp.Types, names = tupleTemp.Names, fields = tupleTemp.Fields

(Of course, I also took this one step further by Pascal-casing the names.)

At this point, you now have a "cleaner" result - which, so far in my experimenting, clearly identifies that some "Inline temporary variables" refactoring is in order. ;-)

As such, I'm wondering if the following wouldn't be helpful...

' TODO: Review the following for possible refactoring using "Inline temporary variables".
Dim tupleTemp = ExtractProperties(parser) : Dim types = tupleTemp.Types, names = tupleTemp.Names, fields = tupleTemp.Fields
paul1956 commented 3 years ago

Fixed in converter 5.0.0.19