In Visual Studio 2013 Ultimate, Microsoft introduced a feature named CodeLens. A handy feature which (among others) has the ability to count the number of times a method is referenced in your project.
At the moment we're using VS2015 Pro and I'm working in a big solution with multiple projects in it.
The problem
Consider the following class:
public class MapItem
{
public int Id { get; set; }
public string Provider { get; set; }
public string Value { get; set; }
public bool MainItem { get; set; }
public int? MapId { get; set; }
public override string ToString()
{
return $"Provider: {Provider}, Value: {Value}, MainItem: {MainItem}";
}
}
CodeLens would count the number of times every property is referenced and adds it above each properties' declaration. I've also overridden the ToString()
method to easily read the values when printing.
Right now, every time when I open a file with a ToString()
declaration or when I make changes to one, Visual Studio starts counting the references of every occasion where ToString()
is used. Even when this specific method in this class is not used.
This results in Visual Studio using all my CPU (95%+) and becoming unresponsive for a few minutes.
My Question
I have already learned how to disable CodeLens reference counting completely, but this is not what I want. What I would like to know is if there is any way to tell CodeLens to stop reference counting for a single method in general, and ToString()
specifically (an attribute or blacklist perhaps?). This way Visual Studio won't have to go through the hassle of counting every time an overridden method is referenced. Alternatively, I would like to see the amount of references to MapItem.ToString()
only.
It looks like, it's impossible. You can't disable reference counting for a method, and you can't disable reference counting at all. This option is disabled:
I have found this feature request. And Visual Studio Team won't do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With