Core Framework v2 2.6.0 2023 October 31
Today, we're shipping one new release:
- xUnit.net Core Framework v2
2.6.0
It's been 2 weeks since the release of 2.5.3
.
As always, we'd like to thank all the users who contributed to the success of xUnit.net through usage, feedback, and code. 🎉
Release Notes
These release notes are a comprehensive list of changes from 2.5.3
to 2.6.0
.
Core Framework
- BUG: Fixed an issue where trying to use an enum with a negative value in
[InlineData]
where the current locale is one which uses Unicode U+2212 as the minus sign for integers rather than Unicode U+002D, which causedEnum.Parse
to fail. Additionally we have opened an issue against .NET to try to get a "known safe to roundtrip" value fromEnum.ToString()
that would make this workaround unnecessary, as all overloads ofEnum.ToString()
that take format providers (aka cultures) are marked as obsolete and the format provider is ignored. xunit/xunit#2796 dotnet/runtime#93663
Assertion Library
We have added a new
net6.0
target toxunit.assert
, along with the existingnetstandard1.1
target. This new target enables assertion overloads that supportSpan<T>
andMemory<T>
(and their read-only counterparts), overloads that supportValueTask
andValueTask<T>
for asynchronous operations (in places where we already supportedTask
andTask<T>
), and overloads that supportImmutableHashSet
andImmutableDictionary
. Developers whose test projects target .NET 6 (or later) will automatically get access to these new assertion methods. Note that this may introduce new compiler ambiguities due to the additional overloads; for more information, see issue 2793.
Important note:ValueTask
support only applies to the assertion library. Test methods must return eitherTask
orvoid
if they are async;ValueTask
is not supported in this scenario until v3.We have added a try/catch inside
Assert.Equals
to catch when exceptions are thrown when calling a user-defined comparer (either a comparer function, or an implementation ofIEqualityComparer<T>
). Previously this would just surface as the exception being the cause of the failure; now it will show anAssert.Equal() Failure
message (which includes the collection including a pointer into the collection, when the thing being compared is an item in a collection) as well as the exception that was thrown. This should greatly help in debugging user-provided comparison functions to understand which data item caused the exception. xunit/xunit#2800We have added special handling for
KeyValuePair<TKey, TValue>
when usingAssert.Equal
(including when what you're comparing is a collection of key/value pairs). We already had special handling for dictionaries with special equality handling for the key and the value; this extends that behavior to the "dictionary-like" situation ofIEnumerable<KeyValuePair<>>
as well. xunit/xunit#2803BUG: Fixed an issue where some implementations of
GetHashCode
were throwingNotImplementedException
, causing some code paths forAssert.Equal
to throw when the hash code was needed. xunit/xunit#2804BUG: Fixed a significant performance regression related to
Assert.Equal
with collections. In some situations, the comparison could take as much as 10x (1000%) longer as in 2.4.2. Most of the performance issues have been resolved, and the new collection assertion is within 10% of the older assertions (and in some cases on .NET 6+, the new collection comparison can be a few orders of magnitude faster, for arrays of unmanaged values). xunit/xunit#2806