TNG / ArchUnitNET

A C# architecture test library to specify and assert architecture rules in C# for automated testing.
Apache License 2.0
900 stars 59 forks source link

ResidesInAssembly loading System.* #302

Open AdrianoAE opened 1 month ago

AdrianoAE commented 1 month ago

When verifying types from assemblies, the base types are being considered

IArchRule rule = Types()
    .That().ResideInAssembly(_DOMAIN_ASSEMBLY)
    .Should().NotDependOnAnyTypesThat().ResideInAssembly(_API_ASSEMBLY);

_ARCHITECTURE.CheckRule(rule);

Expected: Success because there is no reference between the projects

Actual:

ArchUnitNET.xUnit.FailedArchRuleException : "Types that reside in assembly "Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" should not depend on any types that reside in assembly "Api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"" failed:
    Domain.MyClass1 does depend on System.Runtime.CompilerServices.IsReadOnlyAttribute and System.IEquatable`1 and System.TimeSpan and System.TimeSpan& and System.Boolean and System.String and System.Object and System.Int32 and System.Collections.Generic.EqualityComparer`1

Same thing for the opposite rule with DependOnAnyTypesThat(). BCL and FCL types should not be taken into consideration since they are no declared in the given assembly

alexanderlinne commented 3 weeks ago

Hi @AdrianoAE, this seems to be a bug where types are assigned the wrong origin assembly. I've created #312 which I'd expect to solve your issue. Would be great if you'd be able to test this once we've merged it.