-
Notifications
You must be signed in to change notification settings - Fork 735
Remove legacy drivers, simplify architecture, and reorganize codebase structure #4270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove legacy drivers, simplify architecture, and reorganize codebase structure #4270
Conversation
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
CursesDriver, NetDriver, WindowsDriver, and legacy Application code and code that v2win/v2net introduced that wraps that legacy|
@copilot Unit tests are failing |
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Fixed several test failures in commit a5e3b8c:
Key tests now passing: Init_NoParam_ForceDriver_Works, Run_t_Does_Not_Creates_Top_Without_Init Some tests may still fail due to the architectural changes from legacy drivers to v2 - these will need further investigation if they're critical. |
|
@copilot I've pushed some changes. Many unit tests fail; esp those that depend on FakeDriver. Before working on that, please move the V2Application tests that are in UnitTestse/ConsoleDrivers out of that folder into the proper place. |
|
@copilot In the current code, what is the distinction between the Application and Applicationv2 class? Why do both still exist? |
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Moved all test files from Application tests (moved to
Driver tests (moved to
All namespaces updated and V2 subfolder removed. Build succeeds with 0 errors. |
The key connection: Both exist because:
The legacy drivers (CursesDriver, NetDriver, WindowsDriver) used ApplicationImpl directly, while the new architecture uses ApplicationV2 as the default. |
…g:gui-cs/Terminal.Gui into copilot-v2
|
@copilot In the current code, what is the distinction between the Application and Applicationv2 class? Why do both still exist? |
…g:gui-cs/Terminal.Gui into copilot-v2
Updated `FakeDriver` to set `RunningUnitTests` to `true` and initialize dimensions using `FakeConsole`. Modified `TestRespondersDisposedAttribute` to set `ConsoleDriver.RunningUnitTests` in the `Before` method, ensuring proper behavior during unit tests. Temporarily disabled the `Button_CanFocus_False_Raises_Accepted_Correctly` test in `ViewCommandTests` by adding a `Skip` parameter to the `[Fact]` attribute, referencing issue #4270.
|
@tznind Just pushed some fixes that enable all unit tests to pass reliably locally, but still seeing CI/CD failures. There's some weridness in there still for sure, and I'm eager to get this merged so we can move on. I can't see why the non-par tests are failing in CI/CD. Frustrating. I'll keep poking at it, but keyboarding continues to be painful. 😒 |
Modified the `dotnet test` command in the `Run UnitTestsParallelizable` step to set `xunit.stopOnFail` to `false`. This ensures that the test runner does not stop execution on the first failure, allowing all tests to execute regardless of individual test outcomes.
Refactored `ClearContents_Called_When_Top_Frame_Changes` test: - Added `[AutoInitShutdown]` attribute for automatic lifecycle management. - Replaced manual `Application.Init` and `Application.Top` setup with `Application.Begin` and `RunState`. - Simplified event handling by defining `ClearedContents` handler inline. - Removed explicit cleanup logic, relying on `Application.End` for teardown. Updated `using` directives to include `UnitTests` namespace.
|
All passed! I'm skeptcial tho. |
|
The reason why the |
Update ApplicationImpl initialization parameter Changed the second parameter of the `impl.Init` method in the `FakeApplicationFactory` class from `"dotnet"` to `"fake"`.
Updated the `dotnet test` command in `unit-tests.yml` to set the `xunit.stopOnFail` parameter to `true`. This change ensures that test execution halts immediately upon encountering a failure, allowing quicker identification and resolution of issues. Note that this may prevent the full test suite from running in the event of a failure.
Updated `unit-tests.yml` to set `xunit.stopOnFail` to `false` in both `Run UnitTests` and `Run UnitTestsParallelizable` steps. This ensures that the test runner does not stop execution on the first test failure, allowing all tests to complete even if some fail.
|
Gonna do one more commit to this to force another test pass... |
Updated the `<remarks>` section in `RuneExtensions.GetColumns` to include details about the `wcwidth` implementation and improved readability with `<para>` tags. Added `wcwidth` to the user dictionary in `Terminal.sln.DotSettings` to avoid spelling errors.
…g:gui-cs/Terminal.Gui into copilot-v2
Updated the remarks section of the `GetColumns` method in the `RuneExtensions` class to enhance readability by reformatting and properly indenting `<para>` tags. The content remains unchanged, describing the method's implementation via `wcwidth` and its role as a Terminal.Gui extension for `System.Text.Rune`.
Replaced legacy drivers (`CursesDriver`, `NetDriver`) with `UnixDriver` and `DotNetDriver` across the codebase, including comments, method names, and test cases. Updated documentation and remarks to reflect the new driver names and platforms. Revamped clipboard handling with new platform-specific implementations: `UnixClipboard` for Unix, `MacOSXClipboard` for macOS, and `WSLClipboard` for Linux under WSL. Removed the old `CursesClipboard` and consolidated clipboard logic. Updated test cases to align with the new drivers and clipboard implementations. Improved naming consistency and cleaned up redundant code. Updated the README and documentation to reflect these changes.
This commit removes the `PlatformColor` property from the `Attribute` struct, simplifying the codebase by eliminating platform-specific color handling. The following changes were made: - Removed `PlatformColor` from the `Attribute` struct, including its initialization, usage, and related comments. - Updated constructors to no longer initialize or use `PlatformColor`. - Modified `Equals` and `GetHashCode` methods to exclude `PlatformColor`. - Updated `UnixComponentFactory` documentation to remove references to "v2unix." - Renamed `v2TestDriver` to `testDriver` in the `With` class for clarity. - Removed `PlatformColor` references in `DriverAssert` and related error messages. - Deleted test cases in `AttributeTests` that relied on `PlatformColor`. - Cleaned up comments and TODOs related to `PlatformColor` and `UnixDriver`. These changes reflect a shift away from platform-dependent color management, improving code clarity and reducing complexity. Remove `PlatformColor` and simplify `Attribute` logic The `PlatformColor` property has been removed from the `Attribute` struct, along with its associated logic, simplifying the codebase and eliminating platform-specific dependencies. Constructors, equality checks, and hash code generation in `Attribute` have been updated accordingly. The `CurrentAttribute` property in `ConsoleDriver` and `OutputBuffer` has been simplified, removing dependencies on `Application.Driver`. The `MakeColor` method logic has been removed or simplified in related classes. Tests in `AttributeTests` have been refactored to reflect these changes, focusing on `Foreground`, `Background`, and `Style`. Unix-specific logic tied to `PlatformColor` has been eliminated. Additional updates include renaming parameters in the `With` class for clarity, simplifying `DriverAssert` output, and performing minor code cleanups to improve readability and maintainability.
Updated documentation to reflect the new modular driver architecture in Terminal.Gui v2. - Revised `namespace-drivers.md` to include new components (`IConsoleInput`, `IConsoleOutput`, `IInputProcessor`, `IOutputBuffer`, `IWindowSizeMonitor`) and terminal size monitoring. - Replaced "Key Components" with "Architecture Overview" and added details on the **Component Factory** pattern. - Documented the four driver implementations (`DotNetDriver`, `WindowsDriver`, `UnixDriver`, `FakeDriver`) and their platform-specific optimizations. - Added a "Threading Model" section to explain the multi-threaded design for responsive input handling. - Updated examples to demonstrate driver capabilities and explicit driver selection. In `drivers.md`: - Expanded the "Overview" to emphasize the modular, component-based architecture. - Reorganized "Drivers" into "Available Drivers" and added details on `FakeDriver` for unit testing. - Added sections on "Initialization Flow," "Shutdown Flow," and platform-specific driver details. - Provided examples for accessing driver components and creating custom drivers. In `index.md`: - Updated "Cross Platform" feature to reflect new driver names and clarified compatibility with SSH and monochrome terminals.
… structure (gui-cs#4270) * Initial plan * Remove legacy drivers and reorganize v2 architecture Co-authored-by: tig <585482+tig@users.noreply.github.com> * Extract Windows key helper utilities and fix build Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix all test references to legacy drivers Co-authored-by: tig <585482+tig@users.noreply.github.com> * Update documentation to reflect new driver architecture Co-authored-by: tig <585482+tig@users.noreply.github.com> * Remove V2.cd diagram file Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix test failures: support legacy drivers and update exception handling Co-authored-by: tig <585482+tig@users.noreply.github.com> * updated driver names * Move V2 tests from ConsoleDrivers/V2 to proper locations Co-authored-by: tig <585482+tig@users.noreply.github.com> * Rename ApplicationV2 to ModernApplicationImpl to remove v2 terminology Co-authored-by: tig <585482+tig@users.noreply.github.com> * Remove V2 terminology from test drivers and FakeDriver classes Co-authored-by: tig <585482+tig@users.noreply.github.com> * Merge ModernApplicationImpl into ApplicationImpl and move to App folder Co-authored-by: tig <585482+tig@users.noreply.github.com> * Create modern FakeDriver with component factory architecture in Terminal.Gui project Co-authored-by: tig <585482+tig@users.noreply.github.com> * Refactor: Move non-platform-dependent code from /Drivers to /App Co-authored-by: tig <585482+tig@users.noreply.github.com> * Code cleanup and org * Unit test reorg * Refactor MainLoop architecture: rename classes and enhance documentation for clarity Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add comprehensive FakeDriver tests (WIP - some tests need fixes) Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fixed FakeDriver build failures * Fix all FakeDriver test failures - Application.Top creation and clipboard behaviors Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fixed FakeDriver build failures2 * Remove hanging legacy FakeDriver tests that use Console.MockKeyPresses Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fixed some tests * Fixed more tests * Fixed more tests * Fix bad copilot (gui-cs#4277) * Update Terminal.Gui/Drivers/FakeDriver/FakeConsoleOutput.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor Application Init and Update Tests Refactored `Application.Init` to improve initialization logic: - Added fallback to `ForceDriver` when `driverName` is null. - Changed repeated `Init` calls to throw `InvalidOperationException`. - Updated `_driverName` assignment logic for robustness. Enhanced `IConsoleDriver` with detailed remarks on implementations. Revised test cases to align with updated `Application.Init` behavior: - Replaced `FakeDriver` with `null` and `driverName: "fake"`. - Skipped or commented out tests incompatible with new logic. - Improved formatting and removed redundant setup code. Improved code style and consistency across the codebase: - Standardized parameter formatting and spacing. - Removed outdated comments and unused code. General cleanup to enhance readability and maintainability. * Warp fix copilot (gui-cs#4278) * More fixes (gui-cs#4279) * Fixes/works around test failures and temporarily disable failing test Updated `FakeDriver` to set `RunningUnitTests` to `true` and initialize dimensions using `FakeConsole`. Modified `TestRespondersDisposedAttribute` to set `ConsoleDriver.RunningUnitTests` in the `Before` method, ensuring proper behavior during unit tests. Temporarily disabled the `Button_CanFocus_False_Raises_Accepted_Correctly` test in `ViewCommandTests` by adding a `Skip` parameter to the `[Fact]` attribute, referencing issue gui-cs#4270. * Allow all tests to run despite failures in UnitTests Modified the `dotnet test` command in the `Run UnitTestsParallelizable` step to set `xunit.stopOnFail` to `false`. This ensures that the test runner does not stop execution on the first failure, allowing all tests to execute regardless of individual test outcomes. * Refactor ApplicationScreenTests for cleaner setup/teardown Refactored `ClearContents_Called_When_Top_Frame_Changes` test: - Added `[AutoInitShutdown]` attribute for automatic lifecycle management. - Replaced manual `Application.Init` and `Application.Top` setup with `Application.Begin` and `RunState`. - Simplified event handling by defining `ClearedContents` handler inline. - Removed explicit cleanup logic, relying on `Application.End` for teardown. Updated `using` directives to include `UnitTests` namespace. * Attempt to fix intermittent local test failures. Update ApplicationImpl initialization parameter Changed the second parameter of the `impl.Init` method in the `FakeApplicationFactory` class from `"dotnet"` to `"fake"`. * Code cleanup to cause Action to re-run. * Stop tests on first failure in UnitTestsParallelizable Updated the `dotnet test` command in `unit-tests.yml` to set the `xunit.stopOnFail` parameter to `true`. This change ensures that test execution halts immediately upon encountering a failure, allowing quicker identification and resolution of issues. Note that this may prevent the full test suite from running in the event of a failure. * Allow all tests to run despite failures in CI Updated `unit-tests.yml` to set `xunit.stopOnFail` to `false` in both `Run UnitTests` and `Run UnitTestsParallelizable` steps. This ensures that the test runner does not stop execution on the first test failure, allowing all tests to complete even if some fail. * Enhance RuneExtensions docs and update user dictionary Updated the `<remarks>` section in `RuneExtensions.GetColumns` to include details about the `wcwidth` implementation and improved readability with `<para>` tags. Added `wcwidth` to the user dictionary in `Terminal.sln.DotSettings` to avoid spelling errors. * Improve XML doc formatting in RuneExtensions.cs Updated the remarks section of the `GetColumns` method in the `RuneExtensions` class to enhance readability by reformatting and properly indenting `<para>` tags. The content remains unchanged, describing the method's implementation via `wcwidth` and its role as a Terminal.Gui extension for `System.Text.Rune`. * Refactor drivers and improve clipboard handling Replaced legacy drivers (`CursesDriver`, `NetDriver`) with `UnixDriver` and `DotNetDriver` across the codebase, including comments, method names, and test cases. Updated documentation and remarks to reflect the new driver names and platforms. Revamped clipboard handling with new platform-specific implementations: `UnixClipboard` for Unix, `MacOSXClipboard` for macOS, and `WSLClipboard` for Linux under WSL. Removed the old `CursesClipboard` and consolidated clipboard logic. Updated test cases to align with the new drivers and clipboard implementations. Improved naming consistency and cleaned up redundant code. Updated the README and documentation to reflect these changes. * Remove `PlatformColor` from `Attribute` struct This commit removes the `PlatformColor` property from the `Attribute` struct, simplifying the codebase by eliminating platform-specific color handling. The following changes were made: - Removed `PlatformColor` from the `Attribute` struct, including its initialization, usage, and related comments. - Updated constructors to no longer initialize or use `PlatformColor`. - Modified `Equals` and `GetHashCode` methods to exclude `PlatformColor`. - Updated `UnixComponentFactory` documentation to remove references to "v2unix." - Renamed `v2TestDriver` to `testDriver` in the `With` class for clarity. - Removed `PlatformColor` references in `DriverAssert` and related error messages. - Deleted test cases in `AttributeTests` that relied on `PlatformColor`. - Cleaned up comments and TODOs related to `PlatformColor` and `UnixDriver`. These changes reflect a shift away from platform-dependent color management, improving code clarity and reducing complexity. Remove `PlatformColor` and simplify `Attribute` logic The `PlatformColor` property has been removed from the `Attribute` struct, along with its associated logic, simplifying the codebase and eliminating platform-specific dependencies. Constructors, equality checks, and hash code generation in `Attribute` have been updated accordingly. The `CurrentAttribute` property in `ConsoleDriver` and `OutputBuffer` has been simplified, removing dependencies on `Application.Driver`. The `MakeColor` method logic has been removed or simplified in related classes. Tests in `AttributeTests` have been refactored to reflect these changes, focusing on `Foreground`, `Background`, and `Style`. Unix-specific logic tied to `PlatformColor` has been eliminated. Additional updates include renaming parameters in the `With` class for clarity, simplifying `DriverAssert` output, and performing minor code cleanups to improve readability and maintainability. * Refactor Terminal.Gui driver architecture for v2 Updated documentation to reflect the new modular driver architecture in Terminal.Gui v2. - Revised `namespace-drivers.md` to include new components (`IConsoleInput`, `IConsoleOutput`, `IInputProcessor`, `IOutputBuffer`, `IWindowSizeMonitor`) and terminal size monitoring. - Replaced "Key Components" with "Architecture Overview" and added details on the **Component Factory** pattern. - Documented the four driver implementations (`DotNetDriver`, `WindowsDriver`, `UnixDriver`, `FakeDriver`) and their platform-specific optimizations. - Added a "Threading Model" section to explain the multi-threaded design for responsive input handling. - Updated examples to demonstrate driver capabilities and explicit driver selection. In `drivers.md`: - Expanded the "Overview" to emphasize the modular, component-based architecture. - Reorganized "Drivers" into "Available Drivers" and added details on `FakeDriver` for unit testing. - Added sections on "Initialization Flow," "Shutdown Flow," and platform-specific driver details. - Provided examples for accessing driver components and creating custom drivers. In `index.md`: - Updated "Cross Platform" feature to reflect new driver names and clarified compatibility with SSH and monochrome terminals. * Moved files around --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Tig <tig@users.noreply.github.com> Co-authored-by: Thomas Nind <31306100+tznind@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…e badly using VSDebugConsole.exe (#4275) * Fixes #4274. Using Windows Host Console v2win is rendering window size badly using VSDebugConsole.exe * Fixes #4259. Our wcwidth library is out of date (#4281) * Update package versions and remove hack code from RuneExtensions Updated several package versions in `Directory.Packages.props`, including `JetBrains.Annotations`, `Microsoft.Extensions.Logging.Abstractions`, `System.IO.Abstractions`, and `Wcwidth`. Refactored methods in `RuneExtensions.cs`: - Simplified `GetColumns` by removing special Unicode handling. - Renamed constants to follow naming conventions. - Improved logic and readability in `DecodeSurrogatePair`, `Encode`, and `GetEncodingLength`. - Streamlined `IsSurrogatePair` and `MakePrintable` for clarity and efficiency. * Update package version ranges for flexibility Updated the `JetBrains.Annotations` package to use a version range starting from `2025.2.2` to allow future updates. Adjusted the `Microsoft.Extensions.Logging.Abstractions` package to a version range `[9.0.0,10)` for compatibility. Changed `System.IO.Abstractions` to a range `[22.0.16,23)` and `Wcwidth` to `[3.0.0,)` to enable future updates within specified ranges. * Remove legacy drivers, simplify architecture, and reorganize codebase structure (#4270) * Initial plan * Remove legacy drivers and reorganize v2 architecture Co-authored-by: tig <585482+tig@users.noreply.github.com> * Extract Windows key helper utilities and fix build Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix all test references to legacy drivers Co-authored-by: tig <585482+tig@users.noreply.github.com> * Update documentation to reflect new driver architecture Co-authored-by: tig <585482+tig@users.noreply.github.com> * Remove V2.cd diagram file Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix test failures: support legacy drivers and update exception handling Co-authored-by: tig <585482+tig@users.noreply.github.com> * updated driver names * Move V2 tests from ConsoleDrivers/V2 to proper locations Co-authored-by: tig <585482+tig@users.noreply.github.com> * Rename ApplicationV2 to ModernApplicationImpl to remove v2 terminology Co-authored-by: tig <585482+tig@users.noreply.github.com> * Remove V2 terminology from test drivers and FakeDriver classes Co-authored-by: tig <585482+tig@users.noreply.github.com> * Merge ModernApplicationImpl into ApplicationImpl and move to App folder Co-authored-by: tig <585482+tig@users.noreply.github.com> * Create modern FakeDriver with component factory architecture in Terminal.Gui project Co-authored-by: tig <585482+tig@users.noreply.github.com> * Refactor: Move non-platform-dependent code from /Drivers to /App Co-authored-by: tig <585482+tig@users.noreply.github.com> * Code cleanup and org * Unit test reorg * Refactor MainLoop architecture: rename classes and enhance documentation for clarity Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add comprehensive FakeDriver tests (WIP - some tests need fixes) Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fixed FakeDriver build failures * Fix all FakeDriver test failures - Application.Top creation and clipboard behaviors Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fixed FakeDriver build failures2 * Remove hanging legacy FakeDriver tests that use Console.MockKeyPresses Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fixed some tests * Fixed more tests * Fixed more tests * Fix bad copilot (#4277) * Update Terminal.Gui/Drivers/FakeDriver/FakeConsoleOutput.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor Application Init and Update Tests Refactored `Application.Init` to improve initialization logic: - Added fallback to `ForceDriver` when `driverName` is null. - Changed repeated `Init` calls to throw `InvalidOperationException`. - Updated `_driverName` assignment logic for robustness. Enhanced `IConsoleDriver` with detailed remarks on implementations. Revised test cases to align with updated `Application.Init` behavior: - Replaced `FakeDriver` with `null` and `driverName: "fake"`. - Skipped or commented out tests incompatible with new logic. - Improved formatting and removed redundant setup code. Improved code style and consistency across the codebase: - Standardized parameter formatting and spacing. - Removed outdated comments and unused code. General cleanup to enhance readability and maintainability. * Warp fix copilot (#4278) * More fixes (#4279) * Fixes/works around test failures and temporarily disable failing test Updated `FakeDriver` to set `RunningUnitTests` to `true` and initialize dimensions using `FakeConsole`. Modified `TestRespondersDisposedAttribute` to set `ConsoleDriver.RunningUnitTests` in the `Before` method, ensuring proper behavior during unit tests. Temporarily disabled the `Button_CanFocus_False_Raises_Accepted_Correctly` test in `ViewCommandTests` by adding a `Skip` parameter to the `[Fact]` attribute, referencing issue #4270. * Allow all tests to run despite failures in UnitTests Modified the `dotnet test` command in the `Run UnitTestsParallelizable` step to set `xunit.stopOnFail` to `false`. This ensures that the test runner does not stop execution on the first failure, allowing all tests to execute regardless of individual test outcomes. * Refactor ApplicationScreenTests for cleaner setup/teardown Refactored `ClearContents_Called_When_Top_Frame_Changes` test: - Added `[AutoInitShutdown]` attribute for automatic lifecycle management. - Replaced manual `Application.Init` and `Application.Top` setup with `Application.Begin` and `RunState`. - Simplified event handling by defining `ClearedContents` handler inline. - Removed explicit cleanup logic, relying on `Application.End` for teardown. Updated `using` directives to include `UnitTests` namespace. * Attempt to fix intermittent local test failures. Update ApplicationImpl initialization parameter Changed the second parameter of the `impl.Init` method in the `FakeApplicationFactory` class from `"dotnet"` to `"fake"`. * Code cleanup to cause Action to re-run. * Stop tests on first failure in UnitTestsParallelizable Updated the `dotnet test` command in `unit-tests.yml` to set the `xunit.stopOnFail` parameter to `true`. This change ensures that test execution halts immediately upon encountering a failure, allowing quicker identification and resolution of issues. Note that this may prevent the full test suite from running in the event of a failure. * Allow all tests to run despite failures in CI Updated `unit-tests.yml` to set `xunit.stopOnFail` to `false` in both `Run UnitTests` and `Run UnitTestsParallelizable` steps. This ensures that the test runner does not stop execution on the first test failure, allowing all tests to complete even if some fail. * Enhance RuneExtensions docs and update user dictionary Updated the `<remarks>` section in `RuneExtensions.GetColumns` to include details about the `wcwidth` implementation and improved readability with `<para>` tags. Added `wcwidth` to the user dictionary in `Terminal.sln.DotSettings` to avoid spelling errors. * Improve XML doc formatting in RuneExtensions.cs Updated the remarks section of the `GetColumns` method in the `RuneExtensions` class to enhance readability by reformatting and properly indenting `<para>` tags. The content remains unchanged, describing the method's implementation via `wcwidth` and its role as a Terminal.Gui extension for `System.Text.Rune`. * Refactor drivers and improve clipboard handling Replaced legacy drivers (`CursesDriver`, `NetDriver`) with `UnixDriver` and `DotNetDriver` across the codebase, including comments, method names, and test cases. Updated documentation and remarks to reflect the new driver names and platforms. Revamped clipboard handling with new platform-specific implementations: `UnixClipboard` for Unix, `MacOSXClipboard` for macOS, and `WSLClipboard` for Linux under WSL. Removed the old `CursesClipboard` and consolidated clipboard logic. Updated test cases to align with the new drivers and clipboard implementations. Improved naming consistency and cleaned up redundant code. Updated the README and documentation to reflect these changes. * Remove `PlatformColor` from `Attribute` struct This commit removes the `PlatformColor` property from the `Attribute` struct, simplifying the codebase by eliminating platform-specific color handling. The following changes were made: - Removed `PlatformColor` from the `Attribute` struct, including its initialization, usage, and related comments. - Updated constructors to no longer initialize or use `PlatformColor`. - Modified `Equals` and `GetHashCode` methods to exclude `PlatformColor`. - Updated `UnixComponentFactory` documentation to remove references to "v2unix." - Renamed `v2TestDriver` to `testDriver` in the `With` class for clarity. - Removed `PlatformColor` references in `DriverAssert` and related error messages. - Deleted test cases in `AttributeTests` that relied on `PlatformColor`. - Cleaned up comments and TODOs related to `PlatformColor` and `UnixDriver`. These changes reflect a shift away from platform-dependent color management, improving code clarity and reducing complexity. Remove `PlatformColor` and simplify `Attribute` logic The `PlatformColor` property has been removed from the `Attribute` struct, along with its associated logic, simplifying the codebase and eliminating platform-specific dependencies. Constructors, equality checks, and hash code generation in `Attribute` have been updated accordingly. The `CurrentAttribute` property in `ConsoleDriver` and `OutputBuffer` has been simplified, removing dependencies on `Application.Driver`. The `MakeColor` method logic has been removed or simplified in related classes. Tests in `AttributeTests` have been refactored to reflect these changes, focusing on `Foreground`, `Background`, and `Style`. Unix-specific logic tied to `PlatformColor` has been eliminated. Additional updates include renaming parameters in the `With` class for clarity, simplifying `DriverAssert` output, and performing minor code cleanups to improve readability and maintainability. * Refactor Terminal.Gui driver architecture for v2 Updated documentation to reflect the new modular driver architecture in Terminal.Gui v2. - Revised `namespace-drivers.md` to include new components (`IConsoleInput`, `IConsoleOutput`, `IInputProcessor`, `IOutputBuffer`, `IWindowSizeMonitor`) and terminal size monitoring. - Replaced "Key Components" with "Architecture Overview" and added details on the **Component Factory** pattern. - Documented the four driver implementations (`DotNetDriver`, `WindowsDriver`, `UnixDriver`, `FakeDriver`) and their platform-specific optimizations. - Added a "Threading Model" section to explain the multi-threaded design for responsive input handling. - Updated examples to demonstrate driver capabilities and explicit driver selection. In `drivers.md`: - Expanded the "Overview" to emphasize the modular, component-based architecture. - Reorganized "Drivers" into "Available Drivers" and added details on `FakeDriver` for unit testing. - Added sections on "Initialization Flow," "Shutdown Flow," and platform-specific driver details. - Provided examples for accessing driver components and creating custom drivers. In `index.md`: - Updated "Cross Platform" feature to reflect new driver names and clarified compatibility with SSH and monochrome terminals. * Moved files around --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Tig <tig@users.noreply.github.com> Co-authored-by: Thomas Nind <31306100+tznind@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix nit test. * Change ClearScreenNextIteration to internal and trying to fix unit test failure * Reuse method and fix text field color to normal, probably due some changed configuration * Fix scenario Shortcut not restoring Application.Quit * Giving more time to load Scrolling scenario and display failing scenario * Revert changes and add more assertions * Forcing CI tests again and I suspect that is causing by UpdateFromJson unit test * Changed test to force fake driver * Ensure restore the original colors * Fix ResetToHardCodedDefaults method * Tested with this before and the tests pass * Revert "Tested with this before and the tests pass" This reverts commit 297b885. * Revert "Fix ResetToHardCodedDefaults method" This reverts commit 3a28c5e. * Trying to fix scenario tests --------- Co-authored-by: Tig <tig@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Thomas Nind <31306100+tznind@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…#4287) * Fixes #4274. Using Windows Host Console v2win is rendering window size badly using VSDebugConsole.exe * Fixes #4259. Our wcwidth library is out of date (#4281) * Update package versions and remove hack code from RuneExtensions Updated several package versions in `Directory.Packages.props`, including `JetBrains.Annotations`, `Microsoft.Extensions.Logging.Abstractions`, `System.IO.Abstractions`, and `Wcwidth`. Refactored methods in `RuneExtensions.cs`: - Simplified `GetColumns` by removing special Unicode handling. - Renamed constants to follow naming conventions. - Improved logic and readability in `DecodeSurrogatePair`, `Encode`, and `GetEncodingLength`. - Streamlined `IsSurrogatePair` and `MakePrintable` for clarity and efficiency. * Update package version ranges for flexibility Updated the `JetBrains.Annotations` package to use a version range starting from `2025.2.2` to allow future updates. Adjusted the `Microsoft.Extensions.Logging.Abstractions` package to a version range `[9.0.0,10)` for compatibility. Changed `System.IO.Abstractions` to a range `[22.0.16,23)` and `Wcwidth` to `[3.0.0,)` to enable future updates within specified ranges. * Remove legacy drivers, simplify architecture, and reorganize codebase structure (#4270) * Initial plan * Remove legacy drivers and reorganize v2 architecture Co-authored-by: tig <585482+tig@users.noreply.github.com> * Extract Windows key helper utilities and fix build Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix all test references to legacy drivers Co-authored-by: tig <585482+tig@users.noreply.github.com> * Update documentation to reflect new driver architecture Co-authored-by: tig <585482+tig@users.noreply.github.com> * Remove V2.cd diagram file Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix test failures: support legacy drivers and update exception handling Co-authored-by: tig <585482+tig@users.noreply.github.com> * updated driver names * Move V2 tests from ConsoleDrivers/V2 to proper locations Co-authored-by: tig <585482+tig@users.noreply.github.com> * Rename ApplicationV2 to ModernApplicationImpl to remove v2 terminology Co-authored-by: tig <585482+tig@users.noreply.github.com> * Remove V2 terminology from test drivers and FakeDriver classes Co-authored-by: tig <585482+tig@users.noreply.github.com> * Merge ModernApplicationImpl into ApplicationImpl and move to App folder Co-authored-by: tig <585482+tig@users.noreply.github.com> * Create modern FakeDriver with component factory architecture in Terminal.Gui project Co-authored-by: tig <585482+tig@users.noreply.github.com> * Refactor: Move non-platform-dependent code from /Drivers to /App Co-authored-by: tig <585482+tig@users.noreply.github.com> * Code cleanup and org * Unit test reorg * Refactor MainLoop architecture: rename classes and enhance documentation for clarity Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add comprehensive FakeDriver tests (WIP - some tests need fixes) Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fixed FakeDriver build failures * Fix all FakeDriver test failures - Application.Top creation and clipboard behaviors Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fixed FakeDriver build failures2 * Remove hanging legacy FakeDriver tests that use Console.MockKeyPresses Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fixed some tests * Fixed more tests * Fixed more tests * Fix bad copilot (#4277) * Update Terminal.Gui/Drivers/FakeDriver/FakeConsoleOutput.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor Application Init and Update Tests Refactored `Application.Init` to improve initialization logic: - Added fallback to `ForceDriver` when `driverName` is null. - Changed repeated `Init` calls to throw `InvalidOperationException`. - Updated `_driverName` assignment logic for robustness. Enhanced `IConsoleDriver` with detailed remarks on implementations. Revised test cases to align with updated `Application.Init` behavior: - Replaced `FakeDriver` with `null` and `driverName: "fake"`. - Skipped or commented out tests incompatible with new logic. - Improved formatting and removed redundant setup code. Improved code style and consistency across the codebase: - Standardized parameter formatting and spacing. - Removed outdated comments and unused code. General cleanup to enhance readability and maintainability. * Warp fix copilot (#4278) * More fixes (#4279) * Fixes/works around test failures and temporarily disable failing test Updated `FakeDriver` to set `RunningUnitTests` to `true` and initialize dimensions using `FakeConsole`. Modified `TestRespondersDisposedAttribute` to set `ConsoleDriver.RunningUnitTests` in the `Before` method, ensuring proper behavior during unit tests. Temporarily disabled the `Button_CanFocus_False_Raises_Accepted_Correctly` test in `ViewCommandTests` by adding a `Skip` parameter to the `[Fact]` attribute, referencing issue #4270. * Allow all tests to run despite failures in UnitTests Modified the `dotnet test` command in the `Run UnitTestsParallelizable` step to set `xunit.stopOnFail` to `false`. This ensures that the test runner does not stop execution on the first failure, allowing all tests to execute regardless of individual test outcomes. * Refactor ApplicationScreenTests for cleaner setup/teardown Refactored `ClearContents_Called_When_Top_Frame_Changes` test: - Added `[AutoInitShutdown]` attribute for automatic lifecycle management. - Replaced manual `Application.Init` and `Application.Top` setup with `Application.Begin` and `RunState`. - Simplified event handling by defining `ClearedContents` handler inline. - Removed explicit cleanup logic, relying on `Application.End` for teardown. Updated `using` directives to include `UnitTests` namespace. * Attempt to fix intermittent local test failures. Update ApplicationImpl initialization parameter Changed the second parameter of the `impl.Init` method in the `FakeApplicationFactory` class from `"dotnet"` to `"fake"`. * Code cleanup to cause Action to re-run. * Stop tests on first failure in UnitTestsParallelizable Updated the `dotnet test` command in `unit-tests.yml` to set the `xunit.stopOnFail` parameter to `true`. This change ensures that test execution halts immediately upon encountering a failure, allowing quicker identification and resolution of issues. Note that this may prevent the full test suite from running in the event of a failure. * Allow all tests to run despite failures in CI Updated `unit-tests.yml` to set `xunit.stopOnFail` to `false` in both `Run UnitTests` and `Run UnitTestsParallelizable` steps. This ensures that the test runner does not stop execution on the first test failure, allowing all tests to complete even if some fail. * Enhance RuneExtensions docs and update user dictionary Updated the `<remarks>` section in `RuneExtensions.GetColumns` to include details about the `wcwidth` implementation and improved readability with `<para>` tags. Added `wcwidth` to the user dictionary in `Terminal.sln.DotSettings` to avoid spelling errors. * Improve XML doc formatting in RuneExtensions.cs Updated the remarks section of the `GetColumns` method in the `RuneExtensions` class to enhance readability by reformatting and properly indenting `<para>` tags. The content remains unchanged, describing the method's implementation via `wcwidth` and its role as a Terminal.Gui extension for `System.Text.Rune`. * Refactor drivers and improve clipboard handling Replaced legacy drivers (`CursesDriver`, `NetDriver`) with `UnixDriver` and `DotNetDriver` across the codebase, including comments, method names, and test cases. Updated documentation and remarks to reflect the new driver names and platforms. Revamped clipboard handling with new platform-specific implementations: `UnixClipboard` for Unix, `MacOSXClipboard` for macOS, and `WSLClipboard` for Linux under WSL. Removed the old `CursesClipboard` and consolidated clipboard logic. Updated test cases to align with the new drivers and clipboard implementations. Improved naming consistency and cleaned up redundant code. Updated the README and documentation to reflect these changes. * Remove `PlatformColor` from `Attribute` struct This commit removes the `PlatformColor` property from the `Attribute` struct, simplifying the codebase by eliminating platform-specific color handling. The following changes were made: - Removed `PlatformColor` from the `Attribute` struct, including its initialization, usage, and related comments. - Updated constructors to no longer initialize or use `PlatformColor`. - Modified `Equals` and `GetHashCode` methods to exclude `PlatformColor`. - Updated `UnixComponentFactory` documentation to remove references to "v2unix." - Renamed `v2TestDriver` to `testDriver` in the `With` class for clarity. - Removed `PlatformColor` references in `DriverAssert` and related error messages. - Deleted test cases in `AttributeTests` that relied on `PlatformColor`. - Cleaned up comments and TODOs related to `PlatformColor` and `UnixDriver`. These changes reflect a shift away from platform-dependent color management, improving code clarity and reducing complexity. Remove `PlatformColor` and simplify `Attribute` logic The `PlatformColor` property has been removed from the `Attribute` struct, along with its associated logic, simplifying the codebase and eliminating platform-specific dependencies. Constructors, equality checks, and hash code generation in `Attribute` have been updated accordingly. The `CurrentAttribute` property in `ConsoleDriver` and `OutputBuffer` has been simplified, removing dependencies on `Application.Driver`. The `MakeColor` method logic has been removed or simplified in related classes. Tests in `AttributeTests` have been refactored to reflect these changes, focusing on `Foreground`, `Background`, and `Style`. Unix-specific logic tied to `PlatformColor` has been eliminated. Additional updates include renaming parameters in the `With` class for clarity, simplifying `DriverAssert` output, and performing minor code cleanups to improve readability and maintainability. * Refactor Terminal.Gui driver architecture for v2 Updated documentation to reflect the new modular driver architecture in Terminal.Gui v2. - Revised `namespace-drivers.md` to include new components (`IConsoleInput`, `IConsoleOutput`, `IInputProcessor`, `IOutputBuffer`, `IWindowSizeMonitor`) and terminal size monitoring. - Replaced "Key Components" with "Architecture Overview" and added details on the **Component Factory** pattern. - Documented the four driver implementations (`DotNetDriver`, `WindowsDriver`, `UnixDriver`, `FakeDriver`) and their platform-specific optimizations. - Added a "Threading Model" section to explain the multi-threaded design for responsive input handling. - Updated examples to demonstrate driver capabilities and explicit driver selection. In `drivers.md`: - Expanded the "Overview" to emphasize the modular, component-based architecture. - Reorganized "Drivers" into "Available Drivers" and added details on `FakeDriver` for unit testing. - Added sections on "Initialization Flow," "Shutdown Flow," and platform-specific driver details. - Provided examples for accessing driver components and creating custom drivers. In `index.md`: - Updated "Cross Platform" feature to reflect new driver names and clarified compatibility with SSH and monochrome terminals. * Moved files around --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Tig <tig@users.noreply.github.com> Co-authored-by: Thomas Nind <31306100+tznind@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix nit test. * Change ClearScreenNextIteration to internal and trying to fix unit test failure * Reuse method and fix text field color to normal, probably due some changed configuration * Fix scenario Shortcut not restoring Application.Quit * Giving more time to load Scrolling scenario and display failing scenario * Revert changes and add more assertions * Forcing CI tests again and I suspect that is causing by UpdateFromJson unit test * Changed test to force fake driver * Ensure restore the original colors * Update test runner behavior in unit-tests.yml Changed `fail-fast` to `false` in `non_parallel_unittests` to allow all runners to complete even if errors occur. Updated `xunit.stopOnFail` to `true` in both `Run UnitTests` and `Run UnitTestsParallelizable` steps to stop test execution immediately upon failure. These changes improve test handling and execution consistency. Refactor and enhance configuration and scheme handling Refactored `ConfigurationManager` and `Scope<T>` to improve clarity and ensure proper resetting to hardcoded defaults. Updated `Color` constructor to use ARGB values for accuracy. Added debug assertions and logging for better test reliability. Expanded test coverage: - Verified hardcoded schemes and themes reset correctly. - Added tests for `UpdateFromJson` behavior and `Color.ToString` output. - Improved `SchemeManager` and `SchemeTests` to validate attributes and scheme overrides. General improvements include better state management during tests and enhanced readability of event handlers. * Found cause of #4288 and provided a workaround * Reverted unneeded change to ComboBoxTests * Fixed test that wasn't actually testing anything * Added more precise unit test showing issue * Added more precise unit test showing issue2 * Made test even more precise * Potential fix for underlying issue * Fixed test that broke with last change * Reverted`ConfigurationManager` to return `_hardCodedConfigPropertyCache` directly, eliminating deep copy overhead for better performance. Added a new test in `ConfigurationManagerTests` to verify that `GetHardCodedConfigPropertyCache` always returns the same reference. Updated existing tests to reflect this change. Refactored `SchemeManagerTests` to use `try-finally` blocks for proper cleanup and improved test reliability. Applied similar changes to other test methods for consistency. Re-enabled the `UpdateFrom_Corrupts_Schemes_HardCodeDefaults` test in `ThemeScopeTests` as the underlying issue has been rnot been esolved. * Updated the `Disable` method calls across test classes to use the new overload with a `true` parameter, ensuring consistent behavior. * Refactor and fix configuration and theme management Refactored method names across multiple classes for clarity and consistency (e.g., `LoadCurrentValues` to `UpdateToCurrentValues`, `ResetToHardCodedDefaults` to `LoadHardCodedDefaults`). Removed redundant attributes from `ConfigurationManager`. Implemented a workaround for `SchemeManager` to address issues with hard-coded schemes being overwritten. Updated `ThemeManager` logic to ensure proper initialization and updates of themes. Aligned unit tests with refactored methods and added comments to document changes. Made minor adjustments to improve code maintainability, including handling of property values and removal of unused variables. * Fix hard-coded defaults corruption in ThemeScope Replaced `ResetToCurrentValues` with `ResetToHardCodedDefaults` across multiple files to address corruption of hard-coded defaults. - Added a partial workaround in `ConfigurationManager.cs` to prevent overwriting hard-coded schemes in `ThemeScope`. - Highlighted known issues with `UpdateToCurrentValues` in `ThemeManager.cs`. - Updated tests in `ConfigurationManagerTests`, `SchemeManagerTests`, and others to reflect the reset method. - Skipped or modified tests that rely on `ResetToCurrentValues` due to its corruption issues. - Refactored `GlyphTests` to ensure proper cleanup using `try-finally`. - Added comments and skipped tests to document and work around known bugs (e.g., #4288). * Clarify comments and add theme reset functionality Updated comments in `SchemeManager` and `ThemeManager` to clarify that the workaround for hardcoded schemes is partial. Added a new `LoadHardCodedDefaults` method to `ThemeManager`, marked with `[RequiresUnreferencedCode]` and `[RequiresDynamicCode]`, to reset themes to hardcoded defaults. This method ensures proper initialization by throwing an exception if `ConfigurationManager` is not initialized. Updated `ThemeManager` to call `SchemeManager.LoadToHardCodedDefaults` during the theme reset process, ensuring consistent loading of hardcoded schemes. * Removed special handling for the "Schemes" key in `hardCodedThemeProperties`, * Code cleanup Refactored XML documentation comments for better readability. Enhanced exception handling in `GetScheme(Schemes)` by adding a null check and throwing `ArgumentException` for invalid inputs. Simplified method definitions by converting multi-line methods to single-line. Updated attributes for `LoadToHardCodedDefaults` to align with the `SetSchemes` method. Refactored `LoadToHardCodedDefaults` implementation for cleaner code. Added support for Visual Studio debug console in `WindowsDriver`, including disabling the alternative screen buffer, preserving original console colors, and restoring them on shutdown. Performed general code cleanup, including removing unnecessary comments and improving inline comments for clarity. * Refactor and remove redundant validation methods Removed `Validate` methods from `ConfigurationManager`, `Scope<T>`, and `ThemeManager`, indicating a shift in validation responsibilities. Enabled nullable reference types in `Scope.cs` to enforce stricter nullability checks. Simplified `Scope<T>` constructor and replaced explicit type declarations with `var` for improved readability. Adjusted LINQ query formatting and removed unused `using System.Text.Json;` to clean up dependencies. Made minor formatting changes for consistency and maintainability. * Refactor ConfigurationManager for clarity and safety Renamed `ResetToCurrentValues` to `UpdateToCurrentValues` for better clarity and updated all references, including comments and documentation. Introduced `_hardCodedConfigPropertyCacheLock` to ensure thread-safety when accessing `_hardCodedConfigPropertyCache`. Updated `Reset` terminology to `Update` across the codebase to reflect the updated behavior. Improved `SerializerContext` initialization with concise syntax and fixed a formatting issue in a `Console.WriteLine` statement. Reformatted filtering logic for `configPropertiesByScope` for better readability. Updated test cases in `AppSettingsScopeTests` and `ConfigurationManagerTests` to align with the renamed method and ensure consistent functionality. * Code cleanup Improve readability and handle null in serialization Refactored LINQ queries to remove redundant line breaks, improving code readability. Updated comments for clarity and adjusted tone. Added a null check for the `prop` variable during serialization to ensure proper handling of null values by writing `null` to the JSON writer. * Code Cleanup - Refactor ThemeManager and improve nullability handling Updated ThemeManager to improve method visibility, naming consistency, and documentation. Introduced `GetHardCodedThemes` and `SetThemes` for better encapsulation. Made `DEFAULT_THEME_NAME` public for broader access. Enhanced nullability handling across multiple files using the null-forgiving operator (`!`) to suppress warnings. Refactored `Themes.cs` to ensure proper cleanup of `allViewsView`. Simplified assertions in test files to reflect updated method visibility and removed redundant checks. Improved code clarity and maintainability throughout the codebase. --------- Co-authored-by: BDisp <bd.bdisp@gmail.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Thomas Nind <31306100+tznind@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This PR completes the migration to the modern driver architecture by removing all legacy v1 drivers, eliminating "v2" terminology, and reorganizing the codebase for better maintainability and separation of concerns.
Removed Legacy Drivers (~4,000 lines)
Deleted the following legacy driver directories and all supporting code:
Terminal.Gui/Drivers/CursesDriver/- ncurses-based driver with Unix bindingsTerminal.Gui/Drivers/NetDriver/- Legacy .NET Console driverTerminal.Gui/Drivers/WindowsDriver/- Legacy Windows Console API driverUnixMainLoop,NetMainLoop,WindowsMainLoopbinding.cs,constants.cs,handles.cs)Reorganized Driver Structure
Moved all files from the
V2/directory into a clean, organized structure:Simplified Driver Names
Driver names no longer use "v2" prefix:
"v2net"→"dotnet""v2win"→"windows""v2unix"→"unix"Updated
Application.GetDriverTypes()to return the new names.Architecture Simplification
Merged Application Implementations
ModernApplicationImpl.cs(previouslyApplicationV2.cs)ApplicationImpl.csin theAppfolderSeparated Platform-Independent from Platform-Specific Code
Reorganized codebase to clearly separate concerns:
Moved to
/App(platform-independent):/App/MainLoop/- Main loop orchestration (ApplicationMainLoop<T>,MainLoopCoordinator, interfaces)/App/Lifecycle/- View lifecycle management (ToplevelTransitionManager, interface)/App/NotInitializedException.cs- Application exception typeRemains in
/Drivers(platform-specific):DotNetDriver,WindowsDriver,UnixDriver,FakeDriver)IConsoleInput,IConsoleOutput,IComponentFactory, etc.)Platform.cs,PlatformDetection.cs)InputProcessor,OutputBase,OutputBuffer)Clarified MainLoop Architecture
Renamed for clarity:
MainLoop.cs→LegacyMainLoopDriver.cs(marked obsolete, for FakeDriver compatibility)MainLoop<T>→ApplicationMainLoop<T>(the modern main application loop)IMainLoop<T>→IApplicationMainLoop<T>(interface for main loop)Result:
Removed V2 Terminology
Renamed all classes and types to remove "V2" terminology:
Core Classes:
ApplicationV2→ApplicationImpl(merged)FakeDriverV2→FakeConsoleDriverIFakeDriverV2→IFakeConsoleDriverTest Infrastructure:
V2TestDriver→TestDriverV2TestDrivers→TestDriversV2Win→Windows,V2Net→DotNetModern FakeDriver Implementation
Created a proper modern FakeDriver using the component factory architecture in
Terminal.Gui/Drivers/FakeDriver/:New Files:
FakeComponentFactory.cs- Factory for creating fake console componentsFakeConsoleInput.cs- Fake input that extendsConsoleInput<ConsoleKeyInfo>and supports predefined inputFakeConsoleOutput.cs- Fake output that extendsOutputBaseand captures console output for verificationArchitecture:
IComponentFactory<ConsoleKeyInfo>pattern like DotNetDriverThe legacy FakeDriver remains in place temporarily for backward compatibility with existing tests.
FakeDriver Testing - All Tests Passing ✅
Added comprehensive test suite for FakeDriver in
Tests/UnitTests/ConsoleDrivers/FakeDriverTests.cs:Fixed issues:
Console.MockKeyPressesand hung indefinitely with modern architectureResult: All 21 FakeDriver tests pass, plus 3 ConsoleDriverTests pass without hanging!
Removed Hanging Tests & Added Proper Coverage
Removed the following tests from ConsoleDriverTests.cs because they:
Console.MockKeyPresses) incompatible with modern architectureApplication.Run()loopsRemoved tests:
FakeDriver_MockKeyPressesFakeDriver_Only_Sends_Keystrokes_Through_MockKeyPressesFakeDriver_IsValidInput_Wrong_Surrogate_SequenceFakeDriver_IsValidInput_Correct_Surrogate_SequenceAdded replacement tests in NetInputProcessorTests.cs:
ProcessInput_Handles_Valid_Surrogate_Pair- Tests valid high+low surrogate sequencesProcessInput_Handles_Invalid_High_Surrogate_Without_Low- Tests incomplete high surrogateProcessInput_Handles_Invalid_Low_Surrogate_Without_High- Tests orphaned low surrogateProcessInput_Handles_Invalid_Reversed_Surrogates- Tests reversed surrogate orderThe new tests properly validate UTF-16 surrogate pair handling in the input processor layer where this logic actually resides.
Test Organization
Moved test files from
Tests/UnitTests/ConsoleDrivers/V2/to appropriate locations:Moved to Application folder:
ApplicationV2Tests.cs→ApplicationImplTests.csMainLoopCoordinatorTests.csMainLoopTTests.csMoved to ConsoleDrivers folder:
ConsoleInputTests.csMouseInterpreterTests.csNetInputProcessorTests.csWindowSizeMonitorTests.csWindowsInputProcessorTests.csExtracted Utilities
Created helper classes to support the reorganization:
WindowsKeyHelper- Static key conversion utilities extracted from legacy WindowsDriverPlatformDetection- WSL and platform detection utilitiesUpdated Documentation
docfx/docs/drivers.md- Removed legacy driver documentation, added modern driver infoApplication.Driver.cs,ApplicationImpl.cs,Application.Initialization.csBreaking Changes
For code using legacy drivers directly:
new CursesDriver(),new NetDriver(),new WindowsDriver()will no longer compileApplication.ForceDriver = "dotnet"/"windows"/"unix"insteadFor code using v2 driver names:
"v2net"→"dotnet""v2win"→"windows""v2unix"→"unix"Most applications using
Application.Init()without specifying a driver will be unaffected - the framework automatically selects the appropriate driver for the platform.Testing
Summary
This PR removes ~4,000 lines of legacy code, eliminates all "V2" terminology, clarifies the MainLoop architecture with better naming and documentation, and creates a cleaner separation between platform-independent application infrastructure (
/App) and platform-specific driver implementations (/Drivers). The modern component factory architecture is now the only architecture, with three production drivers (dotnet, windows, unix) and a fully functional modern fake driver for testing.Fixes #4245
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.