首页 > 解决方案 > 在 JetBrains Rider 中查找未使用的公共方法

问题描述

我有一个没有在任何地方使用的单一方法的接口:

public interface IInterface
{
    int Foo();
}

public class MyClass : IInterface
{
    public int Foo()
    {
        return 0;
    }
}

但是,即使打开解决方案范围的分析,JetBrains Rider 也不会向我显示任何提示、警告或任何内容。我尝试在Editor > Inspection Settings > Inspection Severity > C# > Redundancies in Symbol Declarations > Type or member is never used中更改设置,并将私有和非私有都设置为Warning。但我仍然没有收到任何警告。找出该方法未在任何地方使用的唯一方法是右键单击它并选择Find usages

是否有可能找到所有未使用的作为接口实现的公共方法?

标签: c#.net-corerider

解决方案


将 Rider 更新到版本 2019.2.2 后,Rider 还会检测接口中未使用的公共方法。但是,该功能非常不稳定,在重构了几个接口后,它再次停止工作。


推荐阅读