Skip to content

Feature/analyzers v1 diagnostics - #5701

Open
omm-prakash18 wants to merge 53 commits into
tui-cs:mainfrom
omm-prakash18:feature/analyzers-v1-diagnostics
Open

omm-prakash18 wants to merge 53 commits into
tui-cs:mainfrom
omm-prakash18:feature/analyzers-v1-diagnostics

Conversation

@omm-prakash18

Copy link
Copy Markdown

Fixes

  • Fixes #_____

Proposed Changes/Todos

  • Todo 1

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

liuqihonggit and others added 30 commits August 27, 2026 05:51
Utf8Buffer replaces StringBuilder to eliminate char[] to UTF8 conversion in output hot path.

AnsiOutput batch mode merges pendingCursorMoves + output.

BuildAnsiForRegionSkippingRasterCoveredBlanks uses Utf8Buffer.

Note: needs rebase after upstream tui-cs#5633 merges.
3-way merge: #5633循环重构 + Utf8Buffer替换,解决OutputBaseTests失败
… path

Utf8Buffer引入Write(ReadOnlySpan<byte>)重载,CountingOutput只override了Write(StringBuilder),导致Writes计数为0
review1: Add Write(ReadOnlySpan<byte>) override to WindowsOutput and NetOutput

review4: Reuse backing array for Unix writes instead of ToArray() per call

review7: Add focused Utf8Buffer unit tests (ASCII, multibyte, surrogate pairs, capacity, Clear, AppendInt)

review9: Extract shared ComputeTextStyleSgrCodes from CSI_AppendTextStyleChange and CSI_BuildTextStyleChange
…ui-cs#5650)

review2: Route Write(StringBuilder) through byte-span path in batch mode to merge deferred cursor moves

review3: try/finally guard _batchMode and _pendingCursorMoves in Write(IOutputBuffer)

review4: Validate count range in TryWriteStdout(byte[], int) to prevent native buffer overread

review7: Guard EnsureCapacity against int overflow with long arithmetic and Array.MaxLength cap
Address review nits on the timer cancellation rework:

- Add a deterministic test for the documented contract that Remove
  returns true for an occurrence that has already been dequeued and is
  executing, and neither waits for nor interrupts that callback. This
  was documented on ITimedEvents.Remove but not covered by a test.
- Note that ActiveTimeoutState is a mutable struct in a Dictionary, so
  every mutation must be written back before the queue lock is released.
- Document ActiveTimeoutOccurrence and ActiveTimeoutState.
- Note that Remove intentionally scans the whole queue, because the same
  Timeout instance can be queued more than once.
- Correct the class-level thread-safety docs. The blanket "Thread-safe
  for concurrent access" claim was inaccurate: Timeouts returns the live
  queue rather than a snapshot and is not synchronized.
- Replace the orphaned <inheritdoc/> on CheckTimers with real docs.
  CheckTimers is not declared on ITimedEvents, so it inherited nothing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Prevent zero-delay repeating timeouts from starving the main loop by limiting each pass to the number of callbacks due at its start.

Validate Timeout inputs, return a synchronized queue snapshot, and report the collision-adjusted Added timestamp with deterministic regression coverage.
Assign each queued timeout occurrence a monotonic identity and limit a timer pass to occurrences that were already queued and due when it began.

Add a deterministic zero-delay repeater plus peer regression and correct the AI test markers noted by review.
CompleteTimeout runs from the finally that follows a timeout callback, and it
raised Added. That made an Added subscriber the only user-code call site
reachable from that finally, so a throwing subscriber could replace an exception
raised by the callback itself.

The masking was not reachable in practice: a throwing callback leaves repeat
false, so CompleteTimeout took its early-return path, which only reads the
active-state entry, decrements it, and either removes it or assigns over an
existing key. None of that allocates, so none of it could throw. The guard was
incidental rather than designed, though, and any future change that let repeat be
true on an error path would have turned it into real masking.

Return the reschedule result from CompleteTimeout instead and raise Added from
the timer loop once the callback has returned normally. Bookkeeping and
rescheduling stay in the finally, still under the queue lock, so the ordering
Remove depends on is unchanged, and Added is still raised after that lock is
released.

Document the resulting contract: an Added handler exception ends the timer pass
while leaving the timeout scheduled, so a handler that throws on every reschedule
ends every subsequent pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A throwing timeout callback cannot also request rescheduling because the callback result is never assigned. The Added event is therefore unreachable on that path, so the exception-masking regression did not exercise the behavior it claimed.

Remove the unsupported regression and restore the simpler occurrence-completion flow. Keep the separate coverage for the reachable case where an Added handler throws after a repeating timeout has been rescheduled.
Align IApplication.RemoveTimeout with the ITimedEvents.Remove contract. A true result can mean cancellation was recorded for an executing callback, which continues running but cannot reschedule.
Read a repeating Timeout Span and the current time before reentering the timeout queue lock, then revalidate the occurrence generation and StopAll epoch before enqueueing. Preserve active-state cleanup if either extension point throws.

Apply the same lock boundary to GetTimeout and all time-provider reads. Add deterministic regressions for blocking and throwing Span overrides plus blocking time providers.
…iguration.Binder

Bumps Microsoft.Extensions.Configuration from 10.0.11 to 10.0.12
Bumps Microsoft.Extensions.Configuration.Binder from 10.0.11 to 10.0.12

---
updated-dependencies:
- dependency-name: Microsoft.Extensions.Configuration
  dependency-version: 10.0.12
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: Microsoft.Extensions.Configuration.Binder
  dependency-version: 10.0.12
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
---
updated-dependencies:
- dependency-name: Microsoft.Extensions.Options
  dependency-version: 10.0.12
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-version: 18.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Back-merge v2.5.0 from main into develop
---
updated-dependencies:
- dependency-name: xunit.v3
  dependency-version: 4.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
…defaultborderstyle

Fixes tui-cs#5675. MenuBar overrides DefaultBorderStyle
perf: UTF-8 batch mode + Utf8Buffer eliminates char[] to UTF8 conversion
tig and others added 23 commits September 14, 2026 11:42
Fixes tui-cs#5652. Execute timeout callbacks outside the queue lock
…focus-5662

Fixes tui-cs#5662. Restore nested paste focus after Begin
…dc55064

Bump Microsoft.Extensions.Configuration and Microsoft.Extensions.Configuration.Binder
….Extensions.Options-10.0.12

Bump Microsoft.Extensions.Options from 10.0.11 to 10.0.12
….NET.Test.Sdk-18.10.0

Bump Microsoft.NET.Test.Sdk from 18.9.0 to 18.10.0
---
updated-dependencies:
- dependency-name: Microsoft.Extensions.Configuration.Json
  dependency-version: 10.0.12
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
….Extensions.Configuration.Json-10.0.12

Bump Microsoft.Extensions.Configuration.Json from 10.0.11 to 10.0.12
---
updated-dependencies:
- dependency-name: Markdig
  dependency-version: 1.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
updated-dependencies:
- dependency-name: Xunit.Combinatorial
  dependency-version: 2.1.43
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
updated-dependencies:
- dependency-name: Moq
  dependency-version: 4.21.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…22.3.0 (tui-cs#5693)

---
updated-dependencies:
- dependency-name: TestableIO.System.IO.Abstractions.TestingHelpers
  dependency-version: 22.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Route ProgressIndicator and Kitty keyboard enable/disable through
  DriverImpl.WriteRaw so terminal I/O failures are contained.
- ProgressIndicator only records sequences that were actually written,
  so a failed set or clear is retried.
- Remove IOException swallows in NetOutput writes so failures reach the
  frame transaction; make NetOutput.SetCursor best-effort like AnsiOutput.
- Back off repeated output retries (0, 25ms .. 1s) and log only the first
  failure and the recovery, instead of a full frame and an error per loop.
- Reset the Unix EAGAIN/EINTR budget on progress so a slow terminal still
  receives the whole frame; the budget bounds consecutive stalls only.
- Legacy AppendOrWriteAttribute shim: flush pending text before the hook
  (matching the built-in Win32 hook) instead of re-decoding the pending
  row per attribute change (114 MB -> linear for a 200x50 colored frame).
- GetColumns single-char fast path avoids grapheme enumeration per cell.
- Rename review-named test files to feature names; add regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AnsiOutput logged and rethrew write IOExceptions, so DriverImpl logged
each failure a second time and every backed-off retry still emitted an
error. Drop that log and keep only the pending-move cleanup. Cursor
updates are best effort and run every iteration, so log their failures
at Debug; a broken sink also fails the next frame, which DriverImpl
reports once.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The backoff deadline was only checked in the no-draw retry branch, so a
view that redraws every iteration still flushed a full frame to a failing
terminal on each loop. Gate DriverImpl.Refresh itself: while a retry is
pending but not due, keep the dirty cells and let the next due call write
the latest buffer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…allucinations at compile time

- Implement V1ApiDiagnosticAnalyzer covering rules TGUI0001 through TGUI0014
- Implement V1ApiCodeFixProvider for automated Roslyn AST refactorings
- Bundle Terminal.Gui.Analyzers.dll inside Terminal.Gui.nupkg under analyzers/dotnet/cs
- Add unit test suite in Tests/Terminal.Gui.Analyzers.Tests and link to UnitTestsParallelizable
@omm-prakash18
omm-prakash18 requested a review from tig as a code owner October 5, 2026 19:13
@omm-prakash18

Copy link
Copy Markdown
Author

please check this pr

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

@BDisp

BDisp commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

You submitted against the main branch instead of the develop branch. So, you need to work with your branch synchronized with the develop. The main branch is only used for release packages.

This branch has not been deployed

No deployments
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.

6 participants