Conversation
Reviewer's GuideRefactors DockView V2 and related components to adopt async disposal patterns, updating title bar and component cleanup logic and removing the previous synchronous IDisposable implementation. Sequence diagram for async disposal flow in DockViewV2sequenceDiagram
participant BlazorRenderer
participant DockViewV2
participant ThemeProviderService
participant BaseComponent
BlazorRenderer->>DockViewV2: trigger async dispose
activate DockViewV2
DockViewV2->>DockViewV2: DisposeAsync(bool disposing = true)
DockViewV2->>ThemeProviderService: unsubscribe ThemeChangedAsync
ThemeProviderService-->>DockViewV2: confirmation
DockViewV2->>BaseComponent: base.DisposeAsync(disposing)
activate BaseComponent
BaseComponent-->>DockViewV2: ValueTask completed
deactivate BaseComponent
DockViewV2-->>BlazorRenderer: ValueTask completed
deactivate DockViewV2
Class diagram for updated async disposal in DockView componentsclassDiagram
class DockViewTitleBar {
+Func~Task~ OnClickBarCallback
+Task OnClickBar()
+ValueTask DisposeAsync()
+ValueTask DisposeAsync(bool disposing)
}
class IAsyncDisposable {
<<interface>>
+ValueTask DisposeAsync()
}
class DockViewV2 {
string? Name
string? LocalStorageKey
...
+void UpdateComponentState(string? key, bool visible, bool? isLock)
+ValueTask DisposeAsync(bool disposing)
}
class DockViewComponent {
string? Key
+Action? OnClickTitleBarCallback
+void Dispose(bool disposing)
}
DockViewTitleBar ..|> IAsyncDisposable
DockViewComponent --> DockViewV2 : DockView
DockViewComponent : overrides Dispose(bool disposing)
DockViewV2 : overrides DisposeAsync(bool disposing)
DockViewTitleBar : clears OnClickBarCallback on DisposeAsync(bool disposing)
DockViewComponent : clears OnClickTitleBarCallback in Dispose(bool disposing)
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
DockViewTitleBar, consider aligning the disposal pattern with the base component (e.g., overridingDispose/DisposeAsyncinstead of introducing a customDisposeAsync(bool disposing)plusGC.SuppressFinalize, which is unnecessary without a finalizer and may be inconsistent with other components). - The
DisposeAsync(bool disposing)pattern inDockViewTitleBarcurrently only nullsOnClickBarCallback; if you intend to support subclass overrides, document or enforce how derived classes should chain base disposal to avoid incomplete cleanup.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `DockViewTitleBar`, consider aligning the disposal pattern with the base component (e.g., overriding `Dispose`/`DisposeAsync` instead of introducing a custom `DisposeAsync(bool disposing)` plus `GC.SuppressFinalize`, which is unnecessary without a finalizer and may be inconsistent with other components).
- The `DisposeAsync(bool disposing)` pattern in `DockViewTitleBar` currently only nulls `OnClickBarCallback`; if you intend to support subclass overrides, document or enforce how derived classes should chain base disposal to avoid incomplete cleanup.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
Updates DockView extension package to 10.0.8-beta06 and adjusts component disposal behavior to improve cleanup (notably event unsubscription and callback release) per issue #975.
Changes:
- Update
DockViewV2disposal to use the async dispose override and unsubscribe fromThemeProviderService.ThemeChangedAsync. - Add
IAsyncDisposableimplementation toDockViewTitleBarand clear click callback on disposal; clearDockViewComponenttitlebar callback during disposal. - Bump
BootstrapBlazor.DockViewpackage version to10.0.8-beta06.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/components/BootstrapBlazor.DockView/Components/DockViewV2.razor.cs | Switch disposal approach to async override and unsubscribe from theme change event. |
| src/components/BootstrapBlazor.DockView/Components/DockViewTitleBar.razor.cs | Implement async disposal and clear callback reference on dispose. |
| src/components/BootstrapBlazor.DockView/Components/DockViewComponent.razor.cs | Clear titlebar click callback during component disposal. |
| src/components/BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj | Bump package version to 10.0.8-beta06. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// <para lang="en">DockViewV2 component</para> | ||
| /// </summary> | ||
| public partial class DockViewV2 : IDisposable | ||
| public partial class DockViewV2 |
There was a problem hiding this comment.
Removing IDisposable from the public DockViewV2 type is a breaking API change for any consumers that were relying on DockViewV2 being disposable (e.g., storing it as IDisposable). If the goal is to switch to the base class async dispose pattern, consider preserving compatibility by keeping IDisposable on the public surface (or providing an explicit IDisposable.Dispose that forwards to the async dispose path), or document this as an intentional breaking change for the beta bump.
| { | ||
| ThemeProviderService.ThemeChangedAsync -= OnThemeChangedAsync; | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc/> | ||
| /// </summary> | ||
| public void Dispose() | ||
| { | ||
| Dispose(true); | ||
| GC.SuppressFinalize(this); | ||
| return base.DisposeAsync(disposing); |
There was a problem hiding this comment.
DisposeAsync override order is inconsistent with other BootstrapModuleComponentBase components in this repo (they typically await base.DisposeAsync(disposing) first, then run component-specific cleanup; e.g. BootstrapBlazor.Term/Components/Term.razor.cs:226-235, BootstrapBlazor.WinBox/WinBox.razor.cs:249-257). Consider aligning to that pattern (and making this method async if needed) to match the established convention and avoid surprises if the base dispose logic depends on running before derived cleanup.
Link issues
fixes #975
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Update DockView V2 disposal patterns and bump DockView package version.
Bug Fixes: