0

I updated to Visual Studio Code 1.81 and after doing so Codelens has stopped showing references to variables within code. It still operates normally for Classes, Methods, seemingly everything except for variables. [EDIT] It also displays references correctly for static variables.

Class shows references in code but variables do not

I tried downgrading to the previous version of VSCode but it did not fix the issue. I also tried resetting my settings but this didn't fix it. I also attempted to reset Omnisharp as per this post: Visual Studio Code codelens doesn't work on variables but it did not seem to fix it either.

Is there a setting that I am not aware of that affects this?

Anodomani
  • 1
  • 2
  • I wonder if this is related? https://stackoverflow.com/q/76850403/11107541. Actually, this seems to be a duplicate of https://stackoverflow.com/q/76848440/11107541. Take a look and if that one solves your problem, vote to close your question as a duplicate. – starball Aug 09 '23 at 07:11
  • @starball I actually included a link to that post in the main body of this post. I attempted to do what worked for them and it had no effect. My issue also started happening 2 days ago when I updated so I imagine they are related. – Anodomani Aug 09 '23 at 14:32
  • Does this answer your question? [What changed about the C# extension for VS Code's IntelliSense in the v2.0.320 release?](https://stackoverflow.com/questions/76850403/what-changed-about-the-c-sharp-extension-for-vs-codes-intellisense-in-the-v2-0) – starball Aug 09 '23 at 19:56

2 Answers2

0

As far as I know, Codelens only displays references for classes, methods and properties, but not for fields (properties are secretly methods with a field but don't tell anyone). Are you sure it displays references for a static field, as opposed to a property?

As long as I remember (so like, a few years), it's always been like this:

Image showing an example class with method, field and property, showing the codelens reference counter above everything except the field.

Squirrelkiller
  • 2,575
  • 1
  • 22
  • 41
0

This issue is the same as stackoverflow.com/q/76850403/11107541 I was able to fix it using the solution provided there. I had to uninstall the C# Dev Kit and Unity extensions and reload Omnisharp. Now things are running as they did before: Correct display of references

Anodomani
  • 1
  • 2
  • 2
    if it's a duplicate, then you should be flagging to close it as a duplicate :) please do that instead. – starball Aug 09 '23 at 19:56