2

たとえば、多くのコントロールを含むソリューションを分析しているとしましょう。

public class FooControl : IControlBase
{
    public void EvilMethod1()
    {
        // does some warning-level evil here
    }

    public void EvilMethod2()
    {
        // does some critical-level evil here
    }
}

2 つの CQLinq クエリを記述して、悪意のあるコード (EvilMethod1 など) を持つすべてのクラスと、2 つの別個のクエリで本当に悪意のあるコード (EvilMethod2 など) を使用するクラスをすべて報告したいと考えています。

このクエリで分析する必要があるすべての型を見つけるために、次のようなコードを記述します。

let Controls = from t in Types
where t.NameLike("Control")
&& t.Implement(@"myNamespace.IControlBase")
select t

from c in Controls
... // actual query goes here

このコードは明らかに両方のクエリで使用されます。両方のクエリでこのコードを参照する方法はありますか、それとも複製する必要がありますか?

4

1 に答える 1

1

For now you need to replicate the logic, however this feature is in our TODO list, you can vote for it here:

https://ndepend.uservoice.com/forums/226344-ndepend-user-voice/suggestions/9752604-let-queries-pull-data-from-other-queries

We will update this answer once available, hopefully some time in 2017.

Btw, this kind of idea is already available through the notmycode JustMyCode feature, but you can only define and reuse the JustMyCode set.

于 2016-04-05T08:43:20.130 に答える