tui-cs/Terminal.Gui · warning · LayoutException

{view.GetType ().Name}.{name} = {bad.GetType ().Name} which

Error message

{view.GetType ().Name}.{name} = {bad.GetType ().Name} which depends on the SuperView's dimensions and the SuperView uses Dim.Auto.

What it means

This diagnostic (only active when View.ValidatePosDim is true) detects a SubView whose Width/Height/X/Y uses a Dim/Pos type (like Dim.Percent or Dim.Fill) that depends on the SuperView's dimensions, while the SuperView itself uses Dim.Auto — which derives its size FROM its SubViews. This creates a circular sizing dependency (child needs parent size, parent needs child size).

Source

Thrown at Terminal.Gui/ViewBase/View.Layout.cs:1727

                case DimFill:
                    break;

                case Dim dim and not DimAbsolute and not DimView and not DimCombine:
                    bad = dim;

                    break;

                case Dim dim and DimCombine:
                    // Recursively check for not Absolute or not View
                    ThrowInvalid (view, (dim as DimCombine)?.Left, name);
                    ThrowInvalid (view, (dim as DimCombine)?.Right, name);

                    break;
            }

            if (bad != null)
            {
                throw new LayoutException ($"{view.GetType ().Name}.{name} = {bad.GetType ().Name} "
                                           + $"which depends on the SuperView's dimensions and the SuperView uses Dim.Auto.");
            }
        }
    }

    #endregion Diagnostics and Verification
}

View on GitHub (pinned to 2e47b11478)

Solutions

  1. Change the SubView to Dim.Absolute or Dim.Auto so it does not depend on the SuperView's computed size.
  2. Change the SuperView from Dim.Auto to an absolute Dim or Dim.Fill so it has an independent size.
  3. Disable ValidatePosDim (it is a debug-only flag with a performance penalty) once you understand the issue.

Example fix

// before
parent.Width = Dim.Auto();
child.Width = Dim.Fill(); // circular
// after
parent.Width = Dim.Fill();
child.Width = Dim.Fill();
Defensive patterns

Strategy: validation

Validate before calling

// Before enabling debug validation, ensure no SubView uses Dim.Fill/Percent under a Dim.Auto parent.
parent.ValidatePosDim = false; // keep off in production
// Fix: child.Width = Dim.Auto() or Dim.Absolute(n) instead of Dim.Fill()

Type guard

static bool IsDimAutoSafe (Dim d) => d is DimAbsolute or DimAuto or DimView or DimCombine;

Prevention

When it happens

Trigger: Enabling ValidatePosDim = true on a SuperView whose Width/Height is Dim.Auto(style: Content), while a SubView uses Dim.Fill, Dim.Percent, or a non-View/absolute Pos that references the SuperView.

Common situations: Debugging a layout that renders at zero size or loops; turning on validation to diagnose; mixing Dim.Auto content sizing with Fill-style children that expect a fixed parent size.

Related errors


AI-assisted analysis of tui-cs/Terminal.Gui@2e47b11478 (2026-08-13). Data as JSON: /api/errors/187a1bce6d65d15f. Report an issue: GitHub.