Let queries pull data from other queries
Logically, parts of queries can be shared between queries. For example, both "Types that could have a lower visibility" and "Potentially dead Types" need to ignore classes with only const fields. I would like queries to be able to build on the results of other queries, much as C# methods reduce code duplication by using other methods.
-
Anonymous commented
This would be very useful to define meta types (E.g. TestFixtures, Test Assemblies, Domain Entities, MessageHandlers, DTOs etc.).
There is also the request for "Allow custom definitions similar to JustMyCode" which is the same in my opinion.This should be implemented easily, as it is possible to do this today with a little hack:
/////// Rule that will be reused, defining test code ////////
// <Name>TestFixtures</Name>
warnif count > 0 // <= this is needed :(
from t in JustMyCode.Typeswhere t.HasAttribute("NUnit.Framework.TestFixtureAttribute".MatchType())
select t
///////////////
/////// Example rule that uses the other rule ////////
// <Name>Testfixtures should end with "Tests"</Name>
//let testFixtures = (from i in Issues where i.Rule.Name == "TestFixtures" select i.CodeElement).Cast<IType>()
let TestFixtures = Rules.First(r => r.Name == "TestFixtures").Issues().Select(i => i.CodeElement).OfType<IType>()
from t in TestFixtureswhere !t.IsAbstract && !t.Name.EndsWith("Tests")
select t
///////////////
/////// Example rule for exclusion ////////
// <Name>Example of exclusion</Name>
let TestFixtures = Rules.First(r => r.Name == "TestFixtures").Issues().Select(i => i.CodeElement).OfType<IType>()from t in JustMyCode.Types
where !t.IsAbstract && t.TypesUsingMe.Count() <= 0 && !TestFixtures.Contains(t)
select t
///////////////Also defining custom extension methods may be even more usefull, as it fits the exclusion rule better.
-
This is a feature we'd like to provide, let's see how many votes it gets, this will help prioritize it.
Thanks