-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
A command to generate a struct from a tuple #26998
Comments
I like this idea. :) If we did this, i also think it should work for anonymous-types as well. I imagine there would be two forms of hte fix:
Basically, should the fix work just for the current method (which is the concept we have for anonymous-types), or should it expand to work globally. |
If we did have the "global fixup" concept, we would likely want to use an IDE index to speed up searching for things. We could update the syntax-tree-index to store the shapes of anonymous-types/tuples we saw, so that we could find all possible matches in O(d) time (where 'd' was the number of files with a matching shape), instead of having to search everything. |
@CyrusNajmabadi Can you please clarify what you mean by "work for current method" and "work globally"? Are you talking about replacing usages of the tuple type with the generated type? |
Would it replace tuples that are unrelated but happen to be the same type? |
The design of such replacement raises the same questions as renaming tuple elements - how do we track tuple types and when do we consider them equal? There should be one answer to both (and hopefully one implementation), so this should probably wait until the design for tuple renaming is finalized. |
Yes. That's what i'm referring to. I would expect to be able to make this change on a local basis versus making it globally.
I would use types and names. The point of allowing the user to specify scopes is precisely around if you'd want to consider other tuples with the same 'shape' as equivalent and important to fixup or not. |
This is new. I should celebrate :)
I |
I didn't ask for replacement. Gust generate the struct and I'll take it from there :) |
Fixed with #28257. @jcouv @jinujoseph can you close this issue? |
@CyrusNajmabadi |
You're welcome. Great idea! |
If I have a ValueTuple in code like this:
(Char From, Char To)
It will be helpful if the context menu offers a command to generate a struct with a default name from this tuple:
Sometimes I start with a tuple, then discover I want to reuse it many times, so it is easier if I convert it to a struct.
The text was updated successfully, but these errors were encountered: