After trying a little bit I created a query that is working in the way I need:
// <Name>Interfaces registered but potentially not used</Name>
warnif count > 0
from t in JustMyCode.Types
from i in JustMyCode.Types
where t.DeriveFrom("StructureMap.Configuration.DSL.Registry")
&& i.IsInterface
&& t.IsUsing(i)
&& i.NbTypesUsingMe < 3 // one using for implementation, one in registry
select i
Not as much code as I expected :-) This query isn't cover any eventuality but it is a good start.
Nevertheless: Patrick, thanks for your help!
You are welcome Rico :) Btw, this code rule can be rewritten this way to be ran in O(N) instead of O(N^2) (N being the number of JustMyCode.Types). This optimization is achieved thanks to the magic UsedByAny() method. This rule also provides a more detailed result.
warnif count > 0
let registryDerived = JustMyCode.Types.Where(t => t.DeriveFrom("StructureMap.Configuration.DSL.Registry"))
from i in JustMyCode.Types.UsedByAny(registryDerived)
where i.IsInterface &&
i.NbTypesUsingMe < 3 // one using for implementation, one in registry
select new { i,
registryDerivedUser = i.TypesUsingMe.Intersect(registryDerived),
i.TypesUsingMe }