Skip to content

foreach autocompletion should be offered when ctrl+. is pressed on a variable representing a collection #60628

@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


There are several things that happen over and over again in programming. One of them is implementing foreach loops for variables.

Consider the following:

string[] names = new string[] {"John", "Peter", "Dan"};
names // press CTRL+. on `names` variable

at this point I would love to have an option in the context menu that would implement:

string[] names = new string[] {"John", "Peter", "Dan"};
foreach (string name in names) {
   // caret here
}

PS: I know I can write foreach and press tabulator twice and it helps but it still requires quite a lot of manual work to get it to required code.

Thank you for considering this feature.


Original Comments

Feedback Bot on 3/21/2022, 07:33 AM:

(private comment, text removed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEDeveloper CommunityThe issue was originally reported on https://developercommunity.visualstudio.comFeature RequestIDE-CodeStyleBuilt-in analyzers, fixes, and refactoringshelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type

    Projects

    Status

    Complete

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions