nunit.analyzers icon indicating copy to clipboard operation
nunit.analyzers copied to clipboard

[bug] Code fix for NUnit2005 does not correctly fix Assert.AreEqual if named parameters are used in unexpected order

Open Bartleby2718 opened this issue 1 year ago • 4 comments

Given the following (note the order of named parameters)

    [Test]
    public void Test1()
    {
        var actual = 1;
        Assert.AreEqual(actual: actual, expected: 1);
    }

NUnit.Analyzers cannot fix NUnit2005 correctly.

The above should suffice, but I also created a repo: https://github.com/Bartleby2718/NUnit2005-Assert-AreEqual-repro

Bartleby2718 avatar Mar 31 '24 02:03 Bartleby2718

I guess we need to add some logic to ClassicModelAssertUsageCodeFix, so it will use NameColon if it is supplied, then this will also fix the same issue in other codefixes deriving from this base-class. I'll see if I have time for this next week.

mikkelbu avatar Mar 31 '24 18:03 mikkelbu

@mikkelbu I just filed a PR for this!

Bartleby2718 avatar Mar 31 '24 20:03 Bartleby2718

@mikkelbu @manfred-brands Can you assign this issue and the corresponding PR to me?

Bartleby2718 avatar Apr 08 '24 03:04 Bartleby2718

@Bartleby2718 Done. I'm in the process of reviewing your PR.

manfred-brands avatar Apr 08 '24 03:04 manfred-brands