Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select types that are not inherited by any class #133

Open
kristofferjalen opened this issue Nov 9, 2023 · 1 comment
Open

Select types that are not inherited by any class #133

kristofferjalen opened this issue Nov 9, 2023 · 1 comment

Comments

@kristofferjalen
Copy link

kristofferjalen commented Nov 9, 2023

Say I have a class that inherits from another, non-abstract, class:

public sealed class UserNotFoundException : UserException { }

public class UserException : Exception { }

This will break my assertion that class should be sealed:

var result = Types.InCurrentDomain()
    .And().AreNotInterfaces()
    .And().AreNotAbstract()
    .Should().BeSealed()
    .GetResult();

Rather than filtering edge-cases:

    .And().DoNotInherit(typeof(Exception)) 

is there any way to select types that are not inherited by any class? Like:

var result = Types.InCurrentDomain()
    .And().AreNotInterfaces()
    .And().AreNotAbstract()
    .And().AreNotInheritedByAnyClass()  // <--- like this
    .Should().BeSealed()
    .GetResult();
@kristofferjalen kristofferjalen changed the title Select types that do not inherit any class Select types that are not inherited by any class Nov 9, 2023
@NeVeSpl
Copy link
Contributor

NeVeSpl commented Nov 9, 2023

It is interesting use case. As far as I know, right now it is not supported, but it looks like doable, and could be added in the future to the NetArchTest.

NeVeSpl added a commit to NeVeSpl/NetArchTest.eNhancedEdition that referenced this issue Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants