I faced with the strange behavior by NetArchTest when I worked with the nameof expression.
I have a simple an architecture test which is below:
public void DomainLayerDoesNotHaveDependencyOnInfrastructureLayer() {
TestResult result = Types.InAssembly(typeof(Identity).Assembly)
.That()
.ResideInNamespace("StronglyTypedIdentity.Domain")
.ShouldNot()
.HaveDependencyOn("StronglyTypedIdentity.Infrastructure")
.GetResult();
Assert.That(result.IsSuccessful);
}
As you see, I want to avoid dependencies on the Infrastructure in the Domain layer (according to the Onion architecture it's wrong).
Now I'm going to apply this arch. test for my pet project .
To reproduce a strange behavior with nameof I deliberately decided to instantiate an object with CustomDbContext type(Infrastructure) in the CustomType (Domain). This means that I added a dependency on the Infrastructure layer in the Domain layer.
And now is an interesting moment, cuz, when I'm wrapping CustomDbContext into the nameof expr. (is evaluated at compile-time), then my arch test is successfully passing, but in fact, it should not. When I don't use nameof, the arch. test result is failed, and that is correct.
Watch my screencast here to realize an issue.
Also, visit my pet project to reproduce an issue
I faced with the strange behavior by NetArchTest when I worked with the
nameofexpression.I have a simple an architecture test which is below:
As you see, I want to avoid dependencies on the Infrastructure in the Domain layer (according to the Onion architecture it's wrong).
Now I'm going to apply this arch. test for my pet project .
To reproduce a strange behavior with
nameofI deliberately decided to instantiate an object withCustomDbContexttype(Infrastructure) in theCustomType(Domain). This means that I added a dependency on the Infrastructure layer in the Domain layer.And now is an interesting moment, cuz, when I'm wrapping
CustomDbContextinto thenameofexpr. (is evaluated at compile-time), then my arch test is successfully passing, but in fact, it should not. When I don't usenameof, the arch. test result is failed, and that is correct.Watch my screencast here to realize an issue.
Also, visit my pet project to reproduce an issue