Ndepend - exclude assembly in some ways but not others

两盒软妹~` 提交于 2021-02-10 14:23:13

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/19415535/ndepend-exclude-assembly-in-some-ways-but-not-others

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!