Let's say I'm analyzing a solution which contains a lot of Controls, e.g.
public class FooControl : IControlBase
{
public void EvilMethod1()
{
// does some warning-level evil here
}
public void EvilMethod2()
{
// does some critical-level evil here
}
}
I want to write two CQLinq queries to report all classes which have evil code (such as EvilMethod1) and such which use really evil code (such as EvilMethod2) in two separate queries.
To find all the types which should be analyzed by this query, I will write code such as
let Controls = from t in Types
where t.NameLike("Control")
&& t.Implement(@"myNamespace.IControlBase")
select t
from c in Controls
... // actual query goes here
This code would obviously used by both queries. Is there a way to reference this code in both queries or am I forced to replicate it?