Skip to content

fix(tui): allow disposable transient views in RegisterView#16

Merged
tgiachi merged 1 commit into
developfrom
fix/tui-disposable-transient-view
Jun 30, 2026
Merged

fix(tui): allow disposable transient views in RegisterView#16
tgiachi merged 1 commit into
developfrom
fix/tui-disposable-transient-view

Conversation

@tgiachi

@tgiachi tgiachi commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Problem

Running the TUI sample crashed at startup with:

DryIoc.ContainerException: Error.RegisteredDisposableTransientWontBeDisposedByContainer
Registered Disposable Transient service ... CounterComposedView ... won't be disposed by container.

TuiView<T> derives from Terminal.Gui Window, which is IDisposable. RegisterView<TView,TViewModel>() registered the view as Reuse.Transient, and DryIoc refuses disposable transients by default. This affected every view (imperative and DSL alike); it only surfaced now because the sample had never been run (build-verified only).

Fix

Register the view with Setup.With(allowDisposableTransient: true). The view host already disposes each view on Remove (TerminalGuiViewHost.Removeview.Dispose()), so the container must not also track/dispose it — allow (not track) avoids a double-dispose.

Added a regression test that registers a disposable ITuiView through RegisterView and asserts it resolves without throwing (the existing test used a non-disposable fake, which is why it never caught this).

Test plan

  • RegisterTuiExtensionsTests green (3/3, incl. the new disposable case)
  • SquidStd.Tui builds (0 errors)
  • Manual dotnet run of the sample now launches past registration (please confirm in a real terminal)

Views derive from Window (IDisposable). DryIoc throws
RegisteredDisposableTransientWontBeDisposedByContainer when a disposable type
is registered as a transient, so resolving the application host and navigating
to the first screen crashed at startup. Register the view with
Setup.With(allowDisposableTransient: true): the view host already disposes each
view on Remove, so the container must not also track/dispose it. Add a
regression test registering a disposable view through RegisterView.
@tgiachi
tgiachi merged commit 782f4db into develop Jun 30, 2026
1 of 2 checks passed
@tgiachi
tgiachi deleted the fix/tui-disposable-transient-view branch June 30, 2026 06:56
[Fact]
public void RegisterView_AllowsDisposableTransientView()
{
var container = new Container();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants