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

NUnit.Analyzers 4.3.0 missed an Assert.IsAssignableFrom that caused a build error after upgrading to latest NUnit 4.2.2

Open MCPtz opened this issue 1 year ago • 2 comments

NUnit.Analyzers 4.3.0 missed an Assert.IsAssignableFrom that caused a build error after upgrading to NUnit 4.2.2, from NUnit 3.13.3.

That is there was no build error or warning when on NUnit 3.13.3 and building with NUnit.Analyzers 4.3.0.

Or if there was a warning, I missed it because I had tens of thousands of changes to make.

I suggest this becomes a build error for NUnit.Analyzers.

Fixed manually by doing this: Assert.IsAssignableFrom<ClassName>(objectVariable); -> Assert.That(objectVariable, Is.AssignableFrom(typeof(ClassName)));

MCPtz avatar Oct 28 '24 20:10 MCPtz

@OsirisTerje This slipped through because when I ensured all tests in the legacy assembly were converted, I forgot to check the test coverage. Assert.IsAssignableFrom and Assert.IsNotAssignableFrom are not tested. I will update the tests and create a analyzer rule for these.

Same for IsInstanceOf and IsNotInstanceOf.

manfred-brands avatar Oct 28 '24 23:10 manfred-brands

I'll close #742 as a duplicate of this

mikkelbu avatar Oct 30 '24 08:10 mikkelbu