Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e962b09
chore: complete task 019, create task 020 for console API coverage
StevenTCramer Mar 22, 2026
91202ee
chore: refactor task 020 into child tasks for console API coverage
StevenTCramer Mar 22, 2026
2794c30
chore: start task 020-002 - encoding and redirection APIs
StevenTCramer Mar 22, 2026
2cea595
feat: add encoding and redirection APIs to IConsole
StevenTCramer Mar 22, 2026
39f6960
chore: start task 020-003 - rich input APIs
StevenTCramer Mar 22, 2026
ff35c0d
feat: add Read() and ReadKey() methods to IConsole
StevenTCramer Mar 22, 2026
a541828
chore: start task 020-004 - cursor properties
StevenTCramer Mar 22, 2026
c427956
feat: add cursor properties to ITerminal
StevenTCramer Mar 22, 2026
7db4c74
chore: start task 020-006 - color state APIs
StevenTCramer Mar 22, 2026
f2b835b
feat: add color state APIs to ITerminal
StevenTCramer Mar 22, 2026
d9c644b
chore: start task 020-007 - control/utility APIs
StevenTCramer Mar 22, 2026
415e51b
feat: add control/utility APIs to ITerminal
StevenTCramer Mar 22, 2026
d3bffd3
chore: start task 020-001 - stream access APIs
StevenTCramer Mar 22, 2026
738c78c
feat: add stream access APIs to IConsole
StevenTCramer Mar 22, 2026
3cba522
chore: start task 020-005 - window/buffer geometry
StevenTCramer Mar 22, 2026
fc0cd2b
feat: add window/buffer geometry APIs to ITerminal
StevenTCramer Mar 22, 2026
72bded7
chore: start task 020-008 - mirror APIs on Terminal static class
StevenTCramer Mar 22, 2026
b9c77a5
feat: mirror new IConsole/ITerminal APIs on Terminal static class
StevenTCramer Mar 22, 2026
72a150f
fix: add null checks to SetIn/SetOut/SetError and fix XML doc issues
StevenTCramer Mar 22, 2026
28cd1c8
chore: bump version to 1.0.0-beta.11
StevenTCramer Mar 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@

<!-- Suppress specific warnings -->
<!-- CA1014: CLS compliance not required for this library -->
<!-- CA1716: Reserved keywords (matching System.Console API: In, Error) -->
<!-- CA1724: Type name conflicts (acceptable in this context) -->
<!-- CA1812: False positives for DI-instantiated classes -->
<!-- IL2026, IL2067, IL2070, IL2075, IL3050, IL2104, IL3053: AOT warnings (not yet implemented) -->
<NoWarn>$(NoWarn);CA1014;CA1724;CA1812;IL2026;IL2067;IL2070;IL2075;IL3050;IL2104;IL3053</NoWarn>
<NoWarn>$(NoWarn);CA1014;CA1716;CA1724;CA1812;IL2026;IL2067;IL2070;IL2075;IL3050;IL2104;IL3053</NoWarn>
</PropertyGroup>

<!-- Code analyzers applied to all projects -->
Expand Down
92 changes: 92 additions & 0 deletions kanban/done/020-001-add-stream-access-apis-to-iconsole.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Add stream access APIs to IConsole

## Description

Add raw stream access methods to `IConsole` to match `System.Console` capabilities. This enables scenarios where code needs direct `Stream` access to stdin/stdout/stderr, or needs to redirect I/O via `TextReader`/`TextWriter`.

Parent: #020

## Checklist

### Implementation
- [x] Add `OpenStandardInput()` → `Stream` to `IConsole`
- [x] Add `OpenStandardOutput()` → `Stream` to `IConsole`
- [x] Add `OpenStandardError()` → `Stream` to `IConsole`
- [x] Add `In` → `TextReader` property to `IConsole`
- [x] Add `Out` → `TextWriter` property to `IConsole`
- [x] Add `Error` → `TextWriter` property to `IConsole`
- [x] Add `SetIn(TextReader)` method to `IConsole`
- [x] Add `SetOut(TextWriter)` method to `IConsole`
- [x] Add `SetError(TextWriter)` method to `IConsole`
- [x] Implement in `TimeWarpConsole`
- [x] Implement in `TimeWarpTerminal`

### Testing
- [x] Add `TestConsole` implementations for all new members
- [x] Add `TestTerminal` implementations for all new members
- [x] Add mock stream support to test implementations
- [x] Add mock TextReader/TextWriter support to test implementations
- [x] Write unit tests for `OpenStandardInput()`
- [x] Write unit tests for `OpenStandardOutput()`
- [x] Write unit tests for `OpenStandardError()`
- [x] Write unit tests for `In`/`Out`/`Error` properties
- [x] Write unit tests for `SetIn()`/`SetOut()`/`SetError()`

## Session

- Created: ses_2f2ab32c3ffeoD0gwPTVU0agTi (2026-03-22)
- Completed: ses_2e9f62f66ffeh05Tj3xKWlwLsS (2026-03-22)

## Notes

### Files to modify
- `iconsole.cs` - add interface members
- `timewarp-console.cs` - implement in TimeWarpConsole
- `timewarp-terminal.cs` - implement in TimeWarpTerminal
- `test-console.cs` - add test implementations
- `test-terminal.cs` - add test implementations

### Design considerations
- `OpenStandard*()` methods return `Stream` - test implementations need mock streams (e.g., `MemoryStream`)
- `In`/`Out`/`Error` are `TextReader`/`TextWriter` - test implementations can use `StringReader`/`StringWriter`
- RS0030 analyzer currently flags `Console.OpenStandard*` usage - this task satisfies that analyzer

### Reference
- https://learn.microsoft.com/en-us/dotnet/api/system.console.openstandardinput

### Coding Standards
Follow the `/csharp` skill for all implementation work.

## Results

### What was implemented
Added 9 stream access members to `IConsole`:
- `Stream OpenStandardInput()` - opens stdin as a stream
- `Stream OpenStandardOutput()` - opens stdout as a stream
- `Stream OpenStandardError()` - opens stderr as a stream
- `TextReader In { get; }` - standard input reader
- `TextWriter Out { get; }` - standard output writer
- `TextWriter Error { get; }` - standard error writer
- `void SetIn(TextReader)` - sets standard input
- `void SetOut(TextWriter)` - sets standard output
- `void SetError(TextWriter)` - sets standard error

### Files changed
- `source/timewarp-terminal/iconsole.cs` - added 9 interface members
- `source/timewarp-terminal/timewarp-console.cs` - implemented all 9 members
- `source/timewarp-terminal/timewarp-terminal.cs` - implemented all 9 members
- `source/timewarp-terminal/test-console.cs` - added mock streams and implementations
- `source/timewarp-terminal/test-terminal.cs` - added mock streams and implementations
- `Directory.Build.props` - added CA1716 to NoWarn (matching System.Console API names)
- `tests/stream-access-01-basic.cs` - new test file (26 tests)

### Test results
- All 26 new tests pass
- All existing tests pass
- Build succeeds with 0 warnings

### Design decisions
- TestConsole/TestTerminal use MemoryStream for OpenStandard* methods
- In/Out/Error properties use StringReader/StringWriter in test implementations
- SetIn/SetOut/SetError update the internal readers/writers
- Added CA1716 suppression for naming conflict with System.Console API (In/Out/Error/SetIn/SetOut/SetError)
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Add encoding and redirection APIs to IConsole

## Description

Add encoding and redirection state properties to `IConsole` to match `System.Console` capabilities. This enables code to detect and control text encoding and check if streams are redirected.

Parent: #020

## Checklist

### Implementation
- [x] Add `InputEncoding` get/set property to `IConsole`
- [x] Add `OutputEncoding` get/set property to `IConsole`
- [x] Add `IsInputRedirected` property to `IConsole`
- [x] Add `IsOutputRedirected` property to `IConsole`
- [x] Add `IsErrorRedirected` property to `IConsole`
- [x] Implement in `TimeWarpConsole`
- [x] Implement in `TimeWarpTerminal`
- [x] Consider deprecating `IsInteractive` on `ITerminal` in favor of explicit `!IsInputRedirected`

### Testing
- [x] Add `TestConsole` implementations for all new members
- [x] Add `TestTerminal` implementations for all new members
- [x] Add mock encoding support to test implementations (default to UTF-8)
- [x] Add redirection state properties to test implementations (default to false)
- [x] Write unit tests for `InputEncoding` get/set
- [x] Write unit tests for `OutputEncoding` get/set
- [x] Write unit tests for `IsInputRedirected`
- [x] Write unit tests for `IsOutputRedirected`
- [x] Write unit tests for `IsErrorRedirected`

## Session

- Created: ses_2f2ab32c3ffeoD0gwPTVU0agTi (2026-03-22)

## Notes

### Files to modify
- `iconsole.cs` - add interface members
- `iterminal.cs` - consider IsInteractive deprecation
- `timewarp-console.cs` - implement in TimeWarpConsole
- `timewarp-terminal.cs` - implement in TimeWarpTerminal
- `test-console.cs` - add test implementations
- `test-terminal.cs` - add test implementations

### Design considerations
- Encoding properties should default to `Encoding.UTF8` in test implementations
- Redirection properties should default to `false` in test implementations
- `IsInteractive` on ITerminal currently returns `!Console.IsInputRedirected` - consider if this should be deprecated or kept as convenience

### Reference
- https://learn.microsoft.com/en-us/dotnet/api/system.console.inputencoding
- https://learn.microsoft.com/en-us/dotnet/api/system.console.isinputredirected

### Coding Standards
Follow the `/csharp` skill for all implementation work.

## Results

### What was implemented
- Added 5 new properties to `IConsole` interface:
- `Encoding InputEncoding { get; set; }`
- `Encoding OutputEncoding { get; set; }`
- `bool IsInputRedirected { get; }`
- `bool IsOutputRedirected { get; }`
- `bool IsErrorRedirected { get; }`

- Implemented in `TimeWarpConsole` - delegates to Console properties
- Implemented in `TimeWarpTerminal` - same as TimeWarpConsole
- Implemented in `TestConsole` and `TestTerminal` with defaults:
- InputEncoding/OutputEncoding default to Encoding.UTF8
- IsInputRedirected/IsOutputRedirected/IsErrorRedirected default to false (settable)

### Files changed
- `source/timewarp-terminal/iconsole.cs` - added interface members
- `source/timewarp-terminal/timewarp-console.cs` - implemented properties
- `source/timewarp-terminal/timewarp-terminal.cs` - implemented properties
- `source/timewarp-terminal/test-console.cs` - added test implementation
- `source/timewarp-terminal/test-terminal.cs` - added test implementation
- `tests/console-encoding-01-basic.cs` - new test file (22 tests)

### Test results
- All 22 new tests pass
- All existing tests pass
- Build succeeds with 0 warnings

### Design decisions
- Kept `IsInteractive` on ITerminal (not deprecated) - it's a convenience property that users may prefer over `!IsInputRedirected`
- Redirection properties on test implementations are settable to allow testing different scenarios
78 changes: 78 additions & 0 deletions kanban/done/020-003-add-rich-input-apis-to-iconsole.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Add rich input APIs to IConsole

## Description

Add character-level input methods to `IConsole` to match `System.Console` capabilities. This enables reading single characters and key presses without requiring a full line.

Parent: #020

## Checklist

### Implementation
- [x] Add `Read()` → `int` method to `IConsole` (reads single character, returns -1 on EOF)
- [x] Add `ReadKey()` overload without parameter to `IConsole` (defaults to intercept: false)
- [x] Implement in `TimeWarpConsole`
- [x] Implement in `TimeWarpTerminal`

### Testing
- [x] Add `TestConsole` implementations for all new members
- [x] Add `TestTerminal` implementations for all new members
- [x] Add character queue support to `TestConsole` for `Read()`
- [x] Write unit tests for `Read()` returning single character
- [x] Write unit tests for `Read()` returning -1 on EOF
- [x] Write unit tests for `ReadKey()` without parameter (intercept: false)
- [x] Write unit tests for `ReadKey()` with intercept: true (existing)

## Session

- Created: ses_2f2ab32c3ffeoD0gwPTVU0agTi (2026-03-22)

## Notes

### Files to modify
- `iconsole.cs` - add interface members
- `timewarp-console.cs` - implement in TimeWarpConsole
- `timewarp-terminal.cs` - implement in TimeWarpTerminal
- `test-console.cs` - add test implementations
- `test-terminal.cs` - add test implementations (may already have ReadKey support)

### Design considerations
- `Read()` returns `int` to allow -1 for EOF (same as `Console.Read()`)
- `ReadKey()` without parameter should default to `intercept: false` (display the key)
- `TestConsole` already has `ReadLine()` - need to add character-level input support

### Reference
- https://learn.microsoft.com/en-us/dotnet/api/system.console.read
- https://learn.microsoft.com/en-us/dotnet/api/system.console.readkey

### Coding Standards
Follow the `/csharp` skill for all implementation work.

## Results

### What was implemented
- Added `int Read()` method to `IConsole` - reads single character, returns -1 on EOF
- Added `ConsoleKeyInfo ReadKey()` overload to `IConsole` - defaults to intercept: false
- Implemented in `TimeWarpConsole` - wraps Console.Read() and Console.ReadKey(false)
- Implemented in `TimeWarpTerminal` - wraps Console.Read() and Console.ReadKey(false)
- Implemented in `TestConsole` with character queue:
- `QueueCharacters(string)` method to queue characters for Read()
- `CharactersInQueue` property
- `Read()` returns next char from queue, or -1 if empty
- `ReadKey()` throws NotSupportedException (use TestTerminal for key input)
- Implemented in `TestTerminal`:
- `Read()` uses existing key queue
- `ReadKey()` overload without parameter calls ReadKey(false)

### Files changed
- `source/timewarp-terminal/iconsole.cs` - added interface members
- `source/timewarp-terminal/timewarp-console.cs` - implemented Read/ReadKey
- `source/timewarp-terminal/timewarp-terminal.cs` - implemented Read/ReadKey
- `source/timewarp-terminal/test-console.cs` - added character queue and implementations
- `source/timewarp-terminal/test-terminal.cs` - added Read/ReadKey implementations
- `tests/rich-input-01-basic.cs` - new test file (15 tests)

### Test results
- All 15 new tests pass
- All existing tests pass
- Build succeeds with 0 warnings
86 changes: 86 additions & 0 deletions kanban/done/020-004-add-cursor-properties-to-iterminal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Add cursor properties to ITerminal

## Description

Add cursor properties to `ITerminal` to match `System.Console` capabilities. Currently only have method pair `SetCursorPosition()`/`GetCursorPosition()`. Add direct property access and visibility/size control.

Parent: #020

## Checklist

### Implementation
- [x] Add `CursorLeft` get/set property to `ITerminal`
- [x] Add `CursorTop` get/set property to `ITerminal`
- [x] Add `CursorVisible` get/set property to `ITerminal`
- [x] Add `CursorSize` get/set property to `ITerminal` (1-100 percentage)
- [x] Implement in `TimeWarpTerminal`

### Testing
- [x] Add `TestTerminal` implementations for all new members
- [x] Add cursor position tracking to `TestTerminal` (currently has fields but not properties)
- [x] Add `CursorVisible` property to `TestTerminal` (default: true)
- [x] Add `CursorSize` property to `TestTerminal` (default: 100)
- [x] Write unit tests for `CursorLeft` get/set
- [x] Write unit tests for `CursorTop` get/set
- [x] Write unit tests for `CursorVisible` get/set
- [x] Write unit tests for `CursorSize` get/set (validate 1-100 range)

## Session

- Created: ses_2f2ab32c3ffeoD0gwPTVU0agTi (2026-03-22)

## Notes

### Files to modify
- `iterminal.cs` - add interface members
- `timewarp-terminal.cs` - implement in TimeWarpTerminal
- `test-terminal.cs` - add test implementations

### Design considerations
- `CursorLeft`/`CursorTop` properties are more idiomatic than the existing method pair
- Consider keeping `SetCursorPosition()`/`GetCursorPosition()` for backward compatibility
- `CursorSize` is 1-100 percentage (size of cursor, 1=small line, 100=full block)
- `TestTerminal` already has `CursorLeft`/`CursorTop` fields - convert to properties

### Reference
- https://learn.microsoft.com/en-us/dotnet/api/system.console.cursorleft
- https://learn.microsoft.com/en-us/dotnet/api/system.console.cursorvisible
- https://learn.microsoft.com/en-us/dotnet/api/system.console.cursorsize

### Coding Standards
Follow the `/csharp` skill for all implementation work.

## Results

### What was implemented
- Added 4 cursor properties to `ITerminal`:
- `int CursorLeft { get; set; }` - cursor column position
- `int CursorTop { get; set; }` - cursor row position
- `bool CursorVisible { get; set; }` - whether cursor is visible
- `int CursorSize { get; set; }` - cursor size as percentage (1-100)

- Implemented in `TimeWarpTerminal`:
- CursorLeft/CursorTop wrap Console properties with IOException handling
- CursorVisible/CursorSize have Windows platform guards (throw PlatformNotSupportedException on non-Windows)

- Implemented in `TestTerminal`:
- Converted existing CursorLeft/CursorTop fields to properties
- Added CursorVisible property (default: true)
- Added CursorSize property (default: 100, validates 1-100 range)
- Backward compatibility: SetCursorPosition()/GetCursorPosition() still work

### Files changed
- `source/timewarp-terminal/iterminal.cs` - added interface properties
- `source/timewarp-terminal/timewarp-terminal.cs` - added implementations with platform guards
- `source/timewarp-terminal/test-terminal.cs` - converted fields to properties, added new properties
- `tests/terminal-cursor-properties.cs` - new test file (13 tests)

### Test results
- All 13 new tests pass
- All existing tests pass
- Build succeeds with 0 warnings

### Design decisions
- Kept SetCursorPosition()/GetCursorPosition() for backward compatibility
- CursorVisible/CursorSize throw PlatformNotSupportedException on non-Windows (matches Console behavior)
- TestTerminal validates CursorSize range (1-100)
Loading
Loading