exclude assembly in some ways but not others

I'm using NDepend to analyze a C# project that I'm in the middle of developing. I have most of my business logic and data access layers written, but right now, the only front end application that I have is a "quick and dirty" test application.

So first off, NDepend has all kinds of issues with my test application. Nothing serious, just things like too many methods, too-long methods, etc. Since this is basically a throwaway application, I didn't want to spend a bunch of time refactoring it, so I removed it from the NDepend project.

The problem is that now, since that was my only front end application in the project, NDepend is complaining about things in my business layer like uninstantiated classes, since there is no code that instantiates them except in the test application that I've excluded. I know that these are safe to ignore for now, since they will eventually be instantiated by the REAL front end app, but I really really want to see all of the yellow triangles go away before I do any further development on this app.

Is there a way to make NDepend NOT complain about issues in a particular assembly, but still include it to make queries in OTHER assemblies pass?

If not, any other ideas?


Yes it is possible. First reference again your test application assembly(ies). Then exclude them by adding a custom query that look like:

// <Name>Discard test assemblies from JustmyCode</Name>
notmycode Application.Assemblies.WithNameIn("TestAsm1","TestAsm2"...)

This query can be saved in the default group Defining JustMyCode (not mandatory but recommended).

Then you need to adapt code rules that are warning about test assemblies dirty stuff to use JustMyCode instead of Application (like from m in JustMyCode.Methods... instead of from m in Application.Methods... ).

The notmycode/JustmyCode related documentation can be found here.

链接地址: http://www.djcxy.com/p/37730.html

上一篇: 查询以减少矩阵

下一篇: 排除大会在某些方面,但不是其他人