"System.ArgumentException : Cannot compare" when the element is a list
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
NUnit Framework |
Fix Released
|
High
|
Charlie Poole | ||
NUnit V2 |
Fix Released
|
Medium
|
Charlie Poole |
Bug Description
Relevant discussion can be found here. https:/
This code throws me a System.
public class IntListEqualCom
{
public bool Equals(List<int> x, List<int> y)
{
}
public int GetHashCode(
{
}
}
[Test]
public void IntListListTest()
{
var list1 = new List<int>() {2, 3};
var list2 = new List<int>() {2, 3};
var list11 = new List<List<int>>() {list1};
var list22 = new List<List<int>>() { list2 };
var comparer = new IntListEqualCom
}
It seems that Nunit can't compare if the elements are of the type List?
Here's the complete stack trace:
failed: System.
at NUnit.Framework
at NUnit.Framework
at NUnit.Framework
at NUnit.Framework
at NUnit.Framework
at NUnit.Framework
at NUnit.Framework
at NUnit.Framework
at NUnit.Framework
Changed in nunitv2: | |
status: | New → Confirmed |
Changed in nunitv2: | |
status: | Confirmed → Triaged |
importance: | Undecided → Medium |
milestone: | none → 2.6.0 |
Changed in nunitv2: | |
assignee: | nobody → Charlie Poole (charlie.poole) |
status: | Triaged → In Progress |
Changed in nunit-3.0: | |
milestone: | none → 2.9.6 |
Changed in nunit-3.0: | |
status: | New → Triaged |
importance: | Undecided → High |
Changed in nunitv2: | |
status: | Fix Committed → Fix Released |
Changed in nunit-3.0: | |
assignee: | nobody → Charlie Poole (charlie.poole) |
Changed in nunit-3.0: | |
status: | Triaged → Fix Committed |
Changed in nunit-3.0: | |
status: | Fix Committed → Fix Released |
This fixes the problem of NUnit using an external comparer designed for a particular type inappropriately.
In addition, it allows use of generic comparers when comparing lists and other ienumerables. Multiple Using clauses may now appear, and will be used on the appropriate types.