visual-studiotfscodelens

CodeLens not showing references


CodeLens stopped working for some reason in project solution that I'm dealing nowadays. It is not showing references instead "- references". However, when I open up Visual Studio with another project It works like charm.I can confirm that CodeLens is enabled. Do you have any idea to make it work?


Solution

  • You may have circular references in your solution that prevents CodeLens from working. Some details were provided in the comments for this issue on the Visual Studio Connect site:

    Somehow, two of my projects in my solution ended up referencing each other causing a circular reference. I think it was a by-product of Resharper's shortcut to reference an undefined class. Once I was cleaned up all of the references, I'm now getting valid values in my reference counts.

    How did you go about "cleaning" up references?

    In my case, my solution has multiple project files. In the references folder of Project A, there was a reference to Project B. In the references folder of Project B, there was a reference to Project A. This was causing the circular reference. If you try to do this "manually", VS will prompt you with a warning regarding the circular reference.

    To clean this up, I removed the reference to Project B from my Project A. I had do some minor class definitions in my Project B so everything would still compile in the end.