Allow custom definitions similar to JustMyCode
The JustMyCode definition is really nice and useful. I'd like to have a similar concept for other things, e.g. JustMyBusinessLogic or JustMyDatabaseLayer. Today I need to create different NDepend projects and adapt the JustMyCode definition for each of them.
-
Let's repor this 5May2015 comment that was on this duplicate question https://ndepend.uservoice.com/forums/226344-ndepend-user-voice/suggestions/9752604-let-queries-pull-data-from-other-queries
---
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.
-
Anonymous commented
Looks like a duplicate to "Let queries pull data from other queries" for me.
-
Robert Leahey commented
Absolutely. I was needing this just today.
-
Paul Saunders commented
Very useful for identifying Test code, and excluding it from certain metrics.