【发布时间】:2017-03-02 14:25:20
【问题描述】:
方法 Visit(Leaf v) 和 Visit(Composite v) 被 SonarLint 标记为未使用。 SonarQube 也将其标记为未使用。但它以动态方式调用。 有人知道如何解决吗?可能有一些配置? 入口点是一个Visit(Base root),然后使用动态调用它会遍历树。
UPD:更新示例
这是示例:
public void Visit(Base root)
{
Visit((dynamic)root);
}
private void Visit(Composite v )
{
v.Children.ForEach(el => Visit((dynamic)el));
}
private void Visit(Leaf v)
{
// do smth
}
class Base
{
}
class Composite : Base
{
public IEnumerable<Base> Children { get;}
}
class Leaf : Base
{
}
【问题讨论】:
-
你能告诉我们你调用
Visit的代码吗? -
@dotctor 是的,srry 入口点错误,更新了代码。这是轻样本。但是在 v.Children.ForEach(el => Visit((dynamic)el)); 中也调用了 Visit((dynamic)el));
-
@mybirthname 移除声纳 - 这不是案例或解决方案