Skip to content

False positive on NUnit2050 #901

Closed

Description

@dfev77

We are using a helper like the one below, and we get an NUnit2050 error (NUnit 4 no longer supports string.Format specification for Assert)
As you see we are just setting some predefined timeout&retry interval on Assert.That
Wonder if the analyzer could be enhanced to not treat such cases as a violation on NUnit2050.

    public static Desk AssertThat<TWindow>(
        this Desk desk,
        Func<TWindow, object> valueProvider,
        IConstraint expression,
        NUnitString message = default,
        [CallerArgumentExpression(nameof(valueProvider))] string actualExpression = "",
        [CallerArgumentExpression(nameof(expression))] string constraintExpression = ""
        ) where TWindow : DeskWindow
    {
        var window = desk.Capture<TWindow>();

        Assert.That(
            (ActualValueDelegate<object>)(() => valueProvider.Invoke(window)),
            new DelayedConstraint(expression, 3000, 300,
            message, actualExpression, constraintExpression);

        return desk;
    }

Activity

  1. manfred-brands commented on Jul 29, 2025

    @manfred-brands
    Member

    @dfev77 I can reproduce the error and updated the rule to allow this when the argument is in fact a parameter with a CallerArgumentExpression attribute.

  2. added this to the Release 4.10 milestone on Aug 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions