Skip to content

Warning CS8620 after update to >= 0.70 #3394

Closed

Description

@volkmnv

After updating to TUnit >= 0.70, the following test raises the warning CS8620 at 'expected'

[Test]
[MethodDataSource(nameof(Data))]
public async Task StartActivity_WithCurrentActivity_CanBeStarted(string? value, string? expected)
{
    await Assert.That(value).IsEqualTo(expected);
}

and this raises the warning at 'Assert.That(value)'

[Test]
[MethodDataSource(nameof(Data))]
public async Task StartActivity_WithCurrentActivity_CanBeStarted(object? value, object? expected)
{
    await Assert.That(value).IsEqualTo(expected);
}

Activity

  1. changed the title [-]Warning CS8620 after update to > 0.70[/-] [+]Warning CS8620 after update to >= 0.70[/+] on Oct 15, 2025
  2. volkmnv commented on Oct 16, 2025

    @volkmnv
    Author

    I can confirm that the first case is fixed in 0.72, but the second case still gives a warning

  3. volkmnv commented on Oct 16, 2025

    @volkmnv
    Author

    After updating to 0.72 I also get a new CS8619 in this test at 'MethodToTest(data!)'

    [Test]
    [MethodDataSource(nameof(Data))]
    public async Task Test(object? data)
    {
        await Assert.That(() => MethodToTest(data!)).Throws<ArgumentException>();
    
        Task<object> MethodToTest(object value)
        {
            if (value is null)
                throw new ArgumentNullException(nameof(value));
            return Task.FromResult(new object());
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions