Skip to content

[Mvc] WebApplicationFactory should implement IAsyncDisposable #29455

Closed
@javiercn

Description

@javiercn

We currently only implement Dispose and call Wait() on the host StopAsync() within Dispose.

Ideally we want to avoid this and simply implement IAsyncDisposable with IDisposable just being a fallback for it.

The only issue here is that currently the factory can be use as an xUnit fixture out of the box, but unfortunately I believe xUnit doesn't support IAsyncDisposable in addition to IDisposable, since they have their own interface for it (IAsyncLifetime).

This means that for using IAsyncDisposable users will either have to extend the default factory and make it implement IAsyncLifetime or create the factory within the test method and use an await using statement to dispose of it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-fewThis issue impacts only small number of customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-mvc-testingMVC testing packagegood first issueGood for newcomers.help wantedUp for grabs. We would accept a PR to help resolve this issueseverity-minorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions