Skip to content

Problem with IAsyncLifetime #96

@tisonv

Description

@tisonv

I'm using xUnit v3 and an AssemblyFixture to setup my containers at startup. Everything works correctly.

Creedengo warns about a GCI93 Consider returning a Task directly instead of a single await in both InitializeAsync and DisposeAsync
I didn't find a way to comply.

I'm not sure if that's a false positive or something I do not know how to do properly.

This is a shortened version of it:

public sealed class AssemblyFixture : IAsyncLifetime
{
    private readonly OracleContainer _oracleContainer;
    private readonly RabbitMqContainer _rabbitMqContainer;

    public AssemblyFixture()
    {
       [... Init containers...]
    }

    public async ValueTask DisposeAsync()
    {
        await Task.WhenAll(
            _oracleContainer.DisposeAsync().AsTask(),
            _rabbitMqContainer.DisposeAsync().AsTask()
        );
    }

    public async ValueTask InitializeAsync()
    {
        await Task.WhenAll(
            _oracleContainer.StartAsync(),
            _rabbitMqContainer.StartAsync()
        );
    }
  [...]
}

Thank you for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    💉 bugSomething isn't working

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions