Skip to content

ResideInNamespaceMatching with nested+internal types #98

@kl1mm

Description

@kl1mm

Hi BenMorris,
we ran into a problem when trying to validate our nested internal types, which we first filtered for ResideInNamespaceMatching.

After examining the NetArchTest code, we found the extension method TypeDefinitionExtensions.GetNamespace, which only checks IsNestedPrivate or IsNestedPublic. For testing, we changed our class from internal to private and it worked.

        public static string GetNamespace(this TypeDefinition typeDefinition)
        {
            if (typeDefinition.IsNestedPrivate || typeDefinition.IsNestedPublic)
            {
                return typeDefinition.DeclaringType.FullName;
            }

            return typeDefinition.Namespace;
        }

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