Skip to content

Fixes #3982. Add Draw trace category and instrument View.Drawing.cs#4831

Draft
Copilot wants to merge 3 commits intov2_developfrom
copilot/add-draw-trace-category
Draft

Fixes #3982. Add Draw trace category and instrument View.Drawing.cs#4831
Copilot wants to merge 3 commits intov2_developfrom
copilot/add-draw-trace-category

Conversation

Copy link
Contributor

Copilot AI commented Mar 11, 2026

Adds a Draw trace category to the tracing infrastructure and instruments the draw pipeline with Trace.Draw(...) calls, enabling diagnostic tracing for draw operations in DEBUG builds. Also adds UICatalog menu items for the Configuration and Draw trace categories.

Proposed Changes/Todos

  • TraceCategory.csDraw = 64 added to [Flags] enum; All updated to include it
  • Trace.csTrace.Draw(string? id, string phase, string? message = null, [CallerMemberName] string method = "") following the existing [Conditional("DEBUG")] / guard / Backend.Log pattern
  • ApplicationImpl.Screen.csLayoutAndDraw: traced at Start (with forceRedraw) and End (with neededLayout/needsDraw)
  • View.Drawing.cs — Static Draw(IEnumerable<View>, bool force): traces each view before its draw call; Instance Draw(DrawContext?): traces each phase — Start, Adornments, SubViews, Text, Content, LineCanvas, End
  • TraceTests.csTraceCategory_Draw_HasExpectedValue, TraceCategory_All_IncludesDraw, Draw_Category_CanBeEnabled
  • UICatalogRunnable.cs — Added Con_figuration and _Draw CheckBox menu items to the _Logging menu so both trace categories can be toggled at runtime

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working
Original prompt

This section details on the original issue you should resolve

<issue_title>Add Draw trace category and instrument ConfigurationManager</issue_title>
<issue_description>## Summary

Add a Draw trace category to the tracing infrastructure and instrument View.Draw.cs with Trace.Draw(...) calls. This enables diagnostic tracing for all Draw-related operations (property discovery, source loading, property assignment, JSON deserialization errors).

Motivation

Draw is a complex subsystem

Trace.Draw should not be used for places where Logging.Error or Logging.Warnings are currently used (or commented out). Generally if there's a commented out Logging call in the Draw codepath, that's a good candidate for Trace.Draw but do not over-do it; too much trace noise is not a good thing.

Changes

TraceCategory.cs

  • Add Draw= 64 to the [Flags] enum
  • Update All to include Draw

Trace.cs

  • Add Trace.Draw(string? id, string phase, string? message, ...) method following the existing pattern ([Conditional("DEBUG")], guard check, Backend.Log)

Terminal.Gui/Draw/ — Instrument key paths:

  • LayoutAndDraw — log start/end,
  • the static View.Draw
  • View.Draw
  • Each phase of the draw flow

Tests

  • TraceCategory_Draw_HasExpectedValue — enum value is 64
  • TraceCategory_All_IncludesDraw — All flag includes Draw
  • Configuration_Draw_CanBeEnabled — enabling the category doesn't throw

Note: Trace methods are [Conditional("DEBUG")] — tests must NOT assert on trace output (they'd fail in Release builds).

</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…nImpl.LayoutAndDraw

Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copilot AI changed the title [WIP] Add draw trace category and instrument configuration manager Fixes #3982. Add Draw trace category and instrument View.Drawing.cs Mar 11, 2026
Copilot finished work on behalf of tig March 11, 2026 23:10
@tig
Copy link
Collaborator

tig commented Mar 12, 2026

@copilot ensure UICatalog has a menuitem for this and the recently added Config flag as well (it was an oversights to not do that).

Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 12, 2026

@copilot ensure UICatalog has a menuitem for this and the recently added Config flag as well (it was an oversights to not do that).

Done in 478c5f8. Added Con_figuration and _Draw CheckBox menu items to the UICatalog _Logging menu, following the same pattern as the existing Lifecycle/Command/Mouse/Keyboard entries. Both are enabled and toggle Trace.EnabledCategories via bitwise OR/AND.

Copilot finished work on behalf of tig March 12, 2026 13:39
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.

Add Draw trace category and instrument ConfigurationManager

2 participants