Components: Use IAsyncDisposable#10037
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #10037 +/- ##
==========================================
- Coverage 91.06% 91.05% -0.02%
==========================================
Files 410 410
Lines 12514 12451 -63
Branches 2446 2427 -19
==========================================
- Hits 11396 11337 -59
+ Misses 570 566 -4
Partials 548 548 ☔ View full report in Codecov by Sentry. |
jperson2000
left a comment
There was a problem hiding this comment.
Nice improvement, @ScarletKuro! I see why you chose not to implement IAsyncDisposable in MudComponentBase; a majority of components don't need to dispose anything, so it makes sense to do them case-by-case.
I see some additional components which qualify for IAsyncDisposable when I do a Find All References on IDisposable:
It's very individual. If the components doesn't have async disposable instances, you can stick with The But thanks for the list. I'm sure that some of them have async disposable instances and are using |
|
Added to the v8 migration guide at #9953 |

Description
We use async code almost everywhere, so it’s necessary.
Answering some questions beforehand:
Q: Why is it
ValueTask DisposeAsyncCore()instead ofValueTask DisposeAsync(bool disposing)?A: This follows Microsoft’s recommendation. See: Explore DisposeAsync and DisposeAsyncCore methods.
Q: Why are we not implementing both
IDisposableandIAsyncDisposable? Isn’t it Microsoft’s recommendation, which comes with a big red warning?A: This applies only when the consumer needs to manage disposal. However, services and components are managed either by DI or the Blazor lifecycle, which correctly disposes of resources. Implementing both interfaces could cause more harm and confusion, in my opinion.
Q: Why
GC.SuppressFinalize(this)is not everywhere?A: Not needed if the class is sealed and there is no finilizer in the class and consumer can't add his own since it's sealed.
Type of Changes
Checklist
dev).