Rychu
Rychu

Reputation: 1005

Prioritize local variables in Visual Studio Intellisense

Is it possible to configure Intellisense to prioritize local variables suggestions over class types? For example if I declare httpContext variable I want to get this variable suggestion on top instead of HttpContext class type. Example situation screenshot.

--- Edit ---

Providing additional example to distinct httpcontent behavior from httpContent.

Different behavior for httpcontent and httpContent from the other PC

Upvotes: 5

Views: 1439

Answers (1)

Mr Qian
Mr Qian

Reputation: 23808

Is it possible to configure Intellisense to prioritize local variables suggestions over class types? For example if I declare httpContext variable I want to get this variable suggestion on top instead of HttpContext class type.

This is quite a abnormal behavior. In fact, Visual Studio Intellisense will prioritize local variables rather than class types by default. And in my side, it works perfectly. See this:

enter image description here

So I think there are some environmental factors that cause this error. Please try these suggestions:

  1. close your VS Instance, delete .vs hidden folder, bin, obj folder. And then restart your project again to test it.

  2. clean vs component caches-----delete files under C:\Users\xxxx\AppData\Local\Microsoft\VisualStudio\16.0_xxx(16.0 is VS2019,15.0 is VS2017)\ComponentModelCache

  3. disable any third party extensions or just use denvenv /safemode to start VS to test your project in case some other extensions cause this abnormal behavior.

  4. do a repair in VS Installer

  5. if your VS is not the latest version, please try to update it in case there are some fixes.

Update 1

After researching more detailed info provided by you, l find that this should be an issue in visual studio intellisense and in fact, l faced the same issue as you described.

So l have reported this issue on our DC Forum.See this link. You can vote it and comment any detailed info which can raise the team's attention.

Since the process may be a bit long, as a suggestion, you can use the resharper extension which works successfully without this issue.

Upvotes: 2

Related Questions