Suggest name when naming incomplete tuple element#80671
Merged
CyrusNajmabadi merged 9 commits intomainfrom Oct 13, 2025
Merged
Conversation
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add suggested name code action for value tuples
Suggest name when naming incomplete tuple element
Oct 12, 2025
| (System.Action $$ | ||
| } | ||
| } | ||
| """, "action"); |
Contributor
There was a problem hiding this comment.
@copilot Create versions of all these tests as well where there is a close paren after the $$.
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
| { | ||
| void Do() | ||
| { | ||
| (List<Person> $$) |
Contributor
There was a problem hiding this comment.
@copilot add variants with System.Collections.Generic.List<Person> and Person[]
Contributor
Author
There was a problem hiding this comment.
Added test variants for fully qualified generic types and array types in commit d2a3d56.
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
CyrusNajmabadi
approved these changes
Oct 12, 2025
JoeRobich
approved these changes
Oct 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #22342
Summary
This PR adds support for suggesting names when typing incomplete tuple elements in method bodies. Previously, name suggestions only worked when the tuple syntax was fully formed.
Problem
When typing an incomplete tuple like this:
The IDE would not suggest "people" as a name for the tuple element, even though it worked correctly for complete tuples:
Root Cause
The C# parser creates different syntax nodes depending on how complete the tuple is:
(List<Person> , int i)→TupleExpressionSyntax(handled byIsTupleLiteralElement)(List<Person>→ParenthesizedExpressionSyntax(not handled)void M((List<Person> )→TupleTypeSyntax(handled byIsTupleTypeElement)Solution
Added a new method
IsIncompleteParenthesizedTupletoDeclarationNameInfo.csthat detects when the user is typing an incomplete tuple by:ParenthesizedExpressionSyntaxNameDeclarationInfofor name generationThe implementation follows the same pattern as existing tuple handling methods and is placed appropriately in the check chain.
Testing
Added ten test cases covering:
(List<Person> $$→ suggests "people"(int $$→ suggests "i"(System.Action $$→ suggests "action"(System.Collections.Generic.List<Person> $$→ suggests "people"(Person[] $$→ suggests "people"All builds successful with no regressions expected.
Fixes #75347
Original prompt
Fixes #75347
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.