Table of Contents

Analyzers 1.3.0 2023 September 17

Today, we're shipping three new releases:

  • xUnit.net Core Framework v2 2.5.1 (release notes)
  • xUnit.net Analyzers 1.3.0
  • xUnit.net Visual Studio adapter 2.5.1 (release notes)

It's been 2 months since the release of 1.2.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.2.0 to 1.3.0.

Usage Analyzers

  • We have updated xUnit1028 to only trigger when the user is has provided an invalid test method return type with a test method decorated with [Fact] or [Theory]. Since third party libraries may allow other returned types, they will no longer trigger this warning. (Third party extensions which provide their own analyzers should consider having a similar rule if you change the valid return types for test methods, including the case where you provide FactAttribute overrides but still have the same return type limitations.) xunit/xunit#2749

  • We have added a fixer for xUnit1029 which removes the [Fact] or [Theory] attribute from the local function.

  • We have introduced a new analyzer (xUnit1030) that will flag usage of ConfigureAwait on tasks as being problematic. Calling this on a task inside a test method will cause the remainder of the test method to be run on a thread pool thread rather than the original thread (which is used to limit the number of tests that run concurrently in parallel). xunit/xunit#2628

  • We have introduced a new analyzer (xUnit1031) that will flag usage of blocking task operations in a test method as being problematic. The operations that are flagged include:

  • Task.GetAwaiter().GetResult() * Task.Wait() * Task.WaitAll() * Task.WaitAny() * Task<T>.GetAwaiter().GetResult() * Task<T>.Result * ValueTask.GetAwaiter().GetResult() * ValueTask<T>.GetAwaiter.GetResult() * ValueTask<T>.Result Calling these inside a test method could cause performance issues and/or cause the test to become deadlocked, due to the limited number of threads available for running tests in parallel. xunit/xunit#1390

  • We have introduced a new analyzer (xUnit1032) that will flag test classes embedded inside a generic class. As there is no way for xUnit.net to know how to close the outer generic class to create instances of the inner test class, this is an error. xunit/xunit#2528