Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallowed from a.* to a.b.* causes a.b.c->a.b.c to throw a warning #49

Open
destects opened this issue Jun 20, 2019 · 2 comments
Open

Comments

@destects
Copy link

destects commented Jun 20, 2019

ChildCanDependOnParentImplicitly="true" and

Will cause any references between the Core.Something.SubSomething namespace (and it's children) to Core.Something.SubSomething.* namespaces to throw an illegal namespace warning.

And also, Core.Something.SubSomething.Things1 namespace should be able to reference Core.Something.SubSomething.Thing2 namespace without issue. but a lateral reference is not allowed. and since Disallowed is stronger than Allowed, the lateral movement is reported as an illegal reference.

@realvizu
Copy link
Owner

Sorry, I don't understand your issue clearly.

I've just created a unit test for the situation that you've described in the issue title but I cannot reproduce the problem.

public void DisallowRule_ButSameNamespaceShouldBeAllowed()
{
var ruleConfig = new DependencyRulesBuilder()
.AddDisallowed("a.*", "a.b.*");
var dependencyValidator = CreateTypeDependencyValidator(ruleConfig);
dependencyValidator.IsAllowedDependency("a.b.c", "C1", "a.b.c", "C2").Should().BeTrue();
}

Also, the implementation of the TypeDependencyValidator explicitly starts with allowing all same-namespace references, so a.b.c->a.b.c should not throw a warning.

public virtual bool IsAllowedDependency(TypeDependency typeDependency)
{
// Inside a namespace all dependencies are allowed.
if (typeDependency.FromNamespaceName == typeDependency.ToNamespaceName)
return true;

So could you give me a complete example so I can reproduce your problem?

realvizu added a commit that referenced this issue Jun 23, 2019
@realvizu
Copy link
Owner

Oh, I think I understand now. So your problem is that a disallowed rule is stronger than the ChildCanDependOnParentImplicitly flag, is that right?
As stated in this unit test:

public void DisallowRule_IsStrongerThanChildCanDependOnParentImplicitly()
{
var ruleConfig = new DependencyRulesBuilder()
.AddDisallowed("a.*", "a.b.*")
.SetChildCanDependOnParentImplicitly(true);
var dependencyValidator = CreateTypeDependencyValidator(ruleConfig);
dependencyValidator.IsAllowedDependency("a.b.c", "C1", "a.b", "C2").Should().BeFalse();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants