{"record":{"id":"572612a60fab8995","repo":"tui-cs/Terminal.Gui","slug":"adornmentview-can-only-render-to-their-parent-or-p","errorCode":null,"errorMessage":"AdornmentView can only render to their Parent or Parent's Superview.","messagePattern":"AdornmentView can only render to their Parent or Parent's Superview\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/ViewBase/Adornment/AdornmentView.cs","lineNumber":176,"sourceCode":"        return true;\n    }\n\n    /// <inheritdoc/>\n    protected override bool OnDrawingText () => Adornment is null || Adornment.Thickness == Thickness.Empty;\n\n    /// <inheritdoc/>\n    protected override bool OnDrawingSubViews () => Adornment is null || Adornment.Thickness == Thickness.Empty;\n\n    /// <summary>Does nothing for AdornmentView.</summary>\n    protected override bool OnRenderingLineCanvas () => true;\n\n    /// <summary>\n    ///     AdornmentViews only render to their <see cref=\"IAdornment.Parent\"/>'s or Parent's SuperView's LineCanvas.\n    /// </summary>\n    public override bool SuperViewRendersLineCanvas\n    {\n        get => false;\n        set => throw new InvalidOperationException (@\"AdornmentView can only render to their Parent or Parent's Superview.\");\n    }\n\n    /// <summary>\n    ///     Indicates whether the specified Parent's SuperView-relative coordinates are within the Adornment's\n    ///     <see cref=\"Thickness\"/>.\n    /// </summary>\n    public override bool Contains (in Point location)\n    {\n        View? parentOrSuperView = Adornment?.Parent;\n\n        if (parentOrSuperView is null)\n        {\n            parentOrSuperView = SuperView;\n\n            if (parentOrSuperView is null)\n            {\n                return false;\n            }","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/ViewBase/Adornment/AdornmentView.cs#L158-L194","documentation":"This error is thrown by AdornmentView.SuperViewRendersLineCanvas setter because AdornmentViews are designed to render exclusively to their parent's or parent's SuperView's LineCanvas, never to their own. Setting this property to true would imply the AdornmentView maintains its own LineCanvas for rendering, which contradicts its architectural role. The getter always returns false to signal this.","triggerScenarios":"Thrown at AdornmentView.cs:176 when any code attempts to set the SuperViewRendersLineCanvas property on an AdornmentView. This could happen via generic property-setting code, serialization/deserialization frameworks, or test infrastructure that iterates over all view properties.","commonSituations":"Generic view-testing tooling (like AllViewsTester) that sets every property on every view type, deserialization that restores all properties, custom rendering code that attempts to control LineCanvas behavior generically, or copy/clone utilities that replicate all properties.","solutions":["Do not set SuperViewRendersLineCanvas on AdornmentView -- it is architecturally fixed at false.","In generic view-processing code, check 'if (view is AdornmentView) continue;' before setting this property.","If this occurs during deserialization, exclude the property via [JsonIgnore] or similar for AdornmentView.","AdornmentViews always render through their parent's LineCanvas; this cannot be changed."],"exampleFix":"// before -- generic property setter hits the invariant\nforeach (var prop in typeof(View).GetProperties()) { prop.SetValue(view, defaultValue); }\n\n// after -- skip AdornmentView-specific properties\nif (view is AdornmentView) continue;\nprop.SetValue(view, defaultValue);","handlingStrategy":"type-guard","validationCode":"// Before setting SuperViewRendersLineCanvas, check the view type\nif (view is not AdornmentView) { view.SuperViewRendersLineCanvas = true; }","typeGuard":"bool CanSetSuperViewRendersLineCanvas(View v) => v is not AdornmentView;","tryCatchPattern":"try { view.SuperViewRendersLineCanvas = value; }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"AdornmentView can only render\"))\n{ /* AdornmentView always renders to parent LineCanvas; skip */ }","preventionTips":["Do not set SuperViewRendersLineCanvas on AdornmentView instances.","In generic code, filter out AdornmentView before setting this property.","Exclude this property from deserialization on AdornmentView.","AdornmentViews always render through their parent's LineCanvas -- this is architectural."],"tags":["adornment","viewbase","rendering","linecanvas","invariant"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}