You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that the changes in nunit/nunit#4899 caused my test code to have build error NUnit2021.
This occurs in some of the test codes like following. (Not all, it seems.)
My codes can build successfully at 36b8b1d37ce76795272b0df4b7b279f8c3cae93c.
[Test]publicvoidTest(){MyLongl0=new(0);Assert.That(l0,Is.EqualTo((MyLong)0));~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~error NUnit2021: The EqualTo constraint always fails as the actual and the expected value cannot be equal (https://github.com/nunit/nunit.analyzers/tree/master/documentation/NUnit2021.md)}
I will report again when the situation can be clearly reproduced.
In pre-4.3.1 Is.EqualTo(object?) for all but variables declared object causes an implicit cast.
The Analyzer is not interest in object but wants to check the original type. It therefore ignores the cast to get to the original type.
In NUnit 4.3.1 the addition of Is.EqualTo<T>(T) means that there is no implicit cast needed.
However if the operand had an explicit cast as in the code from the issue, the Analyzer doesn't use the resulting type but the original type defeating the intention of the writer.
The analyzer must only ignore an implicit cast, for pre-4.3.1 code, not an explicit one.
It seems that the changes in nunit/nunit#4899 caused my test code to have build error NUnit2021.
This occurs in some of the test codes like following. (Not all, it seems.)
My codes can build successfully at 36b8b1d37ce76795272b0df4b7b279f8c3cae93c.
I will report again when the situation can be clearly reproduced.
Originally posted by @smdn in nunit/nunit#4899 (comment)
The text was updated successfully, but these errors were encountered: