-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Description
Description
In #2298 we discovered a regression with 6.0.0 when comparing a non-generic and a generic dictionary.
Reproduction Steps
These works
[Fact]
public void NonGeneric_NonGeneric()
{
var subject = new ListDictionary
{
["id"] = 22,
["CustomerId"] = 33
};
var expected = new ListDictionary
{
["id"] = 22,
["CustomerId"] = 33
};
subject.Should().BeEquivalentTo(expected);
}
[Fact]
public void NonGeneric_Generic_cast_to_non_generic()
{
var subject = new ListDictionary
{
["id"] = 22,
["CustomerId"] = 33
};
var expected = (IDictionary)new Dictionary<object, object>
{
["id"] = 22,
["CustomerId"] = 33
};
subject.Should().BeEquivalentTo(expected);
}
[Fact]
public void Generic_NonGeneric()
{
var subject = new Dictionary<object, object>
{
["id"] = 22,
["CustomerId"] = 33
};
var expected = new ListDictionary
{
["id"] = 22,
["CustomerId"] = 33
};
subject.Should().BeEquivalentTo(expected);
}This one fails:
[Fact]
public void NonGeneric_Generic()
{
var subject = new ListDictionary
{
["id"] = 22,
["CustomerId"] = 33
};
var expected = new Dictionary<object, object>
{
["id"] = 22,
["CustomerId"] = 33
};
subject.Should().BeEquivalentTo(expected);
}Expected behavior
All tests should pass
Actual behavior
NonGeneric_Generic fails.
Regression?
Yes.
All examples above worked in 5.10.3 and with 6.0.0 NonGeneric_Generic started failing.
Known Workarounds
Cast Dictionary<,> to IDictionary or use a non-generic dictionary type like HashTable
Configuration
FA 6.12.0
.NET 8
Other information
No response
Are you willing to help with a pull-request?
Yes, please assign this issue to me.