Skip to content

NotImplementAny(interfaces) returns FAIL if interfaces is Empty #446

@NielsApebs

Description

@NielsApebs

Hello.

I tried to check if my Application implements any Interfaces from Domain Layer:

        var rule =  ArchRuleDefinition.Types()
        .That().ResideInNamespaceMatching($"^application")   // <-- application All Types of the application layer
        .Should().NotImplementAnyInterfaces(                           // <-- This fails
            ArchRuleDefinition.Interfaces()
            .That().ResidesInNamespaceMatching($"^domain"))  // <-- domain All Typs of the domain layer

Because the domain Layer does not contain any Interfaces yet, my test should always be green, but it fails.

After I discovered the NotImplementAnyInterfaces() Condition i found this in
TypeConditionsDefinitions -> NotImplementAny(interfaces):

        foreach (var ruleType in ruleTypes.ToList())
        {
            var matchingInterfaces =
                interfaceList.Count > 0
                    ? ruleType.ImplementedInterfaces.Intersect(interfaceList).ToList()
                    : ruleType.ImplementedInterfaces.ToList();          //<-- Maybe this should be EmptyList, otherwise it fails when interfaceList is empty.
                if (matchingInterfaces.Any())
                {
                    yield return new ConditionResult(
                        ruleType,
                        false,
        ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions