C# Intellisense making wrong suggestions inside foreach statements

There’s a bug in Visual Studio that has been annoying me for quite a long time: sometimes, Intellisense doesn’t work well inside “foreach” statements in C#. It makes suggestions, but the wrong ones.

For example, if I start writing “foreach (System.Xm….)” with the intention to write “System.Xml.XmlNode”, Intellisense only offers stupid options like System.FromXml that make no sense.

I’ve realized that this only happens if the parenthesis are closed. So, if you delete the closing parenthesis before start typing, Intellisense works as expected. 


I´m sure there are other ways to fix this, but for now unchecking the “Automatic brace completion” option (see below) will suffice. 

In fact, it’s an option I never liked, so two birds with one stone… J