Skip to content

Overhaul - #13

Merged
mattj23 merged 16 commits into
mainfrom
overhaul
Sep 10, 2026
Merged

mattj23 merged 16 commits into
mainfrom
overhaul

Conversation

@mattj23

@mattj23 mattj23 commented Sep 10, 2026

Copy link
Copy Markdown
Owner

Summary

This PR modernizes InteractiveReadLine while preserving .NET Standard 2.0 support. It expands the input model, fixes several long-standing behavior issues, improves API safety, and adds
current CI, packaging, release, and documentation infrastructure.

Highlights

  • Add ReadLineResult to distinguish completed lines, canceled input, and end-of-input.
  • Add conventional Ctrl+C cancellation and Ctrl+D end-of-input behavior.
  • Add cancellation-token support and asynchronous read APIs.
  • Add a per-read cut buffer with Ctrl+Y paste support and consecutive-cut accumulation.
  • Fix key modifier registration and allow later key bindings to replace earlier bindings.
  • Improve history navigation and filter blank or immediately repeated history entries.
  • Make SystemConsoleWrapper public and improve console-state restoration.
  • Correct FormattedText equality and hashing behavior.
  • Enable nullable-reference analysis across the library.
  • Retain .NET Standard 2.0 support and add .NET 10 as a target.
  • Normalize line endings and add a blame-ignore revision for that mechanical change.

API changes

New APIs include:

  • ConsoleReadLine.Read(...) and ReadAsync(...)
  • ReadLineAsync(...)
  • ReadLineResult and ReadLineResultKind
  • Cancellation-token support throughout the read pipeline
  • CommonKeyBehaviors.Cancel, EndOfInput, DeleteOrEndOfInput, and Paste
  • Cut-buffer operations on IKeyBehaviorTarget
  • AddCancelKeys()
  • Public SystemConsoleWrapper

ReadLine() remains available as the convenient string API:

  • Enter returns the completed text.
  • Ctrl+C returns an empty string.
  • Ctrl+D on an empty line returns null.

Behavior fixes

  • Honor Control, Alt, and Shift arguments when registering key behaviors.
  • Replace an existing binding when the same key is registered again.
  • Clamp history navigation when a live history collection shrinks.
  • Skip blank and immediately repeated entries in automatically updated history.
  • Preserve stable hash codes for mutable FormattedText color arrays.
  • Use UTF-8 when generating the password-bar hash.
  • Restore console settings when reads complete, fail, or are canceled.

Compatibility notes

This overhaul includes source-breaking changes for custom backend implementations:

  • IReadLineProvider now supports cancellation and requires synchronous and asynchronous key-reading methods.
  • IConsole now exposes key availability and redirected-input state.
  • KeyId properties are now read-only so dictionary keys cannot be mutated after registration.
  • Nullable-reference annotations can surface new compiler warnings for consumers with nullable analysis enabled.

The existing synchronous convenience APIs and .NET Standard 2.0 target remain supported.

@mattj23
mattj23 merged commit 54e5338 into main Sep 10, 2026
3 checks passed
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.

1 participant