NDepend Users Voice

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.

12 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Sye van der Veen shared this idea  ·   ·  Admin →

    2 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • 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.Types

        where 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 TestFixtures

        where !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.

      Feedback and Knowledge Base