Analyzers 1.5.0 2023 November 10
Today, we're shipping one new release:
- xUnit.net Analyzers
1.5.0
It's been 1 month since the release of 1.4.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.4.0
to 1.5.0
.
Usage Analyzers
xUnit1012 has been updated to account for nullable reference types when passing
null
values into[InlineData]
. xunit/xunit#2189 xunit/xunit.analyzers#164Added three new analyzers to ensure that
[MemberData]
usage with data generation methods have compatible arguments: xunit/xunit#2189 xunit/xunit.analyzers#165Added four new analyzers to help users return
TheoryData<>
from[MemberData]
: xunit/xunit#2189 xunit/xunit.analyzers#166- xUnit1037 is reported when you have too few generic types in
TheoryData<>
for your test method. - xUnit1038 is reported when you have too many generic types in
TheoryData<>
for your test method. - xUnit1039 is reported when one of the generic types in
TheoryData<>
is not compatible with the corresponding parameter in your test method. - xUnit1040 is reported when your generic type in
TheoryData<>
is a nullable reference type but the test method parameter is not nullable.
- xUnit1037 is reported when you have too few generic types in
Assertion Analyzers
Analysis in xUnit2014 was updated to remove support for
ValueTask
in theAssert.Throws
since it is no longer supported as of 2.6.1 (due to compiler ambiguity problems with async lambdas).Added xUnit2021 to warn developers when async assertions are not being awaited. This includes:
Assert.PropertyChangedAsync
Assert.RaisesAnyAsync
Assert.RaisesAsync
Assert.ThrowsAnyAsync
Assert.ThrowsAsync
This feature is limited to just assertions shipped with xUnit.net; it does not include third party assertions nor any calls to non-assertion async methods. Note that while CS4014 can report un-awaited tasks, it will only do so if the method is already marked as
async
. xUnit2021 will always be reported regardless of whether the test method isasync
or not (and is reported as an Error, while CS4014 is reported as a Warning). xunit/xunit#2346Added xUnit2022 to suggest to developers that they should not use a negated expression with
Assert.True
orAssert.False
, and should instead use a non-negated expression with the opposite assertion. xunit/xunit#1435