Skip to content

revert(DockView): revert implement IAsyncDisposable interface#978

Merged
ArgoZhang merged 1 commit intomasterfrom
revert-title-bar
Apr 20, 2026
Merged

revert(DockView): revert implement IAsyncDisposable interface#978
ArgoZhang merged 1 commit intomasterfrom
revert-title-bar

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Apr 20, 2026

Link issues

fixes #977

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Revert DockView async disposal and related cleanup behavior to restore the previous non-disposable components.

Enhancements:

  • Remove IAsyncDisposable implementation from DockViewTitleBar and its async dispose logic.
  • Remove DockViewComponent override of Dispose that cleared callbacks and component state.

Copilot AI review requested due to automatic review settings April 20, 2026 06:05
@bb-auto bb-auto bot added the chore label Apr 20, 2026
@bb-auto bb-auto bot added this to the v9.2.0 milestone Apr 20, 2026
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 20, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Reverts the previous implementation of async and custom disposal in DockView components, removing IAsyncDisposable from DockViewTitleBar and the override of Dispose in DockViewComponent, effectively restoring default lifecycle behavior and preventing DockView from clearing callbacks and component state on disposal.

Updated class diagram for DockView disposal behavior

classDiagram
class DockViewTitleBar {
  +OnClickBarCallback
  +OnClickBar() Task
}

class DockViewComponent {
  -Visible
  -IsLock
  -Key
  +OnClickBar() Task
  +SetVisible(visible) void
  +SetLock(isLock) void
}
Loading

Class diagram for reverted async and custom disposal in DockView

classDiagram
class IAsyncDisposable {
  <<interface>>
  +DisposeAsync() ValueTask
}

class DockViewTitleBar_Previous {
  +OnClickBarCallback
  +OnClickBar() Task
  +DisposeAsync() ValueTask
  #DisposeAsync(disposing bool) ValueTask
}

class DockViewComponent_Previous {
  +OnClickTitleBarCallback
  +OnClickBar() Task
  +Dispose(disposing bool) void
}

DockViewTitleBar_Previous ..|> IAsyncDisposable
Loading

File-Level Changes

Change Details Files
Remove IAsyncDisposable implementation and custom async dispose logic from DockViewTitleBar, reverting it to a simple component without explicit disposal behavior.
  • Remove IAsyncDisposable from the DockViewTitleBar class declaration
  • Delete the protected DisposeAsync(bool disposing) helper that nulled OnClickBarCallback
  • Delete the public DisposeAsync implementation that called DisposeAsync(true) and suppressed finalization
src/components/BootstrapBlazor.DockView/Components/DockViewTitleBar.razor.cs
Remove DockViewComponent's custom Dispose override that cleared callbacks and removed persisted component state on disposal.
  • Remove Dispose(bool disposing) override that nulled OnClickTitleBarCallback
  • Remove call to DockView.RemoveComponentState(Key) during disposal
  • Allow base component to manage disposal without DockView-specific cleanup
src/components/BootstrapBlazor.DockView/Components/DockViewComponent.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#977 Remove the IAsyncDisposable implementation and related async dispose methods from DockView title bar component(s).
#977 Revert additional disposal-related logic introduced with the IAsyncDisposable change in DockView components (e.g., custom Dispose/cleanup behavior).

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • By removing the Dispose override from DockViewComponent, DockView.RemoveComponentState(Key) is no longer called, which may leave stale component state hanging around; if this revert is intentional, consider documenting or moving that cleanup logic elsewhere.
  • The revert drops explicit nulling of OnClickTitleBarCallback/OnClickBarCallback; if these callbacks can capture long-lived references, you may want to confirm that their lifetimes are now acceptable or add an alternative cleanup mechanism.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- By removing the `Dispose` override from `DockViewComponent`, `DockView.RemoveComponentState(Key)` is no longer called, which may leave stale component state hanging around; if this revert is intentional, consider documenting or moving that cleanup logic elsewhere.
- The revert drops explicit nulling of `OnClickTitleBarCallback`/`OnClickBarCallback`; if these callbacks can capture long-lived references, you may want to confirm that their lifetimes are now acceptable or add an alternative cleanup mechanism.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ArgoZhang ArgoZhang merged commit 252e0f4 into master Apr 20, 2026
4 checks passed
@ArgoZhang ArgoZhang deleted the revert-title-bar branch April 20, 2026 06:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reverts prior disposal-related changes in DockView components (per issue #977), removing explicit async/sync disposal implementations.

Changes:

  • Removed IAsyncDisposable implementation and async dispose logic from DockViewTitleBar.
  • Removed the Dispose(bool) override from DockViewComponent.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/components/BootstrapBlazor.DockView/Components/DockViewTitleBar.razor.cs Drops IAsyncDisposable and associated cleanup logic from the title bar component.
src/components/BootstrapBlazor.DockView/Components/DockViewComponent.razor.cs Removes the component’s custom disposal override (previously used for cleanup).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 191 to 194
internal void SetVisible(bool visible) => Visible = visible;

internal void SetLock(bool isLock) => IsLock = isLock;

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

if (OnClickTitleBarCallback != null)
{
OnClickTitleBarCallback = null;
}

DockView.RemoveComponentState(Key);
}
}
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

DockViewComponent no longer overrides Dispose(bool), so DockView.RemoveComponentState(Key) is never called. _componentStates in DockViewV2 holds a strong reference to DockViewComponent via DockViewComponentState.Component, which can cause memory leaks and can also break re-adding a component with the same Key (since TryAdd will fail while the stale entry remains). Consider restoring the Dispose(bool) override (calling base.Dispose(disposing) and using DockView?.RemoveComponentState(Key)), so component state is removed when the component is disposed.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

revert(DockView): revert implement IAsyncDisposable interface

2 participants