Conversation
| <value>Implementation type '{0}' can't be converted to service type '{1}'</value> | ||
| </data> | ||
| <data name="AsyncDisposableServiceDispose" xml:space="preserve"> | ||
| <value>'{0}' type only implements IAsyncDisposable. Use DisposeAsync to dispose the container.</value> |
There was a problem hiding this comment.
I'm not 100% sure this is reasonable. There might be cases where something is added to the container out of somebody's control and it'll cause hosting to just crash and burn when the container gets disposed.
There was a problem hiding this comment.
They can always DisposeAsync().Wait() to workaround
There was a problem hiding this comment.
Hosting is the one calling Dispose on the container.
There was a problem hiding this comment.
Maybe make it an option so people can work around it in cases where they don't own the container (like Azure Functions)? By default we can throw but you can turn it off to get the sync over async behavior back.
There was a problem hiding this comment.
Both us and Azure Functions are going to move to DisposeAsync() in time for 3.0 and I doubt that there are a lot of types that implement only IAsyncDisposable
There was a problem hiding this comment.
Ah true, so I guess this error would never happen unless you explicitly called Dispose on the host.
There was a problem hiding this comment.
Maybe TestHost scenarios have the potential to break?
There was a problem hiding this comment.
Nope, WebHost.Dispose() blocks StopAsync and provider.DisposeAsync calls would get moved there
https://github.com/aspnet/AspNetCore/blob/master/src/Hosting/Hosting/src/Internal/WebHost.cs#L350
There was a problem hiding this comment.
You shouldn't call Dispose in StopAsync. Thats not right. Stopping needs to happen before disposing, not during.
There was a problem hiding this comment.
You are right, Dispose will call DisposeAsync and block.
|
Seems like we decided that we have a reasonable migration story for customers with current implementation. Merging. |
|
What’s the migration story? |
|
WebHost and TestHost continue working as before, customers would have to change their calls to Dispose to DisposeAsync if they use async disposable only types. |
|
Get this into ASP.NET Core and EF as soon as possible. |
Commit migrated from dotnet/extensions@a58a80b
Commit migrated from dotnet/extensions@a58a80b
Commit migrated from dotnet/extensions@a58a80b
Commit migrated from dotnet/extensions@a58a80b
Fixes: #426
Implement IAsyncDisposable on ServiceProvider and scopes.
.Disposethrows if there is a service that only implementsIAsyncDisposable