Skip to content

Class member referring a local enum incorrectly results as an external dependency #148

@jonataspc

Description

@jonataspc

The following code results false:

using NetArchTest.Rules;

var result = Types.InCurrentDomain()
                  .That()
                  .HaveNameStartingWith("MyClass")
                  .Should()
                  .OnlyHaveDependenciesOn("System", "NetArchTestLabs")
                  .GetResult();

Console.WriteLine(result.IsSuccessful); // should be true

namespace NetArchTestLabs
{
    public static class MyClass
    {
        private static readonly MyEnum[] _values = { MyEnum.A, MyEnum.B, MyEnum.C };
    }

    public enum MyEnum
    {
        D,
        A,
        B,
        C,
        Z
    }
}

Am I missing something here or is it expected?
If I remove the first element of the enum, weirdly it behaves as expected, resulting true.

Here is a reproducible example:
https://github.com/jonataspc/NetArchTestLabs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions