Table of Contents

Analyzers 1.7.0 2023 December 8

Today, we're shipping three new releases:

  • xUnit.net Core Framework v2 2.6.3 (release notes)
  • xUnit.net Analyzers 1.7.0
  • xUnit.net Visual Studio adapter 2.5.5 (release notes)

It's been 3 weeks since the release of 1.6.0.

As always, we'd like to thank all the users who contributed to the success of xUnit.net through usage, feedback, and code. 🎉

Important

The minimum version for the analyzers is now Visual Studio 2022 17.2, as version 17.0 is no longer supported by Microsoft. This aligns with version Roslyn 4.2. Notably, the latest version of C# that's supported in Roslyn 4.2 is C# 10 (with some support for features that were experimental and ended up in C# 11), so some language features beyond C# 10 may cause false positives in analyzers, as well as not picking up any bug fixes in Roslyn since this release.

Release Notes

These release notes are a comprehensive list of changes from 1.6.0 to 1.7.0.

Usage Analyzers

  • Added xUnit1041 which verifies that any fixture arguments in the constructor of your test class have an appropriate fixture source. This can also highlight an issue where a developer places a test collection definition in the wrong assembly, as this can be difficult to identify. xunit/xunit#2311

  • Added xUnit1042 which suggests to developers that any member-based data source could use TheoryData<> to get type-safe compiler support for their data, as well as being able to take advantage of several of the new TheoryData-related analyzers that were added in 1.6.0. xunit/xunit#1244

  • BUG: Fixed an issues with xUnit1010, xUnit1011, and xUnit1012 that might cause a yellow-bar in Visual Studio showing an ArgumentOutOfRangeException from InlineDataMustMatchTheoryParameters. xunit/xunit#2823

  • BUG: Fixed two issues with xUnit1035, xUnit1036, and xUnit1039 that was causing false positives with some usages of arrays when passing to a params array in the test method. xunit/xunit#2826 xunit/xunit#2827

Assertion Analyzers

  • Added xUnit2024 which detects some usage of Assert.True or Assert.False with equality statements using constant values of strings, integral values, floating point values, decimal values, or enum values. A fixer is available that will convert to Assert.Equal or Assert.NotEqual as appropriate. xunit/xunit#1503

  • Added xUnit2025 which detects some usage of Assert.True or Assert.False with equality statements that compare against literal true or false values. A fixer is available that will simplify the expression (and swap to the opposite assertion function, if needed). xunit/xunit#1503

  • BUG: Fixed an issue with the fixer for xUnit2023 that caused a yellow-bar exception in Visual Studio.