Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Visual Studio IntelliSense is not working here?

Is it not working only for me or for everyone? It's not working everytime I write 'foreach' block inside lambda (dot after Enumerable):

Action t = ()=>
{
    foreach (var item in Enumerable.)
    {

    }
};

Any idea why it's not working in such cases?

I have VS 2010 SP1

update: It's not about Enumerable, it's about any object. I can try to write new object(). and have the same problem.

like image 290
Poma Avatar asked Apr 30 '11 11:04

Poma


People also ask

Why is my IntelliSense not working in Visual Studio?

If you find IntelliSense has stopped working, the language service may not be running. Try restarting VS Code and this should solve the issue. If you are still missing IntelliSense features after installing a language extension, open an issue in the repository of the language extension.

Why is IntelliSense not working Visual Studio 2022?

Please try: Go to Visual Studio Installer, click Modify , uncheck IntelliCode in Individual components, then click Modify button to save the change, wait for the installation to complete, and then reinstall IntelliCode . In Visual Studio, go to Tools->Options->IntelliCode to check if the setting is Default.

How do I enable IntelliSense in Visual Studio?

To access this options page, choose Tools > Options, and then choose Text Editor > C# > IntelliSense.


2 Answers

I can reproduce the bug with VS2010 SP1 and a brand new project:

class Program
{
    static void Main(string[] args)
    {
        Action t = () =>
        {
            foreach (var item in Enumerable.Range(1, 10))
            {
            }
        };
    }
}

Delete ".Range(1, 10)" and type "." and you should see Intellisense choices but there are none. But if you assign the expression to a temporary variable it works as expected. Follow Hans advice and file a bug report.

like image 95
Rick Sladkey Avatar answered Oct 19 '22 02:10

Rick Sladkey


Even if you type the open and close parantheses for foreach, you can get intellisense. For intellisense to work, you need to be typing in front of a white space.

For example: foreach then () and then go back into () and start typing var x in ... no intellisense! But, foreach then ( ) with a space and then go back into ( ) and start typing right after the (... now you get intellisense.

This is the behavior with C# settings. Not sure about settings for other languages.

like image 35
pnvn Avatar answered Oct 19 '22 02:10

pnvn