Skip to content

Support Type.IsAssignableTo(Type) Method #138

@BobSilent

Description

@BobSilent

Description (optional)

.NET5 introduced the handy IsAssignableTo(Type) Method

Rationale

new code is using this and for backword compatibility the code has to be rewritten or an own extensions method needs to be manually added.

Proposed API

namespace System;

#if !NET5_0_OR_GREATER
internal static class Extensions
{
    public static bool IsAssignableTo(this Type sourceType, Type? targetType) => targetType?.IsAssignableFrom(sourceType) ?? false;
}
#endif

Drawbacks

n.a.

Alternatives

Adding the extension method from above manually.

Other thoughts

n.a.

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