Skip to content

Consider adding comparison assertions for enums specifically #7207

@Youssef1313

Description

@Youssef1313

I would instead suggest to fix the implementation of the APIs to use IComparable instead of IComparable<T> or use overload with Enum like:

public static void IsGreaterThan(Enum lowerBound, Enum value, string? message = "",
    [CallerArgumentExpression(nameof(lowerBound))] string lowerBoundExpression = "",
    [CallerArgumentExpression(nameof(value))] string valueExpression = "")
{
    if (value.CompareTo(lowerBound) <= 0)
    {
        // throw assertion failure
    }
}

Originally posted by @Evangelink in #7206 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions