SonarSource / sonar-dotnet

Code analyzer for C# and VB.NET projects
https://redirect.sonarsource.com/plugins/csharp.html
GNU Lesser General Public License v3.0
774 stars 226 forks source link

Fix S3415, S2701, S2699, S2187 FN: Support NUnit 4.0 #8409

Open martin-strecker-sonarsource opened 9 months ago

martin-strecker-sonarsource commented 9 months ago

Description

With NUnit 4.0 the assertion methods are moved to a different type and namespace: https://docs.nunit.org/articles/nunit/release-notes/Nunit4.0-MigrationGuide.html#convert-classic-assert-into-nunit-4x-equivalent

We need to add support for the ClassicAssert in the NUnit.Framework;using NUnit.Framework.Legacy namespace in the following rules:

S3415, S2701, S2699, S2187 Other rules that might be affected:

Repro steps for S3415

Expected behavior

S3415 raises, because expected and actual are swapped.

Actual behavior

The issue is not raised.

Known workarounds

None.

Related information

See also #8410 for more details.

sebastien-marichal commented 1 month ago

This does not impact S3431, ExpectedExceptionAttribute has been removed since (at least) NUnit 2.9.7.