You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Assert.That(() => GetNameAsync()) still warns CS8619 (the lambda case of #3422) #7795
I've searched existing issues to ensure this isn't a duplicate
I've read the documentation and this isn't expected behavior
I'm using the latest version of TUnit
Description
Passing a lambda that returns a Task<T> of a non-nullable reference type to Assert.That without async gives CS8619, because the overload takes Func<Task<TValue?>> and Task<string> is not Task<string?>. With warnings as errors the build fails.
This is the second case of #3422. #3429 fixed the Assert.That(value) warning from that issue and added Issue3422Tests for both cases, but its lambda test still warns on main:
Issue3422Tests.cs(24,33): warning CS8619: Nullability of reference types in value of type 'Task<object>' doesn't match target type 'Task<object?>'.
TUnit.Assertions.Tests does not treat warnings as errors, so that test passes anyway. #3582 fixed the same warning for Assert.That(Task<T>), the task itself; the lambda form still has it. An async () => await GetNameAsync() lambda does not warn.
Expected Behavior
No warning: the lambda's task result is non-nullable, which the assertion can take as it is.
Actual Behavior
warning CS8619 on the Assert.That(() => ...) line (an error with warnings as errors).
Activity
chore: Treat warnings as errors in test projects
fix(assertions): suppress CS8619/CS8621 for a Task<T> delegate passed…