Table of Contents

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 caused Enum.Parse to fail. Additionally we have opened an issue against .NET to try to get a "known safe to roundtrip" value from Enum.ToString() that would make this workaround unnecessary, as all overloads of Enum.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 to xunit.assert, along with the existing netstandard1.1 target. This new target enables assertion overloads that support Span<T> and Memory<T> (and their read-only counterparts), overloads that support ValueTask and ValueTask<T> for asynchronous operations (in places where we already supported Task and Task<T>), and overloads that support ImmutableHashSet and ImmutableDictionary. 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 either Task or void 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 of IEqualityComparer<T>). Previously this would just surface as the exception being the cause of the failure; now it will show an Assert.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#2800

  • We have added special handling for KeyValuePair<TKey, TValue> when using Assert.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 of IEnumerable<KeyValuePair<>> as well. xunit/xunit#2803

  • BUG: Fixed an issue where some implementations of GetHashCode were throwing NotImplementedException, causing some code paths for Assert.Equal to throw when the hash code was needed. xunit/xunit#2804

  • BUG: 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