I’m trying to write a CQL query in Visual NDepend to find all types and methods that don’t directly depend on any type from a list of namespaces.
The Query I’ve built so far is this one:
SELECT METHODS
WHERE
!IsDirectlyUsing "NAMESPACE:Microsoft.*"
AND !IsDirectlyUsing "NAMESPACE:System.Web.UI.*"
AND !FullNameLike ".Test"
AND !HasAttribute "System.CodeDom.Compiler.GeneratedCodeAttribute"
AND FullNameLike "OurOwnNameSpaceHere"
But this still returns methods that accept a SPWeb as a parameter, so I must be missing something.
So I want to:
-
exclude any method that depends on any type inside any referenced Assembly which is inside a Microsoft.* namespace.
-
exclude any method that depends on any type inside any referenced Assembly which is inside a System.Web.Ui.* namespace.
-
exclude any generated method/type
-
exclude any method that is part of a project that has Test in the namespace.
Sample methods that fall through are:
public void SomeMethod(SPWeb web)
{
... // other code here
SomeOtherMethod(web);
...
}
You can try the following code query over LINQ (CQLinq query):
The condition exclude any generated method/type is handled by the fact that we use JustMyCode.
Then, which methods or fields of
SPWebare used by the method still matched?NDepend can detect that a method uses a type only if it is using a member of the type.