Skip to content

OwningComponentBase implements IAsyncDisposable #62583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

rolandVi
Copy link
Contributor

@rolandVi rolandVi commented Jul 7, 2025

OwningComponentBase implements IAsyncDisposable

Description

This pull request enhances the OwningComponentBase class by adding support for asynchronous disposal, improving resource management, and updating tests to validate the new functionality. The most important changes include implementing the IAsyncDisposable interface, adding new methods for asynchronous disposal, updating the public API, and introducing new test cases to ensure proper behavior.

Enhancements to OwningComponentBase:

  • src/Components/Components/src/OwningComponentBase.cs: Updated the OwningComponentBase class to implement the IAsyncDisposable interface. Added DisposeAsync, DisposeAsyncCore, and updated the Dispose method to handle both synchronous and asynchronous disposal of the service scope.
  • The changes were made based on this guidance.

Public API updates:

Testing improvements:

Fixes #25873

@rolandVi rolandVi requested a review from a team as a code owner July 7, 2025 11:36
@github-actions github-actions bot added the area-blazor Includes: Blazor, Razor Components label Jul 7, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jul 7, 2025
@ilonatommy ilonatommy added this to the .NET 10 Planning milestone Jul 7, 2025
@ilonatommy ilonatommy added the breaking-change This issue / pr will introduce a breaking change, when resolved / merged. label Jul 7, 2025
@dotnet-policy-service dotnet-policy-service bot added the needs-breaking-change-announcement Indicates that breaking change announcement shuold be posted and linked to this PR label Jul 7, 2025
@rolandVi
Copy link
Contributor Author

rolandVi commented Jul 7, 2025

@dotnet-policy-service agree

@ilonatommy ilonatommy removed the community-contribution Indicates that the PR has been added by a community member label Jul 7, 2025
Reverted one change
rolandVi and others added 2 commits July 7, 2025 14:54
Removed `OwningComponentBase.DisposeAsync()` from the PublicAPI as the implementation is private now
Copy link
Member

@javiercn javiercn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@rolandVi
Copy link
Contributor Author

rolandVi commented Jul 8, 2025

/ba-g failure connected with known issue

@ilonatommy ilonatommy merged commit 82d75a0 into dotnet:main Jul 8, 2025
27 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components breaking-change This issue / pr will introduce a breaking change, when resolved / merged. needs-breaking-change-announcement Indicates that breaking change announcement shuold be posted and linked to this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OwningComponentBase doesn't implement IAsyncDisposable
4 participants