Table of Contents

Analyzers 1.9.0 2024 January 4

Today, we're shipping two new releases:

  • xUnit.net Core Framework v2 2.6.5 (release notes)
  • xUnit.net Analyzers 1.9.0

It's been 2 weeks since the release of 1.8.0.

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 1.8.0 to 1.9.0.

Usage Analyzers

  • BUG: We fixed an issue in xUnit1030 that was raising a diagnostic inappropriately for using ConfigureAwait inside of a lambda expression. xunit/xunit.analyzers#177

  • BUG: We fixed an issue in xUnit1031 that was raising a diagnostic inappropriately for code using blocking Task methods inside of a lambda expression. xunit/xunit#2856

  • BUG: We fixed an issue in xUnit1034 that was misidentifying array initializers in [InlineData] as being null. xunit/xunit#2852

Assertion Analyzers

  • Added xUnit2026 to detect when developers called Assert.Equal or Assert.NotEqual with two sets, using the function overload for comparisons. Due to the way sets are implemented internally, a full implementation of IEqualityComparer<T> is required, because the implementations of Equals and GetHashCode must be consistent (so just passing the equivalent of Equals as a function is not sufficient for proper comparisons). xunit/xunit#2840

  • Added xUnit2027 to detect when developers called Assert.Equal or Assert.NotEqual with a set (like HashSet) and a linear collection (like an array or list). Since sets are not stored in linear fashion, they have an unpredictable enumeration order, which can cause false positives or false negatives during testing. Applying an order to the set (for example, using LINQ's OrderBy extension method) ensures that the set becomes linear with a predictable order.