Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUnit2021 false positive for IEquatable<T> #322

Closed
pantosha opened this issue Nov 28, 2020 · 2 comments · Fixed by #327
Closed

NUnit2021 false positive for IEquatable<T> #322

pantosha opened this issue Nov 28, 2020 · 2 comments · Fixed by #327
Labels

Comments

@pantosha
Copy link

pantosha commented Nov 28, 2020

NUnit2021 fires when different types T1 and T2 are compared, but T1 implements IEquatable<T2>:

using Microsoft.Extensions.Primitives;
using NUnit.Framework;

namespace UnitTests
{
    public class Tests
    {
        [Test]
        public void Test1()
        {
            var stringValues = new StringValues("abc");
            Assert.That(stringValues, Is.EqualTo("abc")); // <-- NUnit2021 fires here. Test passes ✅.
        }
    }
}
@Dreamescaper
Copy link
Member

I'll take a look

@manfred-brands
Copy link
Member

@Dreamescaper This is similar to the code for IComparable<T>. See ComparableTypesAnalyzer.IsIComparable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants