Skip to content

Select types that are not inherited by any class #133

@kristofferjalen

Description

@kristofferjalen

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();

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