【发布时间】:2020-04-18 00:49:04
【问题描述】:
我不确定这是设计使然还是需要在 VS 2013 Ultimate 中启用/禁用功能,但 codelens 生成的引用计数完全不正常。它不是显示直接引用特定类/方法的类/方法的计数,而是显示整个解决方案中与该类/方法同名的所有内容的计数。
例如,假设我的解决方案中有四个类(四个项目各有一个类并不重要)。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary20
{
public interface IWillPrint
{
void PrintThis();
}
public class Class1 : IWillPrint
{
public void PrintThis() { }
}
public class Class2 : IWillPrint
{
public void PrintThis() { }
}
public class Class3 : IWillPrint
{
public void PrintThis() { }
}
public class Class4 : IWillPrint
{
public void PrintThis() { }
}
public class Class5
{
public void SomeMethod()
{
var j = new Class1();
j.PrintThis();
}
}
}
class1 中方法 PrintThis() 的引用计数显示为 5。引用弹出窗口显示 class1、class2、class3、class4 和 class5 及其对应的行号:
它应该在弹出窗口中只显示一个引用(1 个引用)和第 5 类。另外我不确定为什么codelens还包括实际实现计数中的方法的类。我现在看不到谁在呼唤谁。当你有很多类要处理时,引用计数是一个很大的帮助。
如果有更简单的解决方案,我不想重新安装 resharper 和/或 VS。
【问题讨论】:
-
我有同样的“问题”:我也想只看到“真正的”引用,这意味着在派生类中我只想看到基类的方法,而不是所有方法派生自同一个基类的所有类。不幸的是,这不可用。
标签: visual-studio-2013 reference-counting codelens