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

VisibleMembers should allow defining the surface of a subtree #10

Open realvizu opened 7 years ago

realvizu commented 7 years ago

At the moment, with Allowed/VisibleMembers you can define the surface of only a single namespace. (The To namespace can not be a subtree.) Eg.

    <Allowed From="Codartis.NsDepCop.Core.Factory" To="Codartis.NsDepCop.Core.Implementation.Analysis.NRefactory">
        <VisibleMembers>
            <Type Name="NRefactoryDependencyAnalyzer" />
        </VisibleMembers>
    </Allowed>

It should be allowed to define the surface of a subtree as well. Eg.

    <Allowed From="Codartis.NsDepCop.Core.Factory" To="Codartis.NsDepCop.Core.Implementation.*">
        <VisibleMembers>
            <Type RelativeName="Analysis.ConfiguredAnalyzer" />
            <Type RelativeName="Analysis.IAnalyzerFactory" />
            <Type RelativeName="Analysis.NRefactory.NRefactoryDependencyAnalyzer" />
            <Type RelativeName="Analysis.Roslyn.RoslynDependencyAnalyzer" />
            <Type RelativeName="Config.XmlFileConfigProvider" />
        </VisibleMembers>
    </Allowed>

In this case the Type elements must describe not only the type name but also its relative namespace path.

The same should apply to VisibleMembers elements with the OfNamespace attribute.