realvizu / NsDepCop

NsDepCop is a static code analysis tool that helps to enforce namespace dependency rules in C# projects. No more unplanned or unnoticed dependencies in your system.
GNU General Public License v2.0
200 stars 32 forks source link

[Q] Are transient dependencies supported? #46

Closed o7g8 closed 5 years ago

o7g8 commented 5 years ago

Hello,

Is it possible to capture transient dependencies on type level? Let's say we have a dependency chain A->B->C:


namespace A {
 class ClassA {
    public B.ClassB B = new B.ClassB();
 }
}

namespace B {
 class ClassB {
    public C.ClassC C = new C.ClassC();
 }
}

namespace C {
 class ClassC {
    public int i = 0;
 }
}

I would like to implement a rule disallowing A->..->C. I couldn't make it work with current NsDepCop. Is it possible?

I need to convert big code base to .NET Standard and some of lower layers of the code-base have .NET Standard-incompatible references: to System.Forms, etc. I need to know which upper level code transitively depends on the incompatible stuff (and which doesn't). Is it possible to find out with the help of NsDepCop?

I see my question is related to #35

realvizu commented 5 years ago

Sorry, but transitive dependency checking is not supported. It's possible that it will be added later, but not in the short term.

You should check out other tools, eg. NDepend supports transitive type dependency quieries AFAIK.