Closed mneundorfer closed 1 year ago
Hi @mneundorfer ,
I also don't find a method corresponding to onlyBeAccessed
. Would a rule like Types().That().DependOnAny(TargetLayer).And().AreNot(TargetLayer).Should().Be(AccessLayer)
work for your use case?
Disclaimer: I haven't tested the rule, please verify that it actually does what you need
Hi @MSinstein ,
Thanks for the feedback - apparently, however, it does not work as (I would) expected. Given your example, if I have an AbcLayer
also referencing the TargetLayer
, the tests still run green.
... works as expected, thanks for the hint! For anyone wondering why I thought it was not working in the first place - don't forget to call the .Check()
afterwards... 🤦
From the Java ArchUnit implementation, I am aware of the
onlyBeAccessed
rule, which allows to define a set of types/classes which can have exclusive access to another one.So far, I did not find a counterpart in ArchUnit.NET. As far as I could see there only exists
ShouldOnlyUse
, but no negatingShouldOnlyBeUsedBy
. Is this something that just is not possible with ArchUnit.NET at the moment, or did I just not stumble across the right solution so far...?Thanks for any hints!