Skip to content

TestApplication dispose implementation looks wrong #6726

Description

@Youssef1313

/// <inheritdoc />
public void Dispose()
=> (_host as IDisposable)?.Dispose();
#if NETCOREAPP
/// <inheritdoc />
public ValueTask DisposeAsync()
=> _host is IAsyncDisposable asyncDisposable
? asyncDisposable.DisposeAsync()
: ValueTask.CompletedTask;
#endif

If _host is IDisposable but not IAsyncDisposable (e.g, ServerTestHost and TestHostControllersTestHost), and TestApplication.DisposeAsync is called, it will do nothing. This doesn't make sense.

Generally speaking, there is excessive usage of unnecessary IAsyncDisposable in MTP (IMO), but this one specifically looks wrong.

Metadata

Metadata

Assignees

Labels

area/mtpMicrosoft.Testing.Platform core library.

Type

Fields

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions